Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: gn/BUILD.gn

Issue 2347443002: Compile the skia library for windows using gn. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 Google Inc. 1 # Copyright 2016 Google Inc.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 declare_args() { 6 declare_args() {
7 ar = "ar" 7 ar = "ar"
8 cc = "cc" 8 cc = "cc"
9 cxx = "c++" 9 cxx = "c++"
10 10
11 if (is_android) { 11 if (is_android) {
12 ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar" 12 ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar"
13 cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang" 13 cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
14 cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++" 14 cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
15 } 15 }
16 16
17 extra_cflags = "" 17 extra_cflags = ""
18 extra_cflags_c = "" 18 extra_cflags_c = ""
19 extra_cflags_cc = "" 19 extra_cflags_cc = ""
20 extra_ldflags = "" 20 extra_ldflags = ""
21 21
22 compiler_prefix = "" 22 compiler_prefix = ""
23 } 23 }
24 24
25 config("no_rtti") { 25 if (is_win) {
26 if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI 26 config("default") {
27 cflags_cc = [ "-fno-rtti" ] 27 cflags = [
28 "/Gy", # Enable function-level linking.
mtklein 2016/09/14 21:25:14 If there is any doubt, let's leave it out.
herb_g 2016/09/16 19:54:15 Done.
29 "/FS", # Preserve previous PDB behavior.
30 "/bigobj", # Some of our files are bigger than the regular limits.
31 ]
32 cflags_c = ["/TC"]
33 cflags_cc = ["/TP"]
34 defines = [
35 "_HAS_EXCEPTIONS=0",
36 "WIN32_LEAN_AND_MEAN",
37 "NOMINMAX",
38 ]
39 }
40
41 config("no_rtti") {
42 }
43
44 config("executable") {
45
46 }
47 } else {
48 config("default") {
49 cflags = [
50 "-O1",
51 "-fstrict-aliasing",
52 "-fPIC",
53 "-fvisibility=hidden",
54
55 "-Werror",
56 "-Wall",
57 "-Wextra",
58 "-Winit-self",
59 "-Wpointer-arith",
60 "-Wsign-compare",
61 "-Wvla",
62
63 "-Wno-deprecated-declarations",
64 "-Wno-unused-parameter",
65 ]
66 cflags_cc = [
67 "-std=c++11",
68 "-fno-exceptions",
69 "-fno-threadsafe-statics",
70 "-fvisibility-inlines-hidden",
71
72 "-Wnon-virtual-dtor",
73 ]
74 ldflags = []
75
76 # It's annoying to wait for full debug symbols to push over
77 # to Android devices. -gline-tables-only is a lot slimmer.
78 if (is_android) {
mtklein 2016/09/14 21:25:14 This needs some rebasing.
herb_g 2016/09/16 19:54:15 Done.
79 cflags += [ "-gline-tables-only" ]
80 } else {
81 cflags += [ "-g" ]
82 }
83
84 if (current_cpu == "arm") {
85 cflags += [
86 "-march=armv7-a",
87 "-mfpu=neon",
88 "-mthumb",
89 ]
90 } else if (current_cpu == "mipsel") {
91 cflags += [
92 "-march=mips32r2",
93 "-mdspr2",
94 ]
95 }
96
97 if (is_android) {
98 asmflags = [
99 "--target=$ndk_target",
100 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
101 ]
102 cflags += [
103 "--sysroot=$ndk/platforms/$ndk_platform",
104 "--target=$ndk_target",
105 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
106 ]
107 cflags_cc += [
108 "-isystem$ndk/sources/android/support/include",
109 "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include",
110 ]
111 ldflags += [
112 "--sysroot=$ndk/platforms/$ndk_platform",
113 "--target=$ndk_target",
114 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
115 "-pie",
116 ]
117 lib_dirs = [
118 "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
119 "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/ 4.9.x",
120 ]
121 libs = [
122 # Order matters here! Keep these three in exactly this order.
123 "c++_static",
124 "c++abi",
125 "android_support",
126 ]
127 if (target_cpu == "arm") {
128 libs += [ "unwind" ]
129 }
130 }
131
132 if (is_linux) {
133 libs = [ "pthread" ]
mtklein 2016/09/14 21:25:14 This is the source of our global pthread power.
herb_g 2016/09/16 19:54:15 Done.
134 }
135
136 if (sanitize != "") {
137 # You can either pass the sanitizers directly, e.g. "address,undefined",
138 # or pass one of the couple common aliases used by the bots.
139 sanitizers = sanitize
140 if (sanitize == "ASAN") {
141 sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attri bute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-over flow,unreachable,vla-bound,vptr"
142 } else if (sanitize == "TSAN") {
143 sanitizers = "thread"
144 } else if (sanitize == "MSAN") {
145 sanitizers = "memory"
146 }
147
148 cflags += [
149 "-fsanitize=$sanitizers",
150 "-fno-sanitize-recover=$sanitizers",
151 "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
152 ]
153 ldflags += [ "-fsanitize=$sanitizers" ]
154 if (sanitizers == "memory") {
155 cflags += [ "-fsanitize-memory-track-origins" ]
156 cflags_cc += [ "-stdlib=libc++" ]
157 ldflags += [ "-stdlib=libc++" ]
158 }
159 }
160 }
161
162 config("no_rtti") {
163 if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
164 cflags_cc = [ "-fno-rtti" ]
165 }
166 }
167
168 config("release") {
169 cflags = [ "-O3" ]
170 defines = [ "NDEBUG" ]
171 }
172
173 config("executable") {
174 if (is_mac) {
175 ldflags = [ "-Wl,-rpath,@loader_path/." ]
176 } else if (is_linux) {
177 ldflags = [ "-Wl,-rpath,\$ORIGIN" ]
178 }
28 } 179 }
29 } 180 }
30 181
31 config("default") { 182 toolchain("msvc") {
32 cflags = [ 183
33 "-O1", 184 tool("cc") {
34 "-fstrict-aliasing", 185 rspfile = "{{output}}.rsp"
35 "-fPIC", 186 precompiled_header_type = "msvc"
36 "-fvisibility=hidden", 187 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
37 188
38 "-Werror", 189 # Label names may have spaces in them so the pdbname must be quoted. The
39 "-Wall", 190 # source and output don't need to be quoted because GN knows they're a
40 "-Wextra", 191 # full file name and will quote automatically when necessary.
41 "-Winit-self", 192 command = "ninja -t msvc -e environment.x64 -- C:\Program Files (x86)\Micr osoft Visual Studio 14.0\VC\bin\amd64\cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
42 "-Wpointer-arith", 193 depsformat = "msvc"
43 "-Wsign-compare", 194 description = "CC {{output}}"
44 "-Wvla", 195 outputs = [
45 196 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
46 "-Wno-deprecated-declarations", 197 # "$object_subdir/{{source_name_part}}.obj",
mtklein 2016/09/14 21:25:14 Probably can clean up these working drafts.
herb_g 2016/09/16 19:54:15 Done.
47 "-Wno-unused-parameter", 198 ]
48 ] 199 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_c}}"
49 cflags_cc = [ 200 }
50 "-std=c++11", 201
51 "-fno-exceptions", 202 tool("cxx") {
52 "-fno-threadsafe-statics", 203 rspfile = "{{output}}.rsp"
53 "-fvisibility-inlines-hidden", 204 precompiled_header_type = "msvc"
54 205 pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
55 "-Wnon-virtual-dtor", 206
56 ] 207 # Label names may have spaces in them so the pdbname must be quoted. The
57 ldflags = [] 208 # source and output don't need to be quoted because GN knows they're a
58 209 # full file name and will quote automatically when necessary.
59 # It's annoying to wait for full debug symbols to push over 210 command = "ninja -t msvc -e environment.x64 -- C:\Program Files (x86)\Micr osoft Visual Studio 14.0\VC\bin\amd64\cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
60 # to Android devices. -gline-tables-only is a lot slimmer. 211 depsformat = "msvc"
61 if (is_android) { 212 description = "C++ {{output}}"
62 cflags += [ "-gline-tables-only" ] 213 outputs = [
63 } else { 214 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
64 cflags += [ "-g" ] 215 # "$object_subdir/{{source_name_part}}.obj",
65 } 216 ]
66 217 rspfile_content = "{{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}}"
67 if (current_cpu == "arm") { 218 }
68 cflags += [ 219
69 "-march=armv7-a", 220 tool("alink") {
70 "-mfpu=neon", 221 rspfile = "{{output}}.rsp"
71 "-mthumb", 222 gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/wi n_tool.py")
72 ] 223 command = "python $gyp_win_tool_path link-wrapper environment.x64 False li b.exe /nologo {{arflags}} /OUT:{{output}} @$rspfile"
73 } else if (current_cpu == "mipsel") { 224 description = "LIB {{output}}"
74 cflags += [ 225 outputs = [
75 "-march=mips32r2", 226 # Ignore {{output_extension}} and always use .lib, there's no reason to
76 "-mdspr2", 227 # allow targets to override this extension on Windows.
77 ] 228 #"{{output_dir}}/{{target_output_name}}.lib",
78 } 229 "{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
79 230 ]
80 if (is_android) { 231 default_output_extension = ".lib"
81 asmflags = [ 232 default_output_dir = "{{target_out_dir}}"
82 "--target=$ndk_target", 233
83 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", 234 # The use of inputs_newline is to work around a fixed per-line buffer
84 ] 235 # size in the linker.
85 cflags += [ 236 rspfile_content = "{{inputs_newline}}"
86 "--sysroot=$ndk/platforms/$ndk_platform", 237 }
87 "--target=$ndk_target", 238
88 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", 239 tool("link") {
89 ] 240 exename = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
90 cflags_cc += [ 241 pdbname = "$exename.pdb"
91 "-isystem$ndk/sources/android/support/include", 242 rspfile = "$exename.rsp"
92 "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include", 243
93 ] 244 gyp_win_tool_path = rebase_path("../third_party/externals/gyp/pylib/gyp/wi n_tool.py")
94 ldflags += [ 245 command = "python $gyp_win_tool_path link-wrapper environment.x64 False li nk.exe /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
95 "--sysroot=$ndk/platforms/$ndk_platform", 246
96 "--target=$ndk_target", 247 default_output_extension = ".exe"
97 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", 248 default_output_dir = "{{root_out_dir}}"
98 "-pie", 249 description = "LINK {{output}}"
99 ] 250 outputs = [
100 lib_dirs = [ 251 #"{{root_out_dir}}/{{target_output_name}}{{output_extension}}",
101 "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib", 252 exename,
102 "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4. 9.x", 253 ]
103 ] 254 #if (symbol_level != 0) {
104 libs = [ 255 # outputs += [ pdbname ]
105 # Order matters here! Keep these three in exactly this order. 256 #}
106 "c++_static", 257 #runtime_outputs = outputs
107 "c++abi", 258
108 "android_support", 259 # The use of inputs_newline is to work around a fixed per-line buffer
109 ] 260 # size in the linker.
110 if (target_cpu == "arm") { 261 rspfile_content = "{{inputs_newline}} {{libs}} {{solibs}} {{ldflags}}"
111 libs += [ "unwind" ] 262 }
112 } 263
113 } 264
114 265 tool("stamp") {
115 if (is_linux) { 266 win_stamp_path = rebase_path("win_stamp.py")
116 libs = [ "pthread" ] 267 command = "python $win_stamp_path {{output}}"
117 } 268 }
118
119 if (sanitize != "") {
120 # You can either pass the sanitizers directly, e.g. "address,undefined",
121 # or pass one of the couple common aliases used by the bots.
122 sanitizers = sanitize
123 if (sanitize == "ASAN") {
124 sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribu te,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overfl ow,unreachable,vla-bound,vptr"
125 } else if (sanitize == "TSAN") {
126 sanitizers = "thread"
127 } else if (sanitize == "MSAN") {
128 sanitizers = "memory"
129 }
130
131 cflags += [
132 "-fsanitize=$sanitizers",
133 "-fno-sanitize-recover=$sanitizers",
134 "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
135 ]
136 ldflags += [ "-fsanitize=$sanitizers" ]
137 if (sanitizers == "memory") {
138 cflags += [ "-fsanitize-memory-track-origins" ]
139 cflags_cc += [ "-stdlib=libc++" ]
140 ldflags += [ "-stdlib=libc++" ]
141 }
142 }
143 } 269 }
144 270
145 config("release") {
146 cflags = [ "-O3" ]
147 defines = [ "NDEBUG" ]
148 }
149
150 config("executable") {
151 if (is_mac) {
152 ldflags = [ "-Wl,-rpath,@loader_path/." ]
153 } else if (is_linux) {
154 ldflags = [ "-Wl,-rpath,\$ORIGIN" ]
155 }
156 }
157
158 toolchain("gcc_like") { 271 toolchain("gcc_like") {
159 lib_switch = "-l" 272 lib_switch = "-l"
160 lib_dir_switch = "-L" 273 lib_dir_switch = "-L"
161 274
162 tool("cc") { 275 tool("cc") {
163 depfile = "{{output}}.d" 276 depfile = "{{output}}.d"
164 command = "$compiler_prefix $cc -MMD -MF $depfile {{defines}} {{include_dirs }} {{cflags}} {{cflags_c}} $extra_cflags $extra_cflags_c -c {{source}} -o {{outp ut}}" 277 command = "$compiler_prefix $cc -MMD -MF $depfile {{defines}} {{include_dirs }} {{cflags}} {{cflags_c}} $extra_cflags $extra_cflags_c -c {{source}} -o {{outp ut}}"
165 depsformat = "gcc" 278 depsformat = "gcc"
166 outputs = [ 279 outputs = [
167 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", 280 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 341 }
229 342
230 tool("stamp") { 343 tool("stamp") {
231 command = "touch {{output}}" 344 command = "touch {{output}}"
232 } 345 }
233 346
234 tool("copy") { 347 tool("copy") {
235 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" 348 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
236 } 349 }
237 } 350 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698