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") { |
| 183 action(target_name) { |
| 184 translate_cpu = invoker.translate_cpu |
141 | 185 |
142 # We specify the toolchain explicitly because in the Non-SFI case, we | 186 visibility = [ ":$nexe_copy_target_name" ] |
143 # still want to use the pexe built using the newlib_pnacl toolchain. | |
144 tests = ":ppapi_nacl_tests_nexe(//build/toolchain/nacl:newlib_pnacl)" | |
145 | 187 |
146 pexe = get_label_info(tests, "root_out_dir") + | 188 # We specify the toolchain explicitly because in the Non-SFI case, we |
147 "/${suffixed_output_name}.pexe" | 189 # still want to use the pexe built using the newlib_pnacl toolchain. |
148 if (target_cpu == "x86" || | 190 tests = ":ppapi_nacl_tests_nexe(//build/toolchain/nacl:newlib_pnacl)" |
149 (is_nacl_nonsfi && (target_cpu == "x86" || target_cpu == "x64"))) { | 191 |
150 nmf_cpu = "x32" | 192 pexe = get_label_info(tests, "root_out_dir") + |
151 } else { | 193 "/${suffixed_output_name}.pexe" |
152 nmf_cpu = target_cpu | 194 if (translate_cpu == "x86" || |
| 195 (is_nacl_nonsfi && |
| 196 (translate_cpu == "x86" || translate_cpu == "x64"))) { |
| 197 nmf_cpu = "x32" |
| 198 } else { |
| 199 nmf_cpu = translate_cpu |
| 200 } |
| 201 if (is_nacl_nonsfi) { |
| 202 suffix = "pnacl_newlib_${nmf_cpu}_nonsfi" |
| 203 } else { |
| 204 suffix = "pnacl_newlib_${nmf_cpu}" |
| 205 } |
| 206 nexe = "${root_out_dir}/${output_name}_${suffix}.nexe" |
| 207 |
| 208 script = "${nacl_toolchain_bindir}/pydir/loader.py" |
| 209 sources = [ |
| 210 pexe, |
| 211 ] |
| 212 outputs = [ |
| 213 nexe, |
| 214 ] |
| 215 |
| 216 if (is_nacl_nonsfi) { |
| 217 if (translate_cpu == "x86" || translate_cpu == "x64") { |
| 218 arch = "x86-32-nonsfi" |
| 219 } else if (translate_cpu == "arm") { |
| 220 arch = "arm-nonsfi" |
| 221 } |
| 222 } else { |
| 223 # TODO(phosek): remove the following once change 1360243003 is rolled |
| 224 # into Chrome and use translate_cpu directly. |
| 225 if (translate_cpu == "x86") { |
| 226 arch = "i686" |
| 227 } else if (translate_cpu == "x64") { |
| 228 arch = "x86-64" |
| 229 } else if (translate_cpu == "arm") { |
| 230 arch = "armv7" |
| 231 } |
| 232 } |
| 233 |
| 234 # The pre-translated object file has to be linked with an IRT shim to |
| 235 # get a runnable nexe. This is handled by pnacl-translate, which passes |
| 236 # -l:libpnacl_irt_shim.a to native linker, and we need to ensure the |
| 237 # linker can find the correct library. |
| 238 if (is_nacl_nonsfi) { |
| 239 pnacl_irt_shim = "//ppapi/native_client/src/untrusted/pnacl_irt_shim:a
ot(//build/toolchain/nacl:newlib_pnacl_nonsfi)" |
| 240 } else { |
| 241 pnacl_irt_shim = "//ppapi/native_client/src/untrusted/pnacl_irt_shim:a
ot(//build/toolchain/nacl:clang_newlib_${translate_cpu})" |
| 242 } |
| 243 |
| 244 args = [ |
| 245 "pnacl-translate", |
| 246 rebase_path(pexe, root_build_dir), |
| 247 "-o", |
| 248 rebase_path(nexe, root_build_dir), |
| 249 "-arch", |
| 250 arch, |
| 251 "-Wl,-L" + |
| 252 rebase_path(get_label_info(pnacl_irt_shim, "target_out_dir")), |
| 253 ] |
| 254 deps = [ |
| 255 ":$nexe_target_name(//build/toolchain/nacl:newlib_pnacl)", |
| 256 ] |
| 257 data_deps = [ |
| 258 pnacl_irt_shim, |
| 259 ] |
153 } | 260 } |
154 if (is_nacl_nonsfi) { | 261 } |
155 suffix = "pnacl_newlib_${nmf_cpu}_nonsfi" | 262 |
156 } else { | 263 nacl_test_data_pretranslate_pexe(pexe_translate_target_name) { |
157 suffix = "pnacl_newlib_${nmf_cpu}" | 264 translate_cpu = target_cpu |
| 265 } |
| 266 if (defined(extra_tc_cpu)) { |
| 267 nacl_test_data_pretranslate_pexe(extra_pexe_translate_target_name) { |
| 268 translate_cpu = extra_tc_cpu |
158 } | 269 } |
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 } | 270 } |
214 } | 271 } |
215 | 272 |
216 copy(nexe_copy_target_name) { | 273 copy(nexe_copy_target_name) { |
217 visibility = [ ":$final_target_name" ] | 274 visibility = [ ":$final_target_name" ] |
218 if (generate_nmf) { | 275 if (generate_nmf) { |
219 visibility += [ ":$nmf_target_name" ] | 276 visibility += [ ":$nmf_target_name" ] |
220 } | 277 } |
221 if (current_cpu == "pnacl") { | 278 if (current_cpu == "pnacl") { |
222 if (pretranslate_pexe) { | 279 if (pretranslate_pexe) { |
223 sources = get_target_outputs(":${pexe_translate_target_name}") | 280 sources = get_target_outputs(":${pexe_translate_target_name}") |
| 281 if (defined(extra_tc_cpu)) { |
| 282 sources += get_target_outputs(":${extra_pexe_translate_target_name}") |
| 283 } |
224 } else if (defined(invoker.nonstable_pexe) && invoker.nonstable_pexe) { | 284 } else if (defined(invoker.nonstable_pexe) && invoker.nonstable_pexe) { |
225 sources = [ | 285 sources = [ |
226 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", | 286 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", |
227 ] | 287 ] |
228 } else { | 288 } else { |
229 sources = [ | 289 sources = [ |
230 "${root_out_dir}/${suffixed_output_name}.pexe", | 290 "${root_out_dir}/${suffixed_output_name}.pexe", |
231 ] | 291 ] |
232 } | 292 } |
233 } else { | 293 } else { |
234 sources = [ | 294 sources = [ |
235 "${root_out_dir}/${suffixed_output_name}.nexe", | 295 "${root_out_dir}/${suffixed_output_name}.nexe", |
236 ] | 296 ] |
| 297 if (defined(extra_nmf_cpu)) { |
| 298 extra_root_out_dir = |
| 299 get_label_info(":${nexe_target_name}(${extra_toolchain})", |
| 300 "root_out_dir") |
| 301 sources += |
| 302 [ "${extra_root_out_dir}/${extra_suffixed_output_name}.nexe" ] |
| 303 } |
237 } | 304 } |
238 outputs = [ | 305 outputs = [ |
239 "${target_dir}/{{source_file_part}}", | 306 "${target_dir}/{{source_file_part}}", |
240 ] | 307 ] |
241 if (current_cpu == "pnacl" && pretranslate_pexe) { | 308 if (current_cpu == "pnacl" && pretranslate_pexe) { |
242 deps = [ | 309 deps = [ |
243 ":$pexe_translate_target_name", | 310 ":$pexe_translate_target_name", |
244 ] | 311 ] |
| 312 if (defined(extra_tc_cpu)) { |
| 313 deps += [ ":$extra_pexe_translate_target_name" ] |
| 314 } |
245 } else { | 315 } else { |
246 deps = [ | 316 deps = [ |
247 ":$nexe_target_name", | 317 ":$nexe_target_name", |
248 ] | 318 ] |
| 319 if (defined(extra_nmf_cpu)) { |
| 320 deps += [ ":${nexe_target_name}(${extra_toolchain})" ] |
| 321 } |
249 } | 322 } |
250 } | 323 } |
251 | 324 |
252 if (current_cpu == "pnacl" && !is_nacl_nonsfi) { | 325 if (current_cpu == "pnacl" && !is_nacl_nonsfi) { |
253 if (defined(invoker.debug_pexe) && invoker.debug_pexe) { | 326 if (defined(invoker.debug_pexe) && invoker.debug_pexe) { |
254 copy(pexe_copy_debug_target_name) { | 327 copy(pexe_copy_debug_target_name) { |
255 visibility = [ ":$final_target_name" ] | 328 visibility = [ ":$final_target_name" ] |
256 sources = [ | 329 sources = [ |
257 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", | 330 "${root_out_dir}/exe.unstripped/${suffixed_output_name}.pexe", |
258 ] | 331 ] |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 388 } |
316 } | 389 } |
317 if (generate_nmf) { | 390 if (generate_nmf) { |
318 data_deps += [ ":$nmf_target_name" ] | 391 data_deps += [ ":$nmf_target_name" ] |
319 } | 392 } |
320 if (defined(invoker.test_files)) { | 393 if (defined(invoker.test_files)) { |
321 data_deps += [ ":$test_files_target_name" ] | 394 data_deps += [ ":$test_files_target_name" ] |
322 } | 395 } |
323 } | 396 } |
324 } | 397 } |
OLD | NEW |