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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 # the existing .TOC file, overwrite it, otherwise, don't change it. | 131 # the existing .TOC file, overwrite it, otherwise, don't change it. |
132 # | 132 # |
133 # As a special case, if the library reexports symbols from other dynamic | 133 # As a special case, if the library reexports symbols from other dynamic |
134 # libraries, we always update the .TOC and skip the temporary file and | 134 # libraries, we always update the .TOC and skip the temporary file and |
135 # diffing steps, since that library always needs to be re-linked. | 135 # diffing steps, since that library always needs to be re-linked. |
136 tocname = dylib + ".TOC" | 136 tocname = dylib + ".TOC" |
137 temporary_tocname = dylib + ".tmp" | 137 temporary_tocname = dylib + ".tmp" |
138 | 138 |
139 does_reexport_command = "[ ! -e \"$dylib\" -o ! -e \"$tocname\" ] || otool -l \"$dylib\" | grep -q LC_REEXPORT_DYLIB" | 139 does_reexport_command = "[ ! -e \"$dylib\" -o ! -e \"$tocname\" ] || otool -l \"$dylib\" | grep -q LC_REEXPORT_DYLIB" |
140 | 140 |
141 link_command = "$ld -shared " | 141 linker_driver = |
142 rebase_path("//build/toolchain/mac/linker_driver.py", root_build_dir) | |
Dirk Pranke
2016/05/20 01:47:19
You should be able to hoist this up into a file-sc
Robert Sesek
2016/05/20 15:15:36
I tried doing it at the file-level but GN complain
Dirk Pranke
2016/05/20 16:43:55
Oh, yeah, usage doesn't propagate across templates
| |
143 | |
144 link_command = "$linker_driver $ld -shared " | |
142 if (is_component_build) { | 145 if (is_component_build) { |
143 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out put_extension}}\" " | 146 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out put_extension}}\" " |
144 } | 147 } |
145 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li bs}} {{solibs}}" | 148 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li bs}} {{solibs}}" |
146 | 149 |
147 replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then m v \"$temporary_tocname\" \"$tocname\"" | 150 replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then m v \"$temporary_tocname\" \"$tocname\"" |
148 extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm - gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" | 151 extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm - gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" |
149 | 152 |
150 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" | 153 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" |
151 | 154 |
152 rspfile_content = "{{inputs_newline}}" | 155 rspfile_content = "{{inputs_newline}}" |
153 | 156 |
154 description = "SOLINK {{output}}" | 157 description = "SOLINK {{output}}" |
155 | 158 |
156 # Use this for {{output_extension}} expansions unless a target manually | 159 # Use this for {{output_extension}} expansions unless a target manually |
157 # overrides it (in which case {{output_extension}} will be what the target | 160 # overrides it (in which case {{output_extension}} will be what the target |
158 # specifies). | 161 # specifies). |
159 default_output_dir = "{{root_out_dir}}" | 162 default_output_dir = "{{root_out_dir}}" |
160 default_output_extension = ".dylib" | 163 default_output_extension = ".dylib" |
161 | 164 |
162 output_prefix = "lib" | 165 output_prefix = "lib" |
163 | 166 |
164 # Since the above commands only updates the .TOC file when it changes, ask | 167 # Since the above commands only updates the .TOC file when it changes, ask |
165 # Ninja to check if the timestamp actually changed to know if downstream | 168 # Ninja to check if the timestamp actually changed to know if downstream |
166 # dependencies should be recompiled. | 169 # dependencies should be recompiled. |
167 restat = true | 170 restat = true |
168 | 171 |
169 # Tell GN about the output files. It will link to the dylib but use the | 172 # Tell GN about the output files. It will link to the dylib but use the |
170 # tocname for dependency management. | 173 # tocname for dependency management. |
171 outputs = [ | 174 outputs = [ |
Robert Sesek
2016/05/19 22:38:59
The major issue I see is that we're not listing th
Dirk Pranke
2016/05/20 01:47:19
Can you do something like:
if (enable_dsyms)
Robert Sesek
2016/05/20 15:15:36
As written, we don't generate dSYMs for every targ
Dirk Pranke
2016/05/20 16:43:55
Ah, true. Hmm ...
Robert Sesek
2016/05/24 15:05:32
Mark: What if we created fake dSYMs again? We coul
Mark Mentovai
2016/05/24 18:24:32
I would prefer not to. The fake .dSYMs were just g
Robert Sesek
2016/05/24 18:28:23
In GN land, enable_dsyms is by default tied to is_
| |
172 dylib, | 175 dylib, |
173 tocname, | 176 tocname, |
174 ] | 177 ] |
175 link_output = dylib | 178 link_output = dylib |
176 depend_output = tocname | 179 depend_output = tocname |
177 } | 180 } |
178 | 181 |
179 tool("solink_module") { | 182 tool("solink_module") { |
180 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.so" | 183 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg "./libfoo.so" |
181 rspfile = sofile + ".rsp" | 184 rspfile = sofile + ".rsp" |
182 | 185 |
183 link_command = | 186 linker_driver = |
184 "$ld -bundle {{ldflags}} -o \"$sofile\" -Wl,-filelist,\"$rspfile\"" | 187 rebase_path("//build/toolchain/mac/linker_driver.py", root_build_dir) |
188 | |
189 link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl, -filelist,\"$rspfile\"" | |
185 if (is_component_build) { | 190 if (is_component_build) { |
186 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu t_extension}}" | 191 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu t_extension}}" |
187 } | 192 } |
188 link_command += " {{solibs}} {{libs}}" | 193 link_command += " {{solibs}} {{libs}}" |
189 command = link_command | 194 command = link_command |
190 | 195 |
191 rspfile_content = "{{inputs_newline}}" | 196 rspfile_content = "{{inputs_newline}}" |
192 | 197 |
193 description = "SOLINK_MODULE {{output}}" | 198 description = "SOLINK_MODULE {{output}}" |
194 | 199 |
(...skipping 13 matching lines...) Expand all Loading... | |
208 rspfile = "$outfile.rsp" | 213 rspfile = "$outfile.rsp" |
209 | 214 |
210 # Note about --filelist: Apple's linker reads the file list file and | 215 # Note about --filelist: Apple's linker reads the file list file and |
211 # interprets each newline-separated chunk of text as a file name. It | 216 # interprets each newline-separated chunk of text as a file name. It |
212 # doesn't do the things one would expect from the shell like unescaping | 217 # doesn't do the things one would expect from the shell like unescaping |
213 # or handling quotes. In contrast, when Ninja finds a file name with | 218 # or handling quotes. In contrast, when Ninja finds a file name with |
214 # spaces, it single-quotes them in $inputs_newline as it would normally | 219 # spaces, it single-quotes them in $inputs_newline as it would normally |
215 # do for command-line arguments. Thus any source names with spaces, or | 220 # do for command-line arguments. Thus any source names with spaces, or |
216 # label names with spaces (which GN bases the output paths on) will be | 221 # label names with spaces (which GN bases the output paths on) will be |
217 # corrupted by this process. Don't use spaces for source files or labels. | 222 # corrupted by this process. Don't use spaces for source files or labels. |
218 command = "$ld {{ldflags}} -o \"$outfile\" -Wl,-filelist,\"$rspfile\" {{so libs}} {{libs}}" | 223 linker_driver = |
224 rebase_path("//build/toolchain/mac/linker_driver.py", root_build_dir) | |
225 | |
226 command = "$linker_driver $ld {{ldflags}} -o \"$outfile\" -Wl,-filelist,\" $rspfile\" {{solibs}} {{libs}}" | |
219 description = "LINK $outfile" | 227 description = "LINK $outfile" |
220 rspfile_content = "{{inputs_newline}}" | 228 rspfile_content = "{{inputs_newline}}" |
221 outputs = [ | 229 outputs = [ |
222 outfile, | 230 outfile, |
223 ] | 231 ] |
224 | 232 |
225 default_output_dir = "{{root_out_dir}}" | 233 default_output_dir = "{{root_out_dir}}" |
226 } | 234 } |
227 | 235 |
228 # These two are really entirely generic, but have to be repeated in | 236 # These two are really entirely generic, but have to be repeated in |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } | 364 } |
357 | 365 |
358 mac_toolchain("x64") { | 366 mac_toolchain("x64") { |
359 toolchain_cpu = "x64" | 367 toolchain_cpu = "x64" |
360 toolchain_os = "mac" | 368 toolchain_os = "mac" |
361 cc = "${goma_prefix}/gcc" | 369 cc = "${goma_prefix}/gcc" |
362 cxx = "${goma_prefix}/g++" | 370 cxx = "${goma_prefix}/g++" |
363 ld = cxx | 371 ld = cxx |
364 is_clang = false | 372 is_clang = false |
365 } | 373 } |
OLD | NEW |