| 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 # This template defines a toolchain for something that works like gcc | 5 # This template defines a toolchain for something that works like gcc |
| 6 # (including clang). | 6 # (including clang). |
| 7 # | 7 # |
| 8 # It requires the following variables specifying the executables to run: | 8 # It requires the following variables specifying the executables to run: |
| 9 # - cc | 9 # - cc |
| 10 # - cxx | 10 # - cxx |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 rspfile_content = "{{inputs}}" | 117 rspfile_content = "{{inputs}}" |
| 118 outputs = [ | 118 outputs = [ |
| 119 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" | 119 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 120 ] | 120 ] |
| 121 default_output_extension = ".a" | 121 default_output_extension = ".a" |
| 122 output_prefix = "lib" | 122 output_prefix = "lib" |
| 123 } | 123 } |
| 124 | 124 |
| 125 tool("solink") { | 125 tool("solink") { |
| 126 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 126 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
| 127 rspfile = soname + ".rsp" | 127 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. |
| 128 rspfile = sofile + ".rsp" |
| 128 | 129 |
| 129 # These variables are not built into GN but are helpers that implement | 130 # These variables are not built into GN but are helpers that implement |
| 130 # (1) linking to produce a .so, (2) extracting the symbols from that file | 131 # (1) linking to produce a .so, (2) extracting the symbols from that file |
| 131 # to a temporary file, (3) if the temporary file has differences from the | 132 # to a temporary file, (3) if the temporary file has differences from the |
| 132 # existing .TOC file, overwrite it, otherwise, don't change it. | 133 # existing .TOC file, overwrite it, otherwise, don't change it. |
| 133 tocname = soname + ".TOC" | 134 tocfile = sofile + ".TOC" |
| 134 temporary_tocname = soname + ".tmp" | 135 temporary_tocname = sofile + ".tmp" |
| 135 link_command = "$ld -shared {{ldflags}} -o $soname -Wl,-soname=$soname @$r
spfile" | 136 link_command = "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$r
spfile" |
| 136 toc_command = "{ readelf -d $soname | grep SONAME ; nm -gD -f p $soname |
cut -f1-2 -d' '; } > $temporary_tocname" | 137 toc_command = "{ readelf -d $sofile | grep SONAME ; nm -gD -f p $soname |
cut -f1-2 -d' '; } > $temporary_tocname" |
| 137 replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $tempo
rary_tocname $tocname; fi" | 138 replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $tempo
rary_tocname $tocfile; fi" |
| 138 | 139 |
| 139 command = "$link_command && $toc_command && $replace_command" | 140 command = "$link_command && $toc_command && $replace_command" |
| 140 if (defined(invoker.postsolink)) { | 141 if (defined(invoker.postsolink)) { |
| 141 command += " && " + invoker.postsolink | 142 command += " && " + invoker.postsolink |
| 142 } | 143 } |
| 143 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | 144 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
| 144 | 145 |
| 145 description = "SOLINK $soname" | 146 description = "SOLINK $sofile" |
| 146 | 147 |
| 147 # Use this for {{output_extension}} expansions unless a target manually | 148 # Use this for {{output_extension}} expansions unless a target manually |
| 148 # overrides it (in which case {{output_extension}} will be what the target | 149 # overrides it (in which case {{output_extension}} will be what the target |
| 149 # specifies). | 150 # specifies). |
| 150 default_output_extension = ".so" | 151 default_output_extension = ".so" |
| 151 | 152 |
| 152 output_prefix = "lib" | 153 output_prefix = "lib" |
| 153 | 154 |
| 154 # Since the above commands only updates the .TOC file when it changes, ask | 155 # Since the above commands only updates the .TOC file when it changes, ask |
| 155 # Ninja to check if the timestamp actually changed to know if downstream | 156 # Ninja to check if the timestamp actually changed to know if downstream |
| 156 # dependencies should be recompiled. | 157 # dependencies should be recompiled. |
| 157 restat = true | 158 restat = true |
| 158 | 159 |
| 159 # Tell GN about the output files. It will link to the soname but use the | 160 # Tell GN about the output files. It will link to the sofile but use the |
| 160 # tocname for dependency management. | 161 # tocfile for dependency management. |
| 161 outputs = [ | 162 outputs = [ |
| 162 soname, | 163 sofile, |
| 163 tocname, | 164 tocfile, |
| 164 ] | 165 ] |
| 165 link_output = soname | 166 link_output = sofile |
| 166 depend_output = tocname | 167 depend_output = tocfile |
| 167 } | 168 } |
| 168 | 169 |
| 169 tool("link") { | 170 tool("link") { |
| 170 outfile = "{{target_output_name}}{{output_extension}}" | 171 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 171 rspfile = "$outfile.rsp" | 172 rspfile = "$outfile.rsp" |
| 172 command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solib
s}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" | 173 command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solib
s}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" |
| 173 description = "LINK $outfile" | 174 description = "LINK $outfile" |
| 174 rspfile_content = "{{inputs}}" | 175 rspfile_content = "{{inputs}}" |
| 175 outputs = [ outfile ] | 176 outputs = [ outfile ] |
| 176 } | 177 } |
| 177 | 178 |
| 178 tool("stamp") { | 179 tool("stamp") { |
| 179 command = "touch {{output}}" | 180 command = "touch {{output}}" |
| 180 description = "STAMP {{output}}" | 181 description = "STAMP {{output}}" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 193 if (defined(invoker.is_clang)) { | 194 if (defined(invoker.is_clang)) { |
| 194 is_clang = invoker.is_clang | 195 is_clang = invoker.is_clang |
| 195 } | 196 } |
| 196 } | 197 } |
| 197 | 198 |
| 198 if (defined(invoker.deps)) { | 199 if (defined(invoker.deps)) { |
| 199 deps = invoker.deps | 200 deps = invoker.deps |
| 200 } | 201 } |
| 201 } | 202 } |
| 202 } | 203 } |
| OLD | NEW |