| 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 import("//build/config/nacl/config.gni") | 5 import("//build/config/nacl/config.gni") |
| 6 import("//build/config/sanitizers/sanitizers.gni") | 6 import("//build/config/sanitizers/sanitizers.gni") |
| 7 import("//build/toolchain/cc_wrapper.gni") | 7 import("//build/toolchain/cc_wrapper.gni") |
| 8 import("//build/toolchain/goma.gni") | 8 import("//build/toolchain/goma.gni") |
| 9 import("//build/toolchain/toolchain.gni") | 9 import("//build/toolchain/toolchain.gni") |
| 10 | 10 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 # This needs a Python script to avoid using simple sh features in this | 228 # This needs a Python script to avoid using simple sh features in this |
| 229 # command, in case the host does not use a POSIX shell (e.g. compiling | 229 # command, in case the host does not use a POSIX shell (e.g. compiling |
| 230 # POSIX-like toolchains such as NaCl on Windows). | 230 # POSIX-like toolchains such as NaCl on Windows). |
| 231 ar_wrapper = | 231 ar_wrapper = |
| 232 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) | 232 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) |
| 233 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" $
arflags rcsD @\"$rspfile\"" | 233 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" $
arflags rcsD @\"$rspfile\"" |
| 234 description = "AR {{output}}" | 234 description = "AR {{output}}" |
| 235 rspfile_content = "{{inputs}}" | 235 rspfile_content = "{{inputs}}" |
| 236 outputs = [ | 236 outputs = [ |
| 237 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", | 237 "{{output_dir}}/{{target_output_name}}{{output_extension}}", |
| 238 ] | 238 ] |
| 239 |
| 240 # Shared libraries go in the target out directory by default so we can |
| 241 # generate different targets with the same name and not have them collide. |
| 242 default_output_dir = "{{target_out_dir}}" |
| 239 default_output_extension = ".a" | 243 default_output_extension = ".a" |
| 240 output_prefix = "lib" | 244 output_prefix = "lib" |
| 241 } | 245 } |
| 242 | 246 |
| 243 tool("solink") { | 247 tool("solink") { |
| 244 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 248 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
| 245 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. | 249 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. |
| 246 if (shlib_subdir != ".") { | |
| 247 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" | |
| 248 } | |
| 249 rspfile = sofile + ".rsp" | 250 rspfile = sofile + ".rsp" |
| 250 | 251 |
| 251 unstripped_sofile = sofile | |
| 252 if (defined(invoker.strip)) { | 252 if (defined(invoker.strip)) { |
| 253 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 253 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
| 254 } else { |
| 255 unstripped_sofile = sofile |
| 254 } | 256 } |
| 255 | 257 |
| 256 # These variables are not built into GN but are helpers that | 258 # These variables are not built into GN but are helpers that |
| 257 # implement (1) linking to produce a .so, (2) extracting the symbols | 259 # implement (1) linking to produce a .so, (2) extracting the symbols |
| 258 # from that file (3) if the extracted list differs from the existing | 260 # from that file (3) if the extracted list differs from the existing |
| 259 # .TOC file, overwrite it, otherwise, don't change it. | 261 # .TOC file, overwrite it, otherwise, don't change it. |
| 260 tocfile = sofile + ".TOC" | 262 tocfile = sofile + ".TOC" |
| 261 | 263 |
| 262 link_command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-son
ame=\"$soname\" @\"$rspfile\"" | 264 link_command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-son
ame=\"$soname\" @\"$rspfile\"" |
| 263 | 265 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 276 | 278 |
| 277 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 279 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
| 278 | 280 |
| 279 description = "SOLINK $sofile" | 281 description = "SOLINK $sofile" |
| 280 | 282 |
| 281 # Use this for {{output_extension}} expansions unless a target manually | 283 # Use this for {{output_extension}} expansions unless a target manually |
| 282 # overrides it (in which case {{output_extension}} will be what the target | 284 # overrides it (in which case {{output_extension}} will be what the target |
| 283 # specifies). | 285 # specifies). |
| 284 default_output_extension = default_shlib_extension | 286 default_output_extension = default_shlib_extension |
| 285 | 287 |
| 288 default_output_dir = "{{root_out_dir}}" |
| 289 if (shlib_subdir != ".") { |
| 290 default_output_dir += "/$shlib_subdir" |
| 291 } |
| 292 |
| 286 output_prefix = "lib" | 293 output_prefix = "lib" |
| 287 | 294 |
| 288 # Since the above commands only updates the .TOC file when it changes, ask | 295 # Since the above commands only updates the .TOC file when it changes, ask |
| 289 # Ninja to check if the timestamp actually changed to know if downstream | 296 # Ninja to check if the timestamp actually changed to know if downstream |
| 290 # dependencies should be recompiled. | 297 # dependencies should be recompiled. |
| 291 restat = true | 298 restat = true |
| 292 | 299 |
| 293 # Tell GN about the output files. It will link to the sofile but use the | 300 # Tell GN about the output files. It will link to the sofile but use the |
| 294 # tocfile for dependency management. | 301 # tocfile for dependency management. |
| 295 outputs = [ | 302 outputs = [ |
| 296 sofile, | 303 sofile, |
| 297 tocfile, | 304 tocfile, |
| 298 ] | 305 ] |
| 299 if (sofile != unstripped_sofile) { | 306 if (sofile != unstripped_sofile) { |
| 300 outputs += [ unstripped_sofile ] | 307 outputs += [ unstripped_sofile ] |
| 301 } | 308 } |
| 302 link_output = sofile | 309 link_output = sofile |
| 303 depend_output = tocfile | 310 depend_output = tocfile |
| 304 } | 311 } |
| 305 | 312 |
| 306 tool("solink_module") { | 313 tool("solink_module") { |
| 307 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 314 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
| 308 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. | 315 sofile = "{{output_dir}}/$soname" |
| 309 if (shlib_subdir != ".") { | |
| 310 sofile = "{{root_out_dir}}/$shlib_subdir/$soname" | |
| 311 } | |
| 312 rspfile = sofile + ".rsp" | 316 rspfile = sofile + ".rsp" |
| 313 | 317 |
| 314 unstripped_sofile = sofile | |
| 315 if (defined(invoker.strip)) { | 318 if (defined(invoker.strip)) { |
| 316 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" | 319 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" |
| 320 } else { |
| 321 unstripped_sofile = sofile |
| 317 } | 322 } |
| 318 | 323 |
| 319 command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-soname=\
"$soname\" @\"$rspfile\"" | 324 command = "$ld -shared {{ldflags}} -o \"$unstripped_sofile\" -Wl,-soname=\
"$soname\" @\"$rspfile\"" |
| 320 | 325 |
| 321 if (defined(invoker.strip)) { | 326 if (defined(invoker.strip)) { |
| 322 strip_command = "${invoker.strip} --strip-unneeded -o \"$sofile\" \"$uns
tripped_sofile\"" | 327 strip_command = "${invoker.strip} --strip-unneeded -o \"$sofile\" \"$uns
tripped_sofile\"" |
| 323 command += " && " + strip_command | 328 command += " && " + strip_command |
| 324 } | 329 } |
| 325 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 330 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
| 326 | 331 |
| 327 description = "SOLINK_MODULE $sofile" | 332 description = "SOLINK_MODULE $sofile" |
| 328 | 333 |
| 329 # Use this for {{output_extension}} expansions unless a target manually | 334 # Use this for {{output_extension}} expansions unless a target manually |
| 330 # overrides it (in which case {{output_extension}} will be what the target | 335 # overrides it (in which case {{output_extension}} will be what the target |
| 331 # specifies). | 336 # specifies). |
| 332 if (defined(invoker.loadable_module_extension)) { | 337 if (defined(invoker.loadable_module_extension)) { |
| 333 default_output_extension = invoker.loadable_module_extension | 338 default_output_extension = invoker.loadable_module_extension |
| 334 } else { | 339 } else { |
| 335 default_output_extension = default_shlib_extension | 340 default_output_extension = default_shlib_extension |
| 336 } | 341 } |
| 337 | 342 |
| 343 default_output_dir = "{{root_out_dir}}" |
| 344 if (shlib_subdir != ".") { |
| 345 default_output_dir += "/$shlib_subdir" |
| 346 } |
| 347 |
| 338 output_prefix = "lib" | 348 output_prefix = "lib" |
| 339 | 349 |
| 340 outputs = [ | 350 outputs = [ |
| 341 sofile, | 351 sofile, |
| 342 ] | 352 ] |
| 343 if (sofile != unstripped_sofile) { | 353 if (sofile != unstripped_sofile) { |
| 344 outputs += [ unstripped_sofile ] | 354 outputs += [ unstripped_sofile ] |
| 345 } | 355 } |
| 346 } | 356 } |
| 347 | 357 |
| 348 tool("link") { | 358 tool("link") { |
| 349 exename = "{{target_output_name}}{{output_extension}}" | 359 exename = "{{target_output_name}}{{output_extension}}" |
| 350 outfile = "{{root_out_dir}}/$exename" | 360 outfile = "{{output_dir}}/$exename" |
| 351 rspfile = "$outfile.rsp" | 361 rspfile = "$outfile.rsp" |
| 352 unstripped_outfile = outfile | 362 unstripped_outfile = outfile |
| 353 | 363 |
| 354 # Use this for {{output_extension}} expansions unless a target manually | 364 # Use this for {{output_extension}} expansions unless a target manually |
| 355 # overrides it (in which case {{output_extension}} will be what the target | 365 # overrides it (in which case {{output_extension}} will be what the target |
| 356 # specifies). | 366 # specifies). |
| 357 default_output_extension = default_executable_extension | 367 default_output_extension = default_executable_extension |
| 358 | 368 |
| 369 default_output_dir = "{{root_out_dir}}" |
| 370 |
| 359 if (defined(invoker.strip)) { | 371 if (defined(invoker.strip)) { |
| 360 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" | 372 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" |
| 361 } | 373 } |
| 362 | 374 |
| 363 command = "$ld {{ldflags}} -o \"$unstripped_outfile\" -Wl,--start-group @\
"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_secti
on_postfix" | 375 command = "$ld {{ldflags}} -o \"$unstripped_outfile\" -Wl,--start-group @\
"$rspfile\" {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_secti
on_postfix" |
| 364 if (defined(invoker.strip)) { | 376 if (defined(invoker.strip)) { |
| 365 link_wrapper = | 377 link_wrapper = |
| 366 rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir) | 378 rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir) |
| 367 command = "$python_path \"$link_wrapper\" --strip=\"${invoker.strip}\" -
-unstripped-file=\"$unstripped_outfile\" --output=\"$outfile\" -- $command" | 379 command = "$python_path \"$link_wrapper\" --strip=\"${invoker.strip}\" -
-unstripped-file=\"$unstripped_outfile\" --output=\"$outfile\" -- $command" |
| 368 } | 380 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 nm = "${toolprefix}nm" | 471 nm = "${toolprefix}nm" |
| 460 | 472 |
| 461 forward_variables_from(invoker, | 473 forward_variables_from(invoker, |
| 462 [ | 474 [ |
| 463 "toolchain_cpu", | 475 "toolchain_cpu", |
| 464 "toolchain_os", | 476 "toolchain_os", |
| 465 "use_gold", | 477 "use_gold", |
| 466 ]) | 478 ]) |
| 467 } | 479 } |
| 468 } | 480 } |
| OLD | NEW |