OLD | NEW |
1 # Copyright (c) 2014 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2014 The Native Client 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 import("//build/config/sysroot.gni") | 5 import("//build/config/sysroot.gni") |
6 import("//build/config/nacl/config.gni") | 6 import("//build/config/nacl/config.gni") |
7 import("//build/toolchain/nacl_toolchain.gni") | 7 import("//build/toolchain/nacl_toolchain.gni") |
8 | 8 |
9 # Add the toolchain revision as a preprocessor define so that sources are | 9 # Add the toolchain revision as a preprocessor define so that sources are |
10 # rebuilt when a toolchain is updated. | 10 # rebuilt when a toolchain is updated. |
11 # Idea we could use the toolchain deps feature, but currently that feature is | 11 # Idea we could use the toolchain deps feature, but currently that feature is |
12 # bugged and does not trigger a rebuild. | 12 # bugged and does not trigger a rebuild. |
13 # https://code.google.com/p/chromium/issues/detail?id=431880 | 13 # https://code.google.com/p/chromium/issues/detail?id=431880 |
14 # Calls to get the toolchain revision are relatively slow, so do them all in a | 14 # Calls to get the toolchain revision are relatively slow, so do them all in a |
15 # single batch to amortize python startup, etc. | 15 # single batch to amortize python startup, etc. |
16 revisions = exec_script("//native_client/build/get_toolchain_revision.py", | 16 revisions = exec_script("//native_client/build/get_toolchain_revision.py", |
17 [ | 17 [ |
18 "nacl_x86_glibc", | 18 "nacl_x86_glibc", |
19 "nacl_arm_glibc", | 19 "nacl_arm_glibc", |
20 "pnacl_newlib", | 20 "pnacl_newlib", |
21 ], | 21 ], |
22 "trim list lines") | 22 "trim list lines") |
23 nacl_x86_glibc_rev = revisions[0] | 23 nacl_x86_glibc_rev = revisions[0] |
24 nacl_arm_glibc_rev = revisions[1] | 24 nacl_arm_glibc_rev = revisions[1] |
25 | 25 |
26 # TODO(mcgrathr): Uncomment this when | 26 pnacl_newlib_rev = revisions[2] |
27 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. | 27 |
28 #pnacl_newlib_rev = revisions[2] | 28 if (host_os == "win") { |
| 29 toolsuffix = ".exe" |
| 30 } else { |
| 31 toolsuffix = "" |
| 32 } |
| 33 |
| 34 # The PNaCl toolchain tools are all wrapper scripts rather than binary |
| 35 # executables. On POSIX systems, nobody cares what kind of executable |
| 36 # file you are. But on Windows, scripts (.bat files) cannot be run |
| 37 # directly and need the Windows shell (cmd.exe) specified explicily. |
| 38 if (host_os == "win") { |
| 39 # NOTE! The //build/toolchain/gcc_*_wrapper.py scripts recognize |
| 40 # this exact prefix string, so they must be updated if this string |
| 41 # is changed in any way. |
| 42 scriptprefix = "cmd /c call " |
| 43 scriptsuffix = ".bat" |
| 44 } else { |
| 45 scriptprefix = "" |
| 46 scriptsuffix = "" |
| 47 } |
| 48 |
| 49 # When the compilers are run via goma or ccache rather than directly by |
| 50 # GN/Ninja, the goma/ccache wrapper handles .bat files but gets confused |
| 51 # by being given the scriptprefix. |
| 52 if (host_os == "win" && !use_goma && cc_wrapper == "") { |
| 53 compiler_scriptprefix = scriptprefix |
| 54 } else { |
| 55 compiler_scriptprefix = "" |
| 56 } |
29 | 57 |
30 template("pnacl_toolchain") { | 58 template("pnacl_toolchain") { |
31 assert(defined(invoker.executable_extension), | 59 assert(defined(invoker.executable_extension), |
32 "Must define executable_extension") | 60 "Must define executable_extension") |
33 | 61 |
34 # TODO(mcgrathr): See above. | |
35 pnacl_newlib_rev = revisions[2] | |
36 | |
37 # The PNaCl toolchain tools are all wrapper scripts rather than binary | |
38 # executables. On POSIX systems, nobody cares what kind of executable | |
39 # file you are. But on Windows, scripts (.bat files) cannot be run | |
40 # directly and need the Windows shell (cmd.exe) specified explicily. | |
41 # TODO(mcgrathr): Hoist this to top level when | |
42 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. | |
43 if (host_os == "win") { | |
44 # NOTE! The //build/toolchain/gcc_*_wrapper.py scripts recognize | |
45 # this exact prefix string, so they must be updated if this string | |
46 # is changed in any way. | |
47 scriptprefix = "cmd /c call " | |
48 scriptsuffix = ".bat" | |
49 } else { | |
50 scriptprefix = "" | |
51 scriptsuffix = "" | |
52 } | |
53 | |
54 # When the compilers are run via goma or ccache rather than directly by | |
55 # GN/Ninja, the goma/ccache wrapper handles .bat files but gets confused | |
56 # by being given the scriptprefix. | |
57 if (host_os == "win" && !use_goma && cc_wrapper == "") { | |
58 compiler_scriptprefix = scriptprefix | |
59 } else { | |
60 compiler_scriptprefix = "" | |
61 } | |
62 | |
63 nacl_toolchain(target_name) { | 62 nacl_toolchain(target_name) { |
64 toolchain_package = "pnacl_newlib" | 63 toolchain_package = "pnacl_newlib" |
65 toolchain_revision = pnacl_newlib_rev | 64 toolchain_revision = pnacl_newlib_rev |
66 toolprefix = | 65 toolprefix = |
67 rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/pnacl-", | 66 rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/pnacl-", |
68 root_build_dir) | 67 root_build_dir) |
69 | 68 |
70 cc = compiler_scriptprefix + toolprefix + "clang" + scriptsuffix | 69 cc = compiler_scriptprefix + toolprefix + "clang" + scriptsuffix |
71 cxx = compiler_scriptprefix + toolprefix + "clang++" + scriptsuffix | 70 cxx = compiler_scriptprefix + toolprefix + "clang++" + scriptsuffix |
72 ar = scriptprefix + toolprefix + "ar" + scriptsuffix | 71 ar = scriptprefix + toolprefix + "ar" + scriptsuffix |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 forward_variables_from(invoker, | 114 forward_variables_from(invoker, |
116 [ | 115 [ |
117 "toolchain_package", | 116 "toolchain_package", |
118 "toolchain_revision", | 117 "toolchain_revision", |
119 ]) | 118 ]) |
120 | 119 |
121 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + | 120 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + |
122 invoker.toolchain_tuple + "-", | 121 invoker.toolchain_tuple + "-", |
123 root_build_dir) | 122 root_build_dir) |
124 | 123 |
125 # TODO(mcgrathr): Hoist this to top level when | |
126 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. | |
127 if (host_os == "win") { | |
128 toolsuffix = ".exe" | |
129 } else { | |
130 toolsuffix = "" | |
131 } | |
132 | |
133 nacl_toolchain("glibc_" + toolchain_cpu) { | 124 nacl_toolchain("glibc_" + toolchain_cpu) { |
134 cc = toolprefix + "gcc" + toolsuffix | 125 cc = toolprefix + "gcc" + toolsuffix |
135 cxx = toolprefix + "g++" + toolsuffix | 126 cxx = toolprefix + "g++" + toolsuffix |
136 ar = toolprefix + "ar" + toolsuffix | 127 ar = toolprefix + "ar" + toolsuffix |
137 ld = cxx | 128 ld = cxx |
138 readelf = toolprefix + "readelf" + toolsuffix | 129 readelf = toolprefix + "readelf" + toolsuffix |
139 nm = toolprefix + "nm" + toolsuffix | 130 nm = toolprefix + "nm" + toolsuffix |
140 strip = toolprefix + "strip" + toolsuffix | 131 strip = toolprefix + "strip" + toolsuffix |
141 | 132 |
142 toolchain_args = { | 133 toolchain_args = { |
(...skipping 25 matching lines...) Expand all Loading... |
168 nacl_glibc_toolchain("arm") { | 159 nacl_glibc_toolchain("arm") { |
169 toolchain_package = "nacl_arm_glibc" | 160 toolchain_package = "nacl_arm_glibc" |
170 toolchain_revision = nacl_arm_glibc_rev | 161 toolchain_revision = nacl_arm_glibc_rev |
171 toolchain_tuple = "arm-nacl" | 162 toolchain_tuple = "arm-nacl" |
172 } | 163 } |
173 | 164 |
174 template("nacl_clang_toolchain") { | 165 template("nacl_clang_toolchain") { |
175 toolchain_cpu = target_name | 166 toolchain_cpu = target_name |
176 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple") | 167 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple") |
177 | 168 |
178 # TODO(mcgrathr): See above. | |
179 pnacl_newlib_rev = revisions[2] | |
180 | |
181 toolchain_package = "pnacl_newlib" | 169 toolchain_package = "pnacl_newlib" |
182 toolchain_revision = pnacl_newlib_rev | 170 toolchain_revision = pnacl_newlib_rev |
183 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + | 171 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + |
184 invoker.toolchain_tuple + "-", | 172 invoker.toolchain_tuple + "-", |
185 root_build_dir) | 173 root_build_dir) |
186 | 174 |
187 # TODO(mcgrathr): Hoist this to top level when | |
188 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. | |
189 if (host_os == "win") { | |
190 toolsuffix = ".exe" | |
191 } else { | |
192 toolsuffix = "" | |
193 } | |
194 | |
195 nacl_toolchain("clang_newlib_" + toolchain_cpu) { | 175 nacl_toolchain("clang_newlib_" + toolchain_cpu) { |
196 cc = toolprefix + "clang" + toolsuffix | 176 cc = toolprefix + "clang" + toolsuffix |
197 cxx = toolprefix + "clang++" + toolsuffix | 177 cxx = toolprefix + "clang++" + toolsuffix |
198 ar = toolprefix + "ar" + toolsuffix | 178 ar = toolprefix + "ar" + toolsuffix |
199 ld = cxx | 179 ld = cxx |
200 readelf = toolprefix + "readelf" + toolsuffix | 180 readelf = toolprefix + "readelf" + toolsuffix |
201 nm = toolprefix + "nm" + toolsuffix | 181 nm = toolprefix + "nm" + toolsuffix |
202 strip = toolprefix + "strip" + toolsuffix | 182 strip = toolprefix + "strip" + toolsuffix |
203 | 183 |
204 toolchain_args = { | 184 toolchain_args = { |
205 current_cpu = toolchain_cpu | 185 current_cpu = toolchain_cpu |
206 is_clang = true | 186 is_clang = true |
207 } | 187 } |
208 } | 188 } |
209 } | 189 } |
210 | 190 |
211 template("nacl_irt_toolchain") { | 191 template("nacl_irt_toolchain") { |
212 toolchain_cpu = target_name | 192 toolchain_cpu = target_name |
213 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple") | 193 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple") |
214 | 194 |
215 # TODO(mcgrathr): See above. | |
216 pnacl_newlib_rev = revisions[2] | |
217 | |
218 toolchain_package = "pnacl_newlib" | 195 toolchain_package = "pnacl_newlib" |
219 toolchain_revision = pnacl_newlib_rev | 196 toolchain_revision = pnacl_newlib_rev |
220 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + | 197 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + |
221 invoker.toolchain_tuple + "-", | 198 invoker.toolchain_tuple + "-", |
222 root_build_dir) | 199 root_build_dir) |
223 | 200 |
224 # TODO(mcgrathr): Hoist this to top level when | |
225 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. | |
226 if (host_os == "win") { | |
227 toolsuffix = ".exe" | |
228 } else { | |
229 toolsuffix = "" | |
230 } | |
231 | |
232 link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir) | 201 link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir) |
233 | 202 |
234 tls_edit_label = | 203 tls_edit_label = |
235 "//native_client/src/tools/tls_edit:tls_edit($host_toolchain)" | 204 "//native_client/src/tools/tls_edit:tls_edit($host_toolchain)" |
236 host_toolchain_out_dir = | 205 host_toolchain_out_dir = |
237 rebase_path(get_label_info(tls_edit_label, "root_out_dir"), | 206 rebase_path(get_label_info(tls_edit_label, "root_out_dir"), |
238 root_build_dir) | 207 root_build_dir) |
239 tls_edit = "${host_toolchain_out_dir}/tls_edit" | 208 tls_edit = "${host_toolchain_out_dir}/tls_edit" |
240 | 209 |
241 nacl_toolchain("irt_" + toolchain_cpu) { | 210 nacl_toolchain("irt_" + toolchain_cpu) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 toolchain_tuple = "x86_64-nacl" | 250 toolchain_tuple = "x86_64-nacl" |
282 } | 251 } |
283 | 252 |
284 nacl_clang_toolchains("x64") { | 253 nacl_clang_toolchains("x64") { |
285 toolchain_tuple = "x86_64-nacl" | 254 toolchain_tuple = "x86_64-nacl" |
286 } | 255 } |
287 | 256 |
288 nacl_clang_toolchains("arm") { | 257 nacl_clang_toolchains("arm") { |
289 toolchain_tuple = "arm-nacl" | 258 toolchain_tuple = "arm-nacl" |
290 } | 259 } |
OLD | NEW |