Chromium Code Reviews| 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/toolchain/toolchain.gni") | |
| 6 | |
| 5 # This value will be inherited in the toolchain below. | 7 # This value will be inherited in the toolchain below. |
| 6 concurrent_links = exec_script("get_concurrent_links.py", [], "value") | 8 concurrent_links = exec_script("get_concurrent_links.py", [], "value") |
| 7 | 9 |
| 8 # This template defines a toolchain for something that works like gcc | 10 # This template defines a toolchain for something that works like gcc |
| 9 # (including clang). | 11 # (including clang). |
| 10 # | 12 # |
| 11 # It requires the following variables specifying the executables to run: | 13 # It requires the following variables specifying the executables to run: |
| 12 # - cc | 14 # - cc |
| 13 # - cxx | 15 # - cxx |
| 14 # - ar | 16 # - ar |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 rspfile_content = "{{inputs}}" | 129 rspfile_content = "{{inputs}}" |
| 128 outputs = [ | 130 outputs = [ |
| 129 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", | 131 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 130 ] | 132 ] |
| 131 default_output_extension = ".a" | 133 default_output_extension = ".a" |
| 132 output_prefix = "lib" | 134 output_prefix = "lib" |
| 133 } | 135 } |
| 134 | 136 |
| 135 tool("solink") { | 137 tool("solink") { |
| 136 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 138 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
| 137 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. | 139 sofile = "{{root_out_dir}}/lib/$soname" # Possibly including toolchain di r. |
|
brettw
2015/07/30 23:17:46
Should this be $shlib_subdir ?
agrieve
2015/07/31 02:09:24
No - so added a comment. Problem is that on Androi
brettw
2015/07/31 03:59:19
Ah, thanks
| |
| 138 rspfile = sofile + ".rsp" | 140 rspfile = sofile + ".rsp" |
| 139 | 141 |
| 140 # These variables are not built into GN but are helpers that implement | 142 # These variables are not built into GN but are helpers that implement |
| 141 # (1) linking to produce a .so, (2) extracting the symbols from that file | 143 # (1) linking to produce a .so, (2) extracting the symbols from that file |
| 142 # to a temporary file, (3) if the temporary file has differences from the | 144 # to a temporary file, (3) if the temporary file has differences from the |
| 143 # existing .TOC file, overwrite it, otherwise, don't change it. | 145 # existing .TOC file, overwrite it, otherwise, don't change it. |
| 144 tocfile = sofile + ".TOC" | 146 tocfile = sofile + ".TOC" |
| 145 temporary_tocname = sofile + ".tmp" | 147 temporary_tocname = sofile + ".tmp" |
| 146 link_command = | 148 link_command = |
| 147 "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile" | 149 "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile" |
| 148 toc_command = "{ $readelf -d $sofile | grep SONAME ; $nm -gD -f p $sofile | cut -f1-2 -d' '; } > $temporary_tocname" | 150 toc_command = "{ $readelf -d $sofile | grep SONAME ; $nm -gD -f p $sofile | cut -f1-2 -d' '; } > $temporary_tocname" |
| 149 replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $tempo rary_tocname $tocfile; fi" | 151 replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $tempo rary_tocname $tocfile; fi" |
| 150 | 152 |
| 151 command = "$link_command && $toc_command && $replace_command" | 153 command = "$link_command && $toc_command && $replace_command" |
| 152 if (defined(invoker.postsolink)) { | 154 if (defined(invoker.postsolink)) { |
| 153 command += " && " + invoker.postsolink | 155 command += " && " + invoker.postsolink |
| 154 } | 156 } |
| 155 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 157 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
| 156 | 158 |
| 157 description = "SOLINK $sofile" | 159 description = "SOLINK $sofile" |
| 158 | 160 |
| 159 # Use this for {{output_extension}} expansions unless a target manually | 161 # Use this for {{output_extension}} expansions unless a target manually |
| 160 # overrides it (in which case {{output_extension}} will be what the target | 162 # overrides it (in which case {{output_extension}} will be what the target |
| 161 # specifies). | 163 # specifies). |
| 162 default_output_extension = ".so" | 164 default_output_extension = shlib_extension |
| 163 if (defined(invoker.default_output_extension)) { | 165 if (defined(invoker.default_output_extension)) { |
| 164 default_output_extension = invoker.default_output_extension | 166 default_output_extension = invoker.default_output_extension |
| 165 } | 167 } |
| 166 | 168 |
| 167 output_prefix = "lib" | 169 output_prefix = "lib" |
| 168 | 170 |
| 169 # Since the above commands only updates the .TOC file when it changes, ask | 171 # Since the above commands only updates the .TOC file when it changes, ask |
| 170 # Ninja to check if the timestamp actually changed to know if downstream | 172 # Ninja to check if the timestamp actually changed to know if downstream |
| 171 # dependencies should be recompiled. | 173 # dependencies should be recompiled. |
| 172 restat = true | 174 restat = true |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 if (defined(invoker.is_clang)) { | 226 if (defined(invoker.is_clang)) { |
| 225 is_clang = invoker.is_clang | 227 is_clang = invoker.is_clang |
| 226 } | 228 } |
| 227 } | 229 } |
| 228 | 230 |
| 229 if (defined(invoker.deps)) { | 231 if (defined(invoker.deps)) { |
| 230 deps = invoker.deps | 232 deps = invoker.deps |
| 231 } | 233 } |
| 232 } | 234 } |
| 233 } | 235 } |
| OLD | NEW |