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 # 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/ios/ios_sdk.gni") | 10 import("//build/config/ios/ios_sdk.gni") |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 ] | 112 ] |
| 113 default_output_extension = ".a" | 113 default_output_extension = ".a" |
| 114 output_prefix = "lib" | 114 output_prefix = "lib" |
| 115 } | 115 } |
| 116 | 116 |
| 117 tool("solink") { | 117 tool("solink") { |
| 118 dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e g "./libfoo.dylib" | 118 dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e g "./libfoo.dylib" |
| 119 rspfile = dylib + ".rsp" | 119 rspfile = dylib + ".rsp" |
| 120 | 120 |
| 121 # These variables are not built into GN but are helpers that implement | 121 # These variables are not built into GN but are helpers that implement |
| 122 # (1) linking to produce a .so, (2) extracting the symbols from that file | 122 # (1) linking to produce a .dylib, (2) extracting the symbols from that |
| 123 # to a temporary file, (3) if the temporary file has differences from the | 123 # file to a temporary file, (3) if the temporary file has differences from |
| 124 # existing .TOC file, overwrite it, otherwise, don't change it. | 124 # the existing .TOC file, overwrite it, otherwise, don't change it. |
| 125 # | 125 # |
| 126 # As a special case, if the library reexports symbols from other dynamic | 126 # As a special case, if the library reexports symbols from other dynamic |
| 127 # libraries, we always update the .TOC and skip the temporary file and | 127 # libraries, we always update the .TOC and skip the temporary file and |
| 128 # diffing steps, since that library always needs to be re-linked. | 128 # diffing steps, since that library always needs to be re-linked. |
| 129 tocname = dylib + ".TOC" | 129 tocname = dylib + ".TOC" |
| 130 temporary_tocname = dylib + ".tmp" | 130 temporary_tocname = dylib + ".tmp" |
| 131 | 131 |
| 132 does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dyl ib | grep -q LC_REEXPORT_DYLIB" | 132 does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dyl ib | grep -q LC_REEXPORT_DYLIB" |
| 133 | 133 |
| 134 link_command = "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile" | 134 link_command = "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile" |
| 135 if (is_component_build) { | 135 if (is_component_build) { |
| 136 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu t_extension}}" | 136 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu t_extension}}" |
| 137 } | 137 } |
| 138 link_command += " {{solibs}} {{libs}}" | 138 link_command += " {{solibs}} {{libs}}" |
| 139 | 139 |
| 140 replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $tempo rary_tocname $tocname" | 140 replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $tempo rary_tocname $tocname" |
| 141 extract_toc_command = "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $ dylib | cut -f1-2 -d' ' | grep -v U\$\$; true; }" | 141 extract_toc_command = "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $ dylib | cut -f1-2 -d' ' | grep -v U\$\$; true; }" |
| 142 | 142 |
| 143 command = "if $does_reexport_command ; then $link_command && $extract_toc_ command > $tocname; else $link_command && $extract_toc_command > $temporary_tocn ame && $replace_command ; fi; fi" | 143 command = "if $does_reexport_command ; then $link_command && $extract_toc_ command > $tocname; else $link_command && $extract_toc_command > $temporary_tocn ame && $replace_command ; fi; fi" |
| 144 | 144 |
| 145 rspfile_content = "{{inputs_newline}}" | 145 rspfile_content = "{{inputs_newline}}" |
| 146 | 146 |
| 147 description = "SOLINK {{output}}" | 147 description = "DYLINK {{output}}" |
| 148 | 148 |
| 149 # Use this for {{output_extension}} expansions unless a target manually | 149 # Use this for {{output_extension}} expansions unless a target manually |
| 150 # overrides it (in which case {{output_extension}} will be what the target | 150 # overrides it (in which case {{output_extension}} will be what the target |
| 151 # specifies). | 151 # specifies). |
| 152 default_output_extension = ".dylib" | 152 default_output_extension = ".dylib" |
| 153 | 153 |
| 154 output_prefix = "lib" | 154 output_prefix = "lib" |
| 155 | 155 |
| 156 # Since the above commands only updates the .TOC file when it changes, ask | 156 # Since the above commands only updates the .TOC file when it changes, ask |
| 157 # Ninja to check if the timestamp actually changed to know if downstream | 157 # Ninja to check if the timestamp actually changed to know if downstream |
| 158 # dependencies should be recompiled. | 158 # dependencies should be recompiled. |
| 159 restat = true | 159 restat = true |
| 160 | 160 |
| 161 # Tell GN about the output files. It will link to the dylib but use the | 161 # Tell GN about the output files. It will link to the dylib but use the |
| 162 # tocname for dependency management. | 162 # tocname for dependency management. |
| 163 outputs = [ | 163 outputs = [ |
| 164 dylib, | 164 dylib, |
| 165 tocname, | 165 tocname, |
| 166 ] | 166 ] |
| 167 link_output = dylib | 167 link_output = dylib |
| 168 depend_output = tocname | 168 depend_output = tocname |
| 169 } | 169 } |
| 170 | 170 |
| 171 # tool("solink") { | |
|
Bons
2015/10/06 20:29:19
This will be called solink with the above changed
| |
| 172 # sofile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}} " # eg "./libfoo.so" | |
| 173 # rspfile = sofile + ".rsp" | |
| 174 # | |
| 175 # link_command = "$ld -bundle {{ldflags}} -o $sofile -Wl,-filelist,$rsp file" | |
| 176 # if (is_component_build) { | |
| 177 # link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{ output_extension}}" | |
| 178 # } | |
| 179 # link_command += " {{solibs}} {{libs}}" | |
| 180 # command = link_command | |
| 181 # | |
| 182 # rspfile_content = "{{inputs_newline}}" | |
| 183 # | |
| 184 # description = "SOLINK {{output}}" | |
| 185 # | |
| 186 # # Use this for {{output_extension}} expansions unless a target manual ly | |
| 187 # # overrides it (in which case {{output_extension}} will be what the t arget | |
| 188 # # specifies). | |
| 189 # default_output_extension = ".so" | |
| 190 # | |
| 191 # output_prefix = "lib" | |
| 192 # | |
| 193 # outputs = [ | |
| 194 # sofile | |
| 195 # ] | |
| 196 # } | |
| 197 | |
| 171 tool("link") { | 198 tool("link") { |
| 172 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" | 199 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 173 rspfile = "$outfile.rsp" | 200 rspfile = "$outfile.rsp" |
| 174 command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} { {libs}}" | 201 command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} { {libs}}" |
| 175 description = "LINK $outfile" | 202 description = "LINK $outfile" |
| 176 rspfile_content = "{{inputs_newline}}" | 203 rspfile_content = "{{inputs_newline}}" |
| 177 outputs = [ | 204 outputs = [ |
| 178 outfile, | 205 outfile, |
| 179 ] | 206 ] |
| 180 } | 207 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 } | 278 } |
| 252 | 279 |
| 253 mac_toolchain("x64") { | 280 mac_toolchain("x64") { |
| 254 toolchain_cpu = "x64" | 281 toolchain_cpu = "x64" |
| 255 toolchain_os = "mac" | 282 toolchain_os = "mac" |
| 256 cc = "${goma_prefix}/gcc" | 283 cc = "${goma_prefix}/gcc" |
| 257 cxx = "${goma_prefix}/g++" | 284 cxx = "${goma_prefix}/g++" |
| 258 ld = cxx | 285 ld = cxx |
| 259 is_clang = false | 286 is_clang = false |
| 260 } | 287 } |
| OLD | NEW |