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 value will be inherited in the toolchain below. | 5 # This value will be inherited in the toolchain below. |
6 concurrent_links = exec_script("get_concurrent_links.py", [], "value") | 6 concurrent_links = exec_script("get_concurrent_links.py", [], "value") |
7 | 7 |
8 # This template defines a toolchain for something that works like gcc | 8 # This template defines a toolchain for something that works like gcc |
9 # (including clang). | 9 # (including clang). |
10 # | 10 # |
(...skipping 24 matching lines...) Expand all Loading... |
35 # command. | 35 # command. |
36 # - deps | 36 # - deps |
37 # Just forwarded to the toolchain definition. | 37 # Just forwarded to the toolchain definition. |
38 # - is_clang | 38 # - is_clang |
39 template("gcc_toolchain") { | 39 template("gcc_toolchain") { |
40 toolchain(target_name) { | 40 toolchain(target_name) { |
41 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") | 41 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") |
42 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") | 42 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") |
43 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") | 43 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") |
44 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") | 44 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") |
45 assert(defined(invoker.readelf), | |
46 "gcc_toolchain() must specify a \"readelf\" value") | |
47 assert(defined(invoker.nm), "gcc_toolchain() must specify a \"nm\" value") | |
48 assert(defined(invoker.toolchain_cpu), | 45 assert(defined(invoker.toolchain_cpu), |
49 "gcc_toolchain() must specify a \"toolchain_cpu\"") | 46 "gcc_toolchain() must specify a \"toolchain_cpu\"") |
50 assert(defined(invoker.toolchain_os), | 47 assert(defined(invoker.toolchain_os), |
51 "gcc_toolchain() must specify a \"toolchain_os\"") | 48 "gcc_toolchain() must specify a \"toolchain_os\"") |
52 | 49 |
| 50 # This define changes when the toolchain changes, forcing a rebuild. |
| 51 # Nothing should ever use this define. |
| 52 if (defined(invoker.rebuild_define)) { |
| 53 rebuild_string = "-D" + invoker.rebuild_define + " " |
| 54 } else { |
| 55 rebuild_string = "" |
| 56 } |
| 57 |
53 # We can't do string interpolation ($ in strings) on things with dots in | 58 # We can't do string interpolation ($ in strings) on things with dots in |
54 # them. To allow us to use $cc below, for example, we create copies of | 59 # them. To allow us to use $cc below, for example, we create copies of |
55 # these values in our scope. | 60 # these values in our scope. |
56 cc = invoker.cc | 61 cc = invoker.cc |
57 cxx = invoker.cxx | 62 cxx = invoker.cxx |
58 ar = invoker.ar | 63 ar = invoker.ar |
59 ld = invoker.ld | 64 ld = invoker.ld |
60 readelf = invoker.readelf | 65 if (defined(invoker.readelf)) { |
61 nm = invoker.nm | 66 readelf = invoker.readelf |
| 67 } else { |
| 68 readelf = "readelf" |
| 69 } |
| 70 if (defined(invoker.nm)) { |
| 71 nm = invoker.nm |
| 72 } else { |
| 73 nm = "nm" |
| 74 } |
| 75 |
| 76 if (defined(invoker.executable_extension)) { |
| 77 default_executable_extension = invoker.executable_extension |
| 78 } else { |
| 79 default_executable_extension = "" |
| 80 } |
62 | 81 |
63 # Bring these into our scope for string interpolation with default values. | 82 # Bring these into our scope for string interpolation with default values. |
64 if (defined(invoker.libs_section_prefix)) { | 83 if (defined(invoker.libs_section_prefix)) { |
65 libs_section_prefix = invoker.libs_section_prefix | 84 libs_section_prefix = invoker.libs_section_prefix |
66 } else { | 85 } else { |
67 libs_section_prefix = "" | 86 libs_section_prefix = "" |
68 } | 87 } |
69 | 88 |
70 if (defined(invoker.libs_section_postfix)) { | 89 if (defined(invoker.libs_section_postfix)) { |
71 libs_section_postfix = invoker.libs_section_postfix | 90 libs_section_postfix = invoker.libs_section_postfix |
(...skipping 12 matching lines...) Expand all Loading... |
84 } else { | 103 } else { |
85 solink_libs_section_postfix = "" | 104 solink_libs_section_postfix = "" |
86 } | 105 } |
87 | 106 |
88 # These library switches can apply to all tools below. | 107 # These library switches can apply to all tools below. |
89 lib_switch = "-l" | 108 lib_switch = "-l" |
90 lib_dir_switch = "-L" | 109 lib_dir_switch = "-L" |
91 | 110 |
92 tool("cc") { | 111 tool("cc") { |
93 depfile = "{{output}}.d" | 112 depfile = "{{output}}.d" |
94 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {
{cflags_c}} -c {{source}} -o {{output}}" | 113 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di
rs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
95 depsformat = "gcc" | 114 depsformat = "gcc" |
96 description = "CC {{output}}" | 115 description = "CC {{output}}" |
97 outputs = [ | 116 outputs = [ |
98 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", | 117 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
99 ] | 118 ] |
100 } | 119 } |
101 | 120 |
102 tool("cxx") { | 121 tool("cxx") { |
103 depfile = "{{output}}.d" | 122 depfile = "{{output}}.d" |
104 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}}
{{cflags_cc}} -c {{source}} -o {{output}}" | 123 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d
irs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" |
105 depsformat = "gcc" | 124 depsformat = "gcc" |
106 description = "CXX {{output}}" | 125 description = "CXX {{output}}" |
107 outputs = [ | 126 outputs = [ |
108 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", | 127 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
109 ] | 128 ] |
110 } | 129 } |
111 | 130 |
112 tool("asm") { | 131 tool("asm") { |
113 # For GCC we can just use the C compiler to compile assembly. | 132 # For GCC we can just use the C compiler to compile assembly. |
114 depfile = "{{output}}.d" | 133 depfile = "{{output}}.d" |
115 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {
{cflags_c}} -c {{source}} -o {{output}}" | 134 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di
rs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
116 depsformat = "gcc" | 135 depsformat = "gcc" |
117 description = "ASM {{output}}" | 136 description = "ASM {{output}}" |
118 outputs = [ | 137 outputs = [ |
119 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", | 138 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
120 ] | 139 ] |
121 } | 140 } |
122 | 141 |
123 tool("alink") { | 142 tool("alink") { |
124 rspfile = "{{output}}.rsp" | 143 rspfile = "{{output}}.rsp" |
125 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" | 144 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 outputs += invoker.solink_outputs | 197 outputs += invoker.solink_outputs |
179 } | 198 } |
180 link_output = sofile | 199 link_output = sofile |
181 depend_output = tocfile | 200 depend_output = tocfile |
182 } | 201 } |
183 | 202 |
184 tool("link") { | 203 tool("link") { |
185 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" | 204 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
186 rspfile = "$outfile.rsp" | 205 rspfile = "$outfile.rsp" |
187 command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solib
s}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" | 206 command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solib
s}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" |
| 207 |
| 208 default_output_extension = default_executable_extension |
| 209 |
188 if (defined(invoker.postlink)) { | 210 if (defined(invoker.postlink)) { |
189 command += " && " + invoker.postlink | 211 command += " && " + invoker.postlink |
190 } | 212 } |
191 description = "LINK $outfile" | 213 description = "LINK $outfile" |
192 rspfile_content = "{{inputs}}" | 214 rspfile_content = "{{inputs}}" |
193 outputs = [ | 215 outputs = [ |
194 outfile, | 216 outfile, |
195 ] | 217 ] |
196 if (defined(invoker.link_outputs)) { | 218 if (defined(invoker.link_outputs)) { |
197 outputs += invoker.link_outputs | 219 outputs += invoker.link_outputs |
(...skipping 13 matching lines...) Expand all Loading... |
211 # When invoking this toolchain not as the default one, these args will be | 233 # When invoking this toolchain not as the default one, these args will be |
212 # passed to the build. They are ignored when this is the default toolchain. | 234 # passed to the build. They are ignored when this is the default toolchain. |
213 toolchain_args() { | 235 toolchain_args() { |
214 current_cpu = invoker.toolchain_cpu | 236 current_cpu = invoker.toolchain_cpu |
215 current_os = invoker.toolchain_os | 237 current_os = invoker.toolchain_os |
216 | 238 |
217 # These values need to be passed through unchanged. | 239 # These values need to be passed through unchanged. |
218 target_os = target_os | 240 target_os = target_os |
219 target_cpu = target_cpu | 241 target_cpu = target_cpu |
220 | 242 |
221 if (defined(invoker.is_clang)) { | 243 forward_variables_from(invoker, |
222 is_clang = invoker.is_clang | 244 [ |
223 } | 245 "is_clang", |
| 246 "is_component_build", |
| 247 ]) |
224 } | 248 } |
225 | 249 |
226 if (defined(invoker.deps)) { | 250 forward_variables_from(invoker, [ "deps" ]) |
227 deps = invoker.deps | |
228 } | |
229 } | 251 } |
230 } | 252 } |
OLD | NEW |