| OLD | NEW |
| 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 Loading... |
| 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 if (use_system_xcode) { |
| 66 env_wrapper = "" |
| 67 } else { |
| 68 env_wrapper = "export DEVELOPER_DIR=$hermetic_xcode_path; " |
| 69 } |
| 70 |
| 65 # When invoking this toolchain not as the default one, these args will be | 71 # 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. | 72 # passed to the build. They are ignored when this is the default toolchain. |
| 67 assert(defined(invoker.toolchain_args), | 73 assert(defined(invoker.toolchain_args), |
| 68 "Toolchains must declare toolchain_args") | 74 "Toolchains must declare toolchain_args") |
| 69 toolchain_args = { | 75 toolchain_args = { |
| 70 # Populate toolchain args from the invoker. | 76 # Populate toolchain args from the invoker. |
| 71 forward_variables_from(invoker.toolchain_args, "*") | 77 forward_variables_from(invoker.toolchain_args, "*") |
| 72 | 78 |
| 73 # The host toolchain value computed by the default toolchain's setup | 79 # The host toolchain value computed by the default toolchain's setup |
| 74 # needs to be passed through unchanged to all secondary toolchains to | 80 # needs to be passed through unchanged to all secondary toolchains to |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 depsformat = "gcc" | 211 depsformat = "gcc" |
| 206 description = "OBJCXX {{output}}" | 212 description = "OBJCXX {{output}}" |
| 207 outputs = [ | 213 outputs = [ |
| 208 "$object_subdir/{{source_name_part}}.o", | 214 "$object_subdir/{{source_name_part}}.o", |
| 209 ] | 215 ] |
| 210 } | 216 } |
| 211 | 217 |
| 212 tool("alink") { | 218 tool("alink") { |
| 213 script = | 219 script = |
| 214 rebase_path("//build/toolchain/mac/filter_libtool.py", root_build_dir) | 220 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}}" | 221 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}}" | 222 description = "LIBTOOL-STATIC {{output}}" |
| 217 outputs = [ | 223 outputs = [ |
| 218 "{{output_dir}}/{{target_output_name}}{{output_extension}}", | 224 "{{output_dir}}/{{target_output_name}}{{output_extension}}", |
| 219 ] | 225 ] |
| 220 default_output_dir = "{{target_out_dir}}" | 226 default_output_dir = "{{target_out_dir}}" |
| 221 default_output_extension = ".a" | 227 default_output_extension = ".a" |
| 222 output_prefix = "lib" | 228 output_prefix = "lib" |
| 223 } | 229 } |
| 224 | 230 |
| 225 tool("solink") { | 231 tool("solink") { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 243 link_command = "$linker_driver $ld -shared " | 249 link_command = "$linker_driver $ld -shared " |
| 244 if (is_component_build) { | 250 if (is_component_build) { |
| 245 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out
put_extension}}\" " | 251 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out
put_extension}}\" " |
| 246 } | 252 } |
| 247 link_command += dsym_switch | 253 link_command += dsym_switch |
| 248 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li
bs}} {{solibs}}" | 254 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li
bs}} {{solibs}}" |
| 249 | 255 |
| 250 replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then m
v \"$temporary_tocname\" \"$tocname\"" | 256 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; }" | 257 extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm -
gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" |
| 252 | 258 |
| 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" | 259 command = "$env_wrapper if $does_reexport_command ; then $link_command &&
$extract_toc_command > \"$tocname\"; else $link_command && $extract_toc_command
> \"$temporary_tocname\" && $replace_command ; fi; fi" |
| 254 | 260 |
| 255 rspfile_content = "{{inputs_newline}}" | 261 rspfile_content = "{{inputs_newline}}" |
| 256 | 262 |
| 257 description = "SOLINK {{output}}" | 263 description = "SOLINK {{output}}" |
| 258 | 264 |
| 259 # Use this for {{output_extension}} expansions unless a target manually | 265 # Use this for {{output_extension}} expansions unless a target manually |
| 260 # overrides it (in which case {{output_extension}} will be what the target | 266 # overrides it (in which case {{output_extension}} will be what the target |
| 261 # specifies). | 267 # specifies). |
| 262 default_output_dir = "{{root_out_dir}}" | 268 default_output_dir = "{{root_out_dir}}" |
| 263 default_output_extension = ".dylib" | 269 default_output_extension = ".dylib" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 284 if (_save_unstripped_output) { | 290 if (_save_unstripped_output) { |
| 285 outputs += [ _unstripped_output ] | 291 outputs += [ _unstripped_output ] |
| 286 } | 292 } |
| 287 } | 293 } |
| 288 | 294 |
| 289 tool("solink_module") { | 295 tool("solink_module") { |
| 290 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg
"./libfoo.so" | 296 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg
"./libfoo.so" |
| 291 rspfile = sofile + ".rsp" | 297 rspfile = sofile + ".rsp" |
| 292 pool = "//build/toolchain:link_pool($default_toolchain)" | 298 pool = "//build/toolchain:link_pool($default_toolchain)" |
| 293 | 299 |
| 294 link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl,
-filelist,\"$rspfile\"" | 300 link_command = "$env_wrapper $linker_driver $ld -bundle {{ldflags}} -o \"$
sofile\" -Wl,-filelist,\"$rspfile\"" |
| 295 if (is_component_build) { | 301 if (is_component_build) { |
| 296 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu
t_extension}}" | 302 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu
t_extension}}" |
| 297 } | 303 } |
| 298 link_command += dsym_switch | 304 link_command += dsym_switch |
| 299 link_command += " {{solibs}} {{libs}}" | 305 link_command += " {{solibs}} {{libs}}" |
| 300 command = link_command | 306 command = link_command |
| 301 | 307 |
| 302 rspfile_content = "{{inputs_newline}}" | 308 rspfile_content = "{{inputs_newline}}" |
| 303 | 309 |
| 304 description = "SOLINK_MODULE {{output}}" | 310 description = "SOLINK_MODULE {{output}}" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 327 pool = "//build/toolchain:link_pool($default_toolchain)" | 333 pool = "//build/toolchain:link_pool($default_toolchain)" |
| 328 | 334 |
| 329 # Note about --filelist: Apple's linker reads the file list file and | 335 # 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 | 336 # 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 | 337 # 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 | 338 # 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 | 339 # 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 | 340 # 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 | 341 # 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. | 342 # 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}}" | 343 command = "$env_wrapper $linker_driver $ld $dsym_switch {{ldflags}} -o \"$
outfile\" -Wl,-filelist,\"$rspfile\" {{solibs}} {{libs}}" |
| 338 description = "LINK $outfile" | 344 description = "LINK $outfile" |
| 339 rspfile_content = "{{inputs_newline}}" | 345 rspfile_content = "{{inputs_newline}}" |
| 340 outputs = [ | 346 outputs = [ |
| 341 outfile, | 347 outfile, |
| 342 ] | 348 ] |
| 343 | 349 |
| 344 if (_enable_dsyms) { | 350 if (_enable_dsyms) { |
| 345 outputs += dsym_output | 351 outputs += dsym_output |
| 346 } | 352 } |
| 347 if (_save_unstripped_output) { | 353 if (_save_unstripped_output) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 tool("compile_xcassets") { | 399 tool("compile_xcassets") { |
| 394 _tool = rebase_path("//build/toolchain/mac/compile_xcassets.py", | 400 _tool = rebase_path("//build/toolchain/mac/compile_xcassets.py", |
| 395 root_build_dir) | 401 root_build_dir) |
| 396 if (is_ios) { | 402 if (is_ios) { |
| 397 _sdk_name = ios_sdk_name | 403 _sdk_name = ios_sdk_name |
| 398 _min_deployment_target = ios_deployment_target | 404 _min_deployment_target = ios_deployment_target |
| 399 } else { | 405 } else { |
| 400 _sdk_name = mac_sdk_name | 406 _sdk_name = mac_sdk_name |
| 401 _min_deployment_target = mac_deployment_target | 407 _min_deployment_target = mac_deployment_target |
| 402 } | 408 } |
| 403 command = "rm -f {{output}} && " + | 409 command = "$env_wrapper rm -f {{output}} && " + |
| 404 "TOOL_VERSION=${tool_versions.compile_xcassets} " + | 410 "TOOL_VERSION=${tool_versions.compile_xcassets} " + |
| 405 "python $_tool -p $_sdk_name -t $_min_deployment_target " + | 411 "python $_tool -p $_sdk_name -t $_min_deployment_target " + |
| 406 "-T {{bundle_product_type}} -o {{output}} {{inputs}}" | 412 "-T {{bundle_product_type}} -o {{output}} {{inputs}}" |
| 407 | 413 |
| 408 description = "COMPILE_XCASSETS {{output}}" | 414 description = "COMPILE_XCASSETS {{output}}" |
| 409 pool = ":bundle_pool($default_toolchain)" | 415 pool = ":bundle_pool($default_toolchain)" |
| 410 } | 416 } |
| 411 } | 417 } |
| 412 } | 418 } |
| 413 | 419 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 453 } |
| 448 } | 454 } |
| 449 | 455 |
| 450 mac_toolchain("ios_clang_x64") { | 456 mac_toolchain("ios_clang_x64") { |
| 451 toolchain_args = { | 457 toolchain_args = { |
| 452 current_cpu = "x64" | 458 current_cpu = "x64" |
| 453 current_os = "ios" | 459 current_os = "ios" |
| 454 } | 460 } |
| 455 } | 461 } |
| 456 } | 462 } |
| OLD | NEW |