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

Side by Side Diff: build/toolchain/mac/BUILD.gn

Issue 2387723002: Test CL to demonstrate GN + hermetic toolchain
Patch Set: more fixes. Created 4 years, 2 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 (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires 5 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires
6 # some enhancements since the commands on Mac are slightly different than on 6 # some enhancements since the commands on Mac are slightly different than on
7 # Linux. 7 # Linux.
8 8
9 import("../goma.gni") 9 import("../goma.gni")
10 import("//build/config/clang/clang.gni") 10 import("//build/config/clang/clang.gni")
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 "//build/toolchain/mac/filter_libtool.py", 55 "//build/toolchain/mac/filter_libtool.py",
56 "//build/toolchain/mac/linker_driver.py", 56 "//build/toolchain/mac/linker_driver.py",
57 ], 57 ],
58 root_build_dir), 58 root_build_dir),
59 "trim scope") 59 "trim scope")
60 60
61 # Shared toolchain definition. Invocations should set current_os to set the 61 # Shared toolchain definition. Invocations should set current_os to set the
62 # build args in this definition. 62 # build args in this definition.
63 template("mac_toolchain") { 63 template("mac_toolchain") {
64 toolchain(target_name) { 64 toolchain(target_name) {
65 env_wrapper = "export DEVELOPER_DIR=$hermetic_xcode_path; " # Note trailing space.
65 # When invoking this toolchain not as the default one, these args will be 66 # When invoking this toolchain not as the default one, these args will be
66 # passed to the build. They are ignored when this is the default toolchain. 67 # passed to the build. They are ignored when this is the default toolchain.
67 assert(defined(invoker.toolchain_args), 68 assert(defined(invoker.toolchain_args),
68 "Toolchains must declare toolchain_args") 69 "Toolchains must declare toolchain_args")
69 toolchain_args = { 70 toolchain_args = {
70 # Populate toolchain args from the invoker. 71 # Populate toolchain args from the invoker.
71 forward_variables_from(invoker.toolchain_args, "*") 72 forward_variables_from(invoker.toolchain_args, "*")
72 73
73 # The host toolchain value computed by the default toolchain's setup 74 # The host toolchain value computed by the default toolchain's setup
74 # needs to be passed through unchanged to all secondary toolchains to 75 # needs to be passed through unchanged to all secondary toolchains to
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 dsym_switch = "" 151 dsym_switch = ""
151 } 152 }
152 153
153 if (_save_unstripped_output) { 154 if (_save_unstripped_output) {
154 _unstripped_output = "{{root_out_dir}}/{{target_output_name}}{{output_exte nsion}}.unstripped" 155 _unstripped_output = "{{root_out_dir}}/{{target_output_name}}{{output_exte nsion}}.unstripped"
155 } 156 }
156 157
157 tool("cc") { 158 tool("cc") {
158 depfile = "{{output}}.d" 159 depfile = "{{output}}.d"
159 precompiled_header_type = "gcc" 160 precompiled_header_type = "gcc"
160 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" 161 command = "$env_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
161 depsformat = "gcc" 162 depsformat = "gcc"
162 description = "CC {{output}}" 163 description = "CC {{output}}"
163 outputs = [ 164 outputs = [
164 "$object_subdir/{{source_name_part}}.o", 165 "$object_subdir/{{source_name_part}}.o",
165 ] 166 ]
166 } 167 }
167 168
168 tool("cxx") { 169 tool("cxx") {
169 depfile = "{{output}}.d" 170 depfile = "{{output}}.d"
170 precompiled_header_type = "gcc" 171 precompiled_header_type = "gcc"
171 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" 172 command = "$env_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs} } {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
172 depsformat = "gcc" 173 depsformat = "gcc"
173 description = "CXX {{output}}" 174 description = "CXX {{output}}"
174 outputs = [ 175 outputs = [
175 "$object_subdir/{{source_name_part}}.o", 176 "$object_subdir/{{source_name_part}}.o",
176 ] 177 ]
177 } 178 }
178 179
179 tool("asm") { 180 tool("asm") {
180 # For GCC we can just use the C compiler to compile assembly. 181 # For GCC we can just use the C compiler to compile assembly.
181 depfile = "{{output}}.d" 182 depfile = "{{output}}.d"
182 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}" 183 command = "$env_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
183 depsformat = "gcc" 184 depsformat = "gcc"
184 description = "ASM {{output}}" 185 description = "ASM {{output}}"
185 outputs = [ 186 outputs = [
186 "$object_subdir/{{source_name_part}}.o", 187 "$object_subdir/{{source_name_part}}.o",
187 ] 188 ]
188 } 189 }
189 190
190 tool("objc") { 191 tool("objc") {
191 depfile = "{{output}}.d" 192 depfile = "{{output}}.d"
192 precompiled_header_type = "gcc" 193 precompiled_header_type = "gcc"
193 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_objc}} -c {{source}} -o {{output}}" 194 command = "$env_wrapper $cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}"
194 depsformat = "gcc" 195 depsformat = "gcc"
195 description = "OBJC {{output}}" 196 description = "OBJC {{output}}"
196 outputs = [ 197 outputs = [
197 "$object_subdir/{{source_name_part}}.o", 198 "$object_subdir/{{source_name_part}}.o",
198 ] 199 ]
199 } 200 }
200 201
201 tool("objcxx") { 202 tool("objcxx") {
202 depfile = "{{output}}.d" 203 depfile = "{{output}}.d"
203 precompiled_header_type = "gcc" 204 precompiled_header_type = "gcc"
204 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}" 205 command = "$env_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs} } {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}"
205 depsformat = "gcc" 206 depsformat = "gcc"
206 description = "OBJCXX {{output}}" 207 description = "OBJCXX {{output}}"
207 outputs = [ 208 outputs = [
208 "$object_subdir/{{source_name_part}}.o", 209 "$object_subdir/{{source_name_part}}.o",
209 ] 210 ]
210 } 211 }
211 212
212 tool("alink") { 213 tool("alink") {
213 script = 214 script =
214 rebase_path("//build/toolchain/mac/filter_libtool.py", root_build_dir) 215 rebase_path("//build/toolchain/mac/filter_libtool.py", root_build_dir)
215 command = "rm -f {{output}} && TOOL_VERSION=${tool_versions.filter_libtool } python $script libtool -static {{arflags}} -o {{output}} {{inputs}}" 216 command = "$env_wrapper rm -f {{output}} && TOOL_VERSION=${tool_versions.f ilter_libtool} python $script libtool -static {{arflags}} -o {{output}} {{inputs }}"
216 description = "LIBTOOL-STATIC {{output}}" 217 description = "LIBTOOL-STATIC {{output}}"
217 outputs = [ 218 outputs = [
218 "{{output_dir}}/{{target_output_name}}{{output_extension}}", 219 "{{output_dir}}/{{target_output_name}}{{output_extension}}",
219 ] 220 ]
220 default_output_dir = "{{target_out_dir}}" 221 default_output_dir = "{{target_out_dir}}"
221 default_output_extension = ".a" 222 default_output_extension = ".a"
222 output_prefix = "lib" 223 output_prefix = "lib"
223 } 224 }
224 225
225 tool("solink") { 226 tool("solink") {
226 dylib = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.dylib" 227 dylib = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.dylib"
227 rspfile = dylib + ".rsp" 228 rspfile = dylib + ".rsp"
228 pool = "//build/toolchain:link_pool($default_toolchain)" 229 pool = "//build/toolchain:link_pool($default_toolchain)"
229 230
230 # These variables are not built into GN but are helpers that implement 231 # These variables are not built into GN but are helpers that implement
231 # (1) linking to produce a .dylib, (2) extracting the symbols from that 232 # (1) linking to produce a .dylib, (2) extracting the symbols from that
232 # file to a temporary file, (3) if the temporary file has differences from 233 # file to a temporary file, (3) if the temporary file has differences from
233 # the existing .TOC file, overwrite it, otherwise, don't change it. 234 # the existing .TOC file, overwrite it, otherwise, don't change it.
234 # 235 #
235 # As a special case, if the library reexports symbols from other dynamic 236 # As a special case, if the library reexports symbols from other dynamic
236 # libraries, we always update the .TOC and skip the temporary file and 237 # libraries, we always update the .TOC and skip the temporary file and
237 # diffing steps, since that library always needs to be re-linked. 238 # diffing steps, since that library always needs to be re-linked.
238 tocname = dylib + ".TOC" 239 tocname = dylib + ".TOC"
239 temporary_tocname = dylib + ".tmp" 240 temporary_tocname = dylib + ".tmp"
240 241
241 does_reexport_command = "[ ! -e \"$dylib\" -o ! -e \"$tocname\" ] || otool -l \"$dylib\" | grep -q LC_REEXPORT_DYLIB" 242 does_reexport_command = "[ ! -e \"$dylib\" -o ! -e \"$tocname\" ] || otool -l \"$dylib\" | grep -q LC_REEXPORT_DYLIB"
242 243
243 link_command = "$linker_driver $ld -shared " 244 link_command = "$env_wrapper $linker_driver $ld -shared "
244 if (is_component_build) { 245 if (is_component_build) {
245 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out put_extension}}\" " 246 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out put_extension}}\" "
246 } 247 }
247 link_command += dsym_switch 248 link_command += dsym_switch
248 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li bs}} {{solibs}}" 249 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li bs}} {{solibs}}"
249 250
250 replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then m v \"$temporary_tocname\" \"$tocname\"" 251 replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then m v \"$temporary_tocname\" \"$tocname\""
251 extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm - gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" 252 extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm - gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }"
252 253
253 command = "if $does_reexport_command ; then $link_command && $extract_toc_ command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporar y_tocname\" && $replace_command ; fi; fi" 254 command = "if $does_reexport_command ; then $link_command && $extract_toc_ command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporar y_tocname\" && $replace_command ; fi; fi"
(...skipping 30 matching lines...) Expand all
284 if (_save_unstripped_output) { 285 if (_save_unstripped_output) {
285 outputs += [ _unstripped_output ] 286 outputs += [ _unstripped_output ]
286 } 287 }
287 } 288 }
288 289
289 tool("solink_module") { 290 tool("solink_module") {
290 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.so" 291 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.so"
291 rspfile = sofile + ".rsp" 292 rspfile = sofile + ".rsp"
292 pool = "//build/toolchain:link_pool($default_toolchain)" 293 pool = "//build/toolchain:link_pool($default_toolchain)"
293 294
294 link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl, -filelist,\"$rspfile\"" 295 link_command = "$env_wrapper $linker_driver $ld -bundle {{ldflags}} -o \"$ sofile\" -Wl,-filelist,\"$rspfile\""
295 if (is_component_build) { 296 if (is_component_build) {
296 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu t_extension}}" 297 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu t_extension}}"
297 } 298 }
298 link_command += dsym_switch 299 link_command += dsym_switch
299 link_command += " {{solibs}} {{libs}}" 300 link_command += " {{solibs}} {{libs}}"
300 command = link_command 301 command = link_command
301 302
302 rspfile_content = "{{inputs_newline}}" 303 rspfile_content = "{{inputs_newline}}"
303 304
304 description = "SOLINK_MODULE {{output}}" 305 description = "SOLINK_MODULE {{output}}"
(...skipping 22 matching lines...) Expand all
327 pool = "//build/toolchain:link_pool($default_toolchain)" 328 pool = "//build/toolchain:link_pool($default_toolchain)"
328 329
329 # Note about --filelist: Apple's linker reads the file list file and 330 # Note about --filelist: Apple's linker reads the file list file and
330 # interprets each newline-separated chunk of text as a file name. It 331 # interprets each newline-separated chunk of text as a file name. It
331 # doesn't do the things one would expect from the shell like unescaping 332 # doesn't do the things one would expect from the shell like unescaping
332 # or handling quotes. In contrast, when Ninja finds a file name with 333 # or handling quotes. In contrast, when Ninja finds a file name with
333 # spaces, it single-quotes them in $inputs_newline as it would normally 334 # spaces, it single-quotes them in $inputs_newline as it would normally
334 # do for command-line arguments. Thus any source names with spaces, or 335 # do for command-line arguments. Thus any source names with spaces, or
335 # label names with spaces (which GN bases the output paths on) will be 336 # label names with spaces (which GN bases the output paths on) will be
336 # corrupted by this process. Don't use spaces for source files or labels. 337 # corrupted by this process. Don't use spaces for source files or labels.
337 command = "$linker_driver $ld $dsym_switch {{ldflags}} -o \"$outfile\" -Wl ,-filelist,\"$rspfile\" {{solibs}} {{libs}}" 338 command = "$env_wrapper $linker_driver $ld $dsym_switch {{ldflags}} -o \"$ outfile\" -Wl,-filelist,\"$rspfile\" {{solibs}} {{libs}}"
338 description = "LINK $outfile" 339 description = "LINK $outfile"
339 rspfile_content = "{{inputs_newline}}" 340 rspfile_content = "{{inputs_newline}}"
340 outputs = [ 341 outputs = [
341 outfile, 342 outfile,
342 ] 343 ]
343 344
344 if (_enable_dsyms) { 345 if (_enable_dsyms) {
345 outputs += dsym_output 346 outputs += dsym_output
346 } 347 }
347 if (_save_unstripped_output) { 348 if (_save_unstripped_output) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 tool("compile_xcassets") { 394 tool("compile_xcassets") {
394 _tool = rebase_path("//build/toolchain/mac/compile_xcassets.py", 395 _tool = rebase_path("//build/toolchain/mac/compile_xcassets.py",
395 root_build_dir) 396 root_build_dir)
396 if (is_ios) { 397 if (is_ios) {
397 _sdk_name = ios_sdk_name 398 _sdk_name = ios_sdk_name
398 _min_deployment_target = ios_deployment_target 399 _min_deployment_target = ios_deployment_target
399 } else { 400 } else {
400 _sdk_name = mac_sdk_name 401 _sdk_name = mac_sdk_name
401 _min_deployment_target = mac_deployment_target 402 _min_deployment_target = mac_deployment_target
402 } 403 }
403 command = "rm -f {{output}} && " + 404 command = "$env_wrapper rm -f {{output}} && " +
404 "TOOL_VERSION=${tool_versions.compile_xcassets} " + 405 "TOOL_VERSION=${tool_versions.compile_xcassets} " +
405 "python $_tool -p $_sdk_name -t $_min_deployment_target " + 406 "python $_tool -p $_sdk_name -t $_min_deployment_target " +
406 "-T {{bundle_product_type}} -o {{output}} {{inputs}}" 407 "-T {{bundle_product_type}} -o {{output}} {{inputs}}"
407 408
408 description = "COMPILE_XCASSETS {{output}}" 409 description = "COMPILE_XCASSETS {{output}}"
409 pool = ":bundle_pool($default_toolchain)" 410 pool = ":bundle_pool($default_toolchain)"
410 } 411 }
411 } 412 }
412 } 413 }
413 414
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 448 }
448 } 449 }
449 450
450 mac_toolchain("ios_clang_x64") { 451 mac_toolchain("ios_clang_x64") {
451 toolchain_args = { 452 toolchain_args = {
452 current_cpu = "x64" 453 current_cpu = "x64"
453 current_os = "ios" 454 current_os = "ios"
454 } 455 }
455 } 456 }
456 } 457 }
OLDNEW
« no previous file with comments | « build/secondary/third_party/crashpad/crashpad/util/BUILD.gn ('k') | build/toolchain/toolchain.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698