Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/fnl/BUILD.gn ('k') | build/toolchain/get_concurrent_links.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 # This value will be inherited in the toolchain below.
6 concurrent_links = exec_script("get_concurrent_links.py", [], "value")
7
8 # This template defines a toolchain for something that works like gcc
9 # (including clang).
10 #
11 # It requires the following variables specifying the executables to run:
12 # - cc
13 # - cxx
14 # - ar
15 # - ld
16 # - readelf
17 # - nm
18 # and the following which is used in the toolchain_args
19 # - toolchain_cpu (What "current_cpu" should be set to when invoking a
20 # build using this toolchain.)
21 # - toolchain_os (What "current_os" should be set to when invoking a
22 # build using this toolchain.)
23 #
24 # Optional parameters:
25 # - libs_section_prefix
26 # - libs_section_postfix
27 # The contents of these strings, if specified, will be placed around
28 # the libs section of the linker line. It allows one to inject libraries
29 # at the beginning and end for all targets in a toolchain.
30 # - solink_libs_section_prefix
31 # - solink_libs_section_postfix
32 # Same as libs_section_{pre,post}fix except used for solink instead of link .
33 # - post_solink
34 # The content of this string, if specified, will be appended to the solink
35 # command.
36 # - deps
37 # Just forwarded to the toolchain definition.
38 # - is_clang
39 # - strip
40 # Location of the strip executable. When specified, strip will be run on
41 # all shared libraries and executables as they are built. The pre-stripped
42 # artifacts will be put in lib.stripped/ and exe.stripped/.
43 template("gcc_toolchain") {
44 toolchain(target_name) {
45 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
46 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
47 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
48 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")
49 assert(defined(invoker.readelf),
50 "gcc_toolchain() must specify a \"readelf\" value")
51 assert(defined(invoker.nm), "gcc_toolchain() must specify a \"nm\" value")
52 assert(defined(invoker.toolchain_cpu),
53 "gcc_toolchain() must specify a \"toolchain_cpu\"")
54 assert(defined(invoker.toolchain_os),
55 "gcc_toolchain() must specify a \"toolchain_os\"")
56
57 # We can't do string interpolation ($ in strings) on things with dots in
58 # them. To allow us to use $cc below, for example, we create copies of
59 # these values in our scope.
60 cc = invoker.cc
61 cxx = invoker.cxx
62 ar = invoker.ar
63 ld = invoker.ld
64 readelf = invoker.readelf
65 nm = invoker.nm
66
67 # Bring these into our scope for string interpolation with default values.
68 if (defined(invoker.libs_section_prefix)) {
69 libs_section_prefix = invoker.libs_section_prefix
70 } else {
71 libs_section_prefix = ""
72 }
73
74 if (defined(invoker.libs_section_postfix)) {
75 libs_section_postfix = invoker.libs_section_postfix
76 } else {
77 libs_section_postfix = ""
78 }
79
80 if (defined(invoker.solink_libs_section_prefix)) {
81 solink_libs_section_prefix = invoker.solink_libs_section_prefix
82 } else {
83 solink_libs_section_prefix = ""
84 }
85
86 if (defined(invoker.solink_libs_section_postfix)) {
87 solink_libs_section_postfix = invoker.solink_libs_section_postfix
88 } else {
89 solink_libs_section_postfix = ""
90 }
91
92 # These library switches can apply to all tools below.
93 lib_switch = "-l"
94 lib_dir_switch = "-L"
95
96 tool("cc") {
97 depfile = "{{output}}.d"
98 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}"
99 depsformat = "gcc"
100 description = "CC {{output}}"
101 outputs = [
102 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o",
103 ]
104 }
105
106 tool("cxx") {
107 depfile = "{{output}}.d"
108 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
109 depsformat = "gcc"
110 description = "CXX {{output}}"
111 outputs = [
112 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o",
113 ]
114 }
115
116 tool("asm") {
117 # For GCC we can just use the C compiler to compile assembly.
118 depfile = "{{output}}.d"
119 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}"
120 depsformat = "gcc"
121 description = "ASM {{output}}"
122 outputs = [
123 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o",
124 ]
125 }
126
127 tool("alink") {
128 rspfile = "{{output}}.rsp"
129 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile"
130 description = "AR {{output}}"
131 rspfile_content = "{{inputs}}"
132 outputs = [
133 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}",
134 ]
135 default_output_extension = ".a"
136 output_prefix = "lib"
137 }
138
139 tool("solink") {
140 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
141 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir.
142 rspfile = sofile + ".rsp"
143
144 # These variables are not built into GN but are helpers that implement
145 # (1) linking to produce a .so, (2) extracting the symbols from that file
146 # to a temporary file, (3) if the temporary file has differences from the
147 # existing .TOC file, overwrite it, otherwise, don't change it.
148 tocfile = sofile + ".TOC"
149 temporary_tocname = sofile + ".tmp"
150 link_command =
151 "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile"
152 toc_command = "{ $readelf -d $sofile | grep SONAME ; $nm -gD -f p $sofile | cut -f1-2 -d' '; } > $temporary_tocname"
153 replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $tempo rary_tocname $tocfile; fi"
154
155 command = "$link_command && $toc_command && $replace_command"
156 if (defined(invoker.postsolink)) {
157 command += " && " + invoker.postsolink
158 }
159 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
160
161 description = "SOLINK $sofile"
162
163 # Use this for {{output_extension}} expansions unless a target manually
164 # overrides it (in which case {{output_extension}} will be what the target
165 # specifies).
166 default_output_extension = ".so"
167 if (defined(invoker.default_output_extension)) {
168 default_output_extension = invoker.default_output_extension
169 }
170
171 output_prefix = "lib"
172
173 # Since the above commands only updates the .TOC file when it changes, ask
174 # Ninja to check if the timestamp actually changed to know if downstream
175 # dependencies should be recompiled.
176 restat = true
177
178 # Tell GN about the output files. It will link to the sofile but use the
179 # tocfile for dependency management.
180 outputs = [
181 sofile,
182 tocfile,
183 ]
184 if (defined(invoker.solink_outputs)) {
185 outputs += invoker.solink_outputs
186 }
187 link_output = sofile
188 depend_output = tocfile
189 }
190
191 tool("link") {
192 exename = "{{target_output_name}}{{output_extension}}"
193 outfile = "{{root_out_dir}}/$exename"
194 rspfile = "$outfile.rsp"
195 unstripped_outfile = outfile
196
197 if (defined(invoker.strip)) {
198 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
199 }
200
201 command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspf ile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postf ix"
202 if (defined(invoker.strip)) {
203 strip = invoker.strip
204 strip_command = "${strip} --strip-unneeded -o $outfile $unstripped_outfi le"
205 command += " && " + strip_command
206 }
207 if (defined(invoker.postlink)) {
208 command += " && " + invoker.postlink
209 }
210 description = "LINK $outfile"
211 rspfile_content = "{{inputs}}"
212 outputs = [
213 outfile,
214 ]
215 if (outfile != unstripped_outfile) {
216 outputs += [ unstripped_outfile ]
217 }
218 if (defined(invoker.link_outputs)) {
219 outputs += invoker.link_outputs
220 }
221 }
222
223 tool("stamp") {
224 command = "touch {{output}}"
225 description = "STAMP {{output}}"
226 }
227
228 tool("copy") {
229 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} & & cp -af {{source}} {{output}})"
230 description = "COPY {{source}} {{output}}"
231 }
232
233 # When invoking this toolchain not as the default one, these args will be
234 # passed to the build. They are ignored when this is the default toolchain.
235 toolchain_args() {
236 current_cpu = invoker.toolchain_cpu
237 current_os = invoker.toolchain_os
238
239 # These values need to be passed through unchanged.
240 target_os = target_os
241 target_cpu = target_cpu
242
243 if (defined(invoker.is_clang)) {
244 is_clang = invoker.is_clang
245 }
246 }
247
248 if (defined(invoker.deps)) {
249 deps = invoker.deps
250 }
251 }
252 }
OLDNEW
« no previous file with comments | « build/toolchain/fnl/BUILD.gn ('k') | build/toolchain/get_concurrent_links.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698