OLD | NEW |
---|---|
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import("//build/config/nacl/rules.gni") | 5 import("//build/config/nacl/rules.gni") |
6 | 6 |
7 assert(enable_nacl) | 7 assert(enable_nacl) |
8 | 8 |
9 if (current_cpu == "pnacl") { | 9 if (current_cpu == "pnacl") { |
10 if (is_nacl_nonsfi) { | 10 if (is_nacl_nonsfi) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 output_name = target_name | 46 output_name = target_name |
47 } | 47 } |
48 | 48 |
49 if (current_cpu == "x64") { | 49 if (current_cpu == "x64") { |
50 nmf_cpu = "x86_64" | 50 nmf_cpu = "x86_64" |
51 } else if (current_cpu == "x86") { | 51 } else if (current_cpu == "x86") { |
52 nmf_cpu = "x86_32" | 52 nmf_cpu = "x86_32" |
53 } else { | 53 } else { |
54 nmf_cpu = current_cpu | 54 nmf_cpu = current_cpu |
55 } | 55 } |
56 if (is_nacl_glibc) { | 56 |
57 suffix = "glibc_${nmf_cpu}" | |
58 } else { | |
59 suffix = "newlib_${nmf_cpu}" | |
60 } | |
61 suffixed_output_name = "${output_name}_${suffix}" | |
62 if (current_cpu == "pnacl") { | 57 if (current_cpu == "pnacl") { |
63 if (defined(invoker.pretranslate_pexe)) { | 58 if (defined(invoker.pretranslate_pexe)) { |
64 pretranslate_pexe = invoker.pretranslate_pexe | 59 pretranslate_pexe = invoker.pretranslate_pexe |
65 } else { | 60 } else { |
66 pretranslate_pexe = is_nacl_nonsfi | 61 pretranslate_pexe = is_nacl_nonsfi |
67 } | 62 } |
68 if (pretranslate_pexe) { | 63 } else { |
69 pexe_translate_target_name = target_name + "_translate_pexe" | 64 pretranslate_pexe = false |
65 } | |
66 | |
67 # Note this can't test "is_win" because it's evaluated in the NaCl | |
68 # toolchain context where is_win==false because current_os=="nacl". | |
69 # It tests target_cpu rather than current_cpu because it's also | |
70 # needed in the current_cpu=="pnacl" && pretranslate_pexe case. | |
71 if (target_os == "win" && target_cpu == "x86" && !is_nacl_nonsfi && | |
72 (current_cpu == "x86" || pretranslate_pexe)) { | |
73 # x86 Windows builds of Chrome run on both x86 Windows and x64 | |
74 # Windows. On x64 Windows, only x64 NaCl is supported, so those | |
75 # tests are needed too. | |
76 extra_tc_cpu = "x64" | |
77 if (current_cpu == "x86") { | |
78 extra_nmf_cpu = "x86_64" | |
70 } | 79 } |
71 } | 80 } |
81 | |
82 if (is_nacl_glibc) { | |
83 suffix = "glibc_${nmf_cpu}" | |
84 if (defined(extra_nmf_cpu)) { | |
85 extra_suffix = "glibc_${extra_nmf_cpu}" | |
86 glibc_tc = "//build/toolchain/nacl:glibc" | |
87 assert(current_toolchain == "${glibc_tc}_${current_cpu}") | |
88 extra_toolchain = "${glibc_tc}_${extra_tc_cpu}" | |
89 } | |
90 } else { | |
91 suffix = "newlib_${nmf_cpu}" | |
92 if (defined(extra_nmf_cpu)) { | |
93 extra_suffix = "newlib_${extra_nmf_cpu}" | |
94 newlib_tc = "//build/toolchain/nacl:clang_newlib" | |
95 assert(current_toolchain == "${newlib_tc}_${current_cpu}") | |
96 extra_toolchain = "${newlib_tc}_${extra_tc_cpu}" | |
97 } | |
98 } | |
99 suffixed_output_name = "${output_name}_${suffix}" | |
100 if (defined(extra_nmf_cpu)) { | |
101 extra_suffixed_output_name = "${output_name}_${extra_suffix}" | |
102 } | |
103 if (pretranslate_pexe) { | |
104 pexe_translate_target_name = target_name + "_translate_pexe_" | |
105 if (defined(extra_tc_cpu)) { | |
106 # There will be an extra pretranslation done below for the | |
107 # extra CPU (i.e. for x64 on x86 Windows). | |
108 extra_pexe_translate_target_name = | |
109 pexe_translate_target_name + extra_tc_cpu | |
110 } | |
111 pexe_translate_target_name += target_cpu | |
112 } | |
72 if (defined(invoker.generate_nmf)) { | 113 if (defined(invoker.generate_nmf)) { |
73 generate_nmf = invoker.generate_nmf | 114 generate_nmf = invoker.generate_nmf |
74 } else { | 115 } else { |
75 generate_nmf = true | 116 generate_nmf = true |
76 } | 117 } |
77 nexe_target_name = target_name + "_nexe" | 118 nexe_target_name = target_name + "_nexe" |
78 nexe_copy_target_name = target_name + "_copy_nexe" | 119 nexe_copy_target_name = target_name + "_copy_nexe" |
79 if (current_cpu == "pnacl" && !is_nacl_nonsfi) { | 120 if (current_cpu == "pnacl" && !is_nacl_nonsfi) { |
80 if (defined(invoker.debug_pexe) && invoker.debug_pexe) { | 121 if (defined(invoker.debug_pexe) && invoker.debug_pexe) { |
81 pexe_copy_debug_target_name = target_name + "_copy_pexe_debug" | 122 pexe_copy_debug_target_name = target_name + "_copy_pexe_debug" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 "//build/config/nacl:nacl_base", | 170 "//build/config/nacl:nacl_base", |
130 "//ppapi/native_client:ppapi_lib", | 171 "//ppapi/native_client:ppapi_lib", |
131 ] | 172 ] |
132 ldflags = [ "-pthread" ] | 173 ldflags = [ "-pthread" ] |
133 if (defined(invoker.deps)) { | 174 if (defined(invoker.deps)) { |
134 deps += invoker.deps | 175 deps += invoker.deps |
135 } | 176 } |
136 } | 177 } |
137 | 178 |
138 if (current_cpu == "pnacl" && pretranslate_pexe) { | 179 if (current_cpu == "pnacl" && pretranslate_pexe) { |
139 action(pexe_translate_target_name) { | 180 # This is a template so it can be invoked twice in the |
140 visibility = [ ":$nexe_copy_target_name" ] | 181 # defined(extra_tc_cpu) case below. |
182 template("nacl_test_data_pretranslate_pexe") { | |
Petr Hosek
2016/05/12 22:08:26
Since translate_cpu is a required argument, we sho
Roland McGrath
2016/05/12 22:29:59
I thought about that but didn't bother. It might
| |
183 action(target_name) { | |
184 visibility = [ ":$nexe_copy_target_name" ] | |
141 | 185 |
142 # We specify the toolchain explicitly because in the Non-SFI case, we | 186 # We specify the toolchain explicitly because in the Non-SFI case, we |
143 # still want to use the pexe built using the newlib_pnacl toolchain. | 187 # still want to use the pexe built using the newlib_pnacl toolchain. |
144 tests = ":ppapi_nacl_tests_nexe(//build/toolchain/nacl:newlib_pnacl)" | 188 tests = ":ppapi_nacl_tests_nexe(//build/toolchain/nacl:newlib_pnacl)" |
145 | 189 |
146 pexe = get_label_info(tests, "root_out_dir") + | 190 pexe = get_label_info(tests, "root_out_dir") + |
147 "/${suffixed_output_name}.pexe" | 191 "/${suffixed_output_name}.pexe" |
148 if (target_cpu == "x86" || | 192 if (invoker.translate_cpu == "x86" || (is_nacl_nonsfi && |
149 (is_nacl_nonsfi && (target_cpu == "x86" || target_cpu == "x64"))) { | 193 (invoker.translate_cpu == |
150 nmf_cpu = "x32" | 194 "x86" || |
151 } else { | 195 invoker.translate_cpu == "x64")) ) { |
152 nmf_cpu = target_cpu | 196 nmf_cpu = "x32" |
197 } else { | |
198 nmf_cpu = invoker.translate_cpu | |
199 } | |
200 if (is_nacl_nonsfi) { | |
201 suffix = "pnacl_newlib_${nmf_cpu}_nonsfi" | |
202 } else { | |
203 suffix = "pnacl_newlib_${nmf_cpu}" | |
204 } | |
205 nexe = "${root_out_dir}/${output_name}_${suffix}.nexe" | |
206 | |
207 script = "${nacl_toolchain_bindir}/pydir/loader.py" | |
208 sources = [ | |
209 pexe, | |
210 ] | |
211 outputs = [ | |
212 nexe, | |
213 ] | |
214 | |
215 if (is_nacl_nonsfi) { | |
216 if (invoker.translate_cpu == "x86" || invoker.translate_cpu == "x64") { | |
217 arch = "x86-32-nonsfi" | |
218 } else if (invoker.translate_cpu == "arm") { | |
219 arch = "arm-nonsfi" | |
220 } | |
221 } else { | |
222 # TODO(phosek): remove the following once change 1360243003 is rolled | |
223 # into Chrome and use invoker.translate_cpu directly. | |
224 if (invoker.translate_cpu == "x86") { | |
225 arch = "i686" | |
226 } else if (invoker.translate_cpu == "x64") { | |
227 arch = "x86-64" | |
228 } else if (invoker.translate_cpu == "arm") { | |
229 arch = "armv7" | |
230 } | |
231 } | |
232 | |
233 # The pre-translated object file has to be linked with an IRT shim to | |
234 # get a runnable nexe. This is handled by pnacl-translate, which passes | |
235 # -l:libpnacl_irt_shim.a to native linker, and we need to ensure the | |
236 # linker can find the correct library. | |
237 if (is_nacl_nonsfi) { | |
238 pnacl_irt_shim = "//ppapi/native_client/src/untrusted/pnacl_irt_shim:a ot(//build/toolchain/nacl:newlib_pnacl_nonsfi)" | |
239 } else { | |
240 pnacl_irt_shim = "//ppapi/native_client/src/untrusted/pnacl_irt_shim:a ot(//build/toolchain/nacl:clang_newlib_${invoker.translate_cpu})" | |
241 } | |
242 | |
243 args = [ | |
244 "pnacl-translate", | |
245 rebase_path(pexe, root_build_dir), | |
246 "-o", | |
247 rebase_path(nexe, root_build_dir), | |
248 "-arch", | |
249 arch, | |
250 "-Wl,-L" + | |
251 rebase_path(get_label_info(pnacl_irt_shim, "target_out_dir")), | |
252 ] | |
253 deps = [ | |
254 ":$nexe_target_name(//build/toolchain/nacl:newlib_pnacl)", | |
255 ] | |
256 data_deps = [ | |
257 pnacl_irt_shim, | |
258 ] | |
153 } | 259 } |
154 if (is_nacl_nonsfi) { | 260 } |
155 suffix = "pnacl_newlib_${nmf_cpu}_nonsfi" | 261 |
156 } else { | 262 nacl_test_data_pretranslate_pexe(pexe_translate_target_name) { |
157 suffix = "pnacl_newlib_${nmf_cpu}" | 263 translate_cpu = target_cpu |
264 } | |
265 if (defined(extra_tc_cpu)) { | |
266 nacl_test_data_pretranslate_pexe(extra_pexe_translate_target_name) { | |
267 translate_cpu = extra_tc_cpu | |
158 } | 268 } |
159 nexe = "${root_out_dir}/${output_name}_${suffix}.nexe" | |
160 | |
161 script = "${nacl_toolchain_bindir}/pydir/loader.py" | |
162 sources = [ | |
163 pexe, | |
164 ] | |
165 outputs = [ | |
166 nexe, | |
167 ] | |
168 | |
169 if (is_nacl_nonsfi) { | |
170 if (target_cpu == "x86" || target_cpu == "x64") { | |
171 arch = "x86-32-nonsfi" | |
172 } else if (target_cpu == "arm") { | |
173 arch = "arm-nonsfi" | |
174 } | |
175 } else { | |
176 # TODO(phosek): remove the following once change 1360243003 is rolled | |
177 # into Chrome and use $target_cpu directly. | |
178 if (target_cpu == "x86") { | |
179 arch = "i686" | |
180 } else if (target_cpu == "x64") { | |
181 arch = "x86-64" | |
182 } else if (target_cpu == "arm") { | |
183 arch = "armv7" | |
184 } | |
185 } | |
186 | |
187 # The pre-translated object file has to be linked with an IRT shim to | |
188 # get a runnable nexe. This is handled by pnacl-translate, which passes | |
189 # -l:libpnacl_irt_shim.a to native linker, and we need to ensure the | |
190 # linker can find the correct library. | |
191 if (is_nacl_nonsfi) { | |
192 pnacl_irt_shim = "//ppapi/native_client/src/untrusted/pnacl_irt_shim:aot (//build/toolchain/nacl:newlib_pnacl_nonsfi)" | |
193 } else { | |
194 pnacl_irt_shim = "//ppapi/native_client/src/untrusted/pnacl_irt_shim:aot (//build/toolchain/nacl:clang_newlib_${target_cpu})" | |
195 } | |
196 | |
197 args = [ | |
198 "pnacl-translate", | |
199 rebase_path(pexe, root_build_dir), | |
200 "-o", | |
201 rebase_path(nexe, root_build_dir), | |
202 "-arch", | |
203 arch, | |
204 "-Wl,-L" + | |
205 rebase_path(get_label_info(pnacl_irt_shim, "target_out_dir")), | |
206 ] | |
207 deps = [ | |
208 ":$nexe_target_name(//build/toolchain/nacl:newlib_pnacl)", | |
209 ] | |
210 data_deps = [ | |
211 pnacl_irt_shim, | |
212 ] | |
213 } | 269 } |
214 } | 270 } |
215 | 271 |
216 copy(nexe_copy_target_name) { | 272 copy(nexe_copy_target_name) { |
217 visibility = [ ":$final_target_name" ] | 273 visibility = [ ":$final_target_name" ] |
218 if (generate_nmf) { | 274 if (generate_nmf) { |
219 visibility += [ ":$nmf_target_name" ] | 275 visibility += [ ":$nmf_target_name" ] |
220 } | 276 } |
221 if (current_cpu == "pnacl") { | 277 if (current_cpu == "pnacl") { |
222 if (pretranslate_pexe) { | 278 if (pretranslate_pexe) { |
223 sources = get_target_outputs(":${pexe_translate_target_name}") | 279 sources = get_target_outputs(":${pexe_translate_target_name}") |
280 if (defined(extra_tc_cpu)) { | |
281 sources += get_target_outputs(":${extra_pexe_translate_target_name}") | |
282 } | |
224 } else if (defined(invoker.nonstable_pexe) && invoker.nonstable_pexe) { | 283 } else if (defined(invoker.nonstable_pexe) && invoker.nonstable_pexe) { |
225 sources = [ | 284 sources = [ |
226 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", | 285 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", |
227 ] | 286 ] |
228 } else { | 287 } else { |
229 sources = [ | 288 sources = [ |
230 "${root_out_dir}/${suffixed_output_name}.pexe", | 289 "${root_out_dir}/${suffixed_output_name}.pexe", |
231 ] | 290 ] |
232 } | 291 } |
233 } else { | 292 } else { |
234 sources = [ | 293 sources = [ |
235 "${root_out_dir}/${suffixed_output_name}.nexe", | 294 "${root_out_dir}/${suffixed_output_name}.nexe", |
236 ] | 295 ] |
296 if (defined(extra_nmf_cpu)) { | |
297 extra_root_out_dir = | |
298 get_label_info(":${nexe_target_name}(${extra_toolchain})", | |
299 "root_out_dir") | |
300 sources += | |
301 [ "${extra_root_out_dir}/${extra_suffixed_output_name}.nexe" ] | |
302 } | |
237 } | 303 } |
238 outputs = [ | 304 outputs = [ |
239 "${target_dir}/{{source_file_part}}", | 305 "${target_dir}/{{source_file_part}}", |
240 ] | 306 ] |
241 if (current_cpu == "pnacl" && pretranslate_pexe) { | 307 if (current_cpu == "pnacl" && pretranslate_pexe) { |
242 deps = [ | 308 deps = [ |
243 ":$pexe_translate_target_name", | 309 ":$pexe_translate_target_name", |
244 ] | 310 ] |
311 if (defined(extra_tc_cpu)) { | |
312 deps += [ ":$extra_pexe_translate_target_name" ] | |
313 } | |
245 } else { | 314 } else { |
246 deps = [ | 315 deps = [ |
247 ":$nexe_target_name", | 316 ":$nexe_target_name", |
248 ] | 317 ] |
318 if (defined(extra_nmf_cpu)) { | |
319 deps += [ ":${nexe_target_name}(${extra_toolchain})" ] | |
320 } | |
249 } | 321 } |
250 } | 322 } |
251 | 323 |
252 if (current_cpu == "pnacl" && !is_nacl_nonsfi) { | 324 if (current_cpu == "pnacl" && !is_nacl_nonsfi) { |
253 if (defined(invoker.debug_pexe) && invoker.debug_pexe) { | 325 if (defined(invoker.debug_pexe) && invoker.debug_pexe) { |
254 copy(pexe_copy_debug_target_name) { | 326 copy(pexe_copy_debug_target_name) { |
255 visibility = [ ":$final_target_name" ] | 327 visibility = [ ":$final_target_name" ] |
256 sources = [ | 328 sources = [ |
257 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", | 329 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", |
258 ] | 330 ] |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 } | 387 } |
316 } | 388 } |
317 if (generate_nmf) { | 389 if (generate_nmf) { |
318 data_deps += [ ":$nmf_target_name" ] | 390 data_deps += [ ":$nmf_target_name" ] |
319 } | 391 } |
320 if (defined(invoker.test_files)) { | 392 if (defined(invoker.test_files)) { |
321 data_deps += [ ":$test_files_target_name" ] | 393 data_deps += [ ":$test_files_target_name" ] |
322 } | 394 } |
323 } | 395 } |
324 } | 396 } |
OLD | NEW |