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
3 # found in the LICENSE file.
5 import("//build/config/features.gni")
7 if (enable_nacl && enable_nacl_untrusted && enable_pnacl) {
8 # We could use 'copies', but we want to rename the files
9 # in a white-listed way first. Thus use an action.
10 action("pnacl_support_extension") {
11 script = "pnacl_component_crx_gen.py"
13 "//native_client/build/package_version/package_version.py",
14 "//native_client/pnacl/driver/pnacl_info_template.json",
15 "//native_client/toolchain_revisions/pnacl_translator.json",
17 shim_target_dir = "//ppapi/native_client/src/untrusted/pnacl_irt_shim/"
19 rebase_path(get_path_info(shim_target_dir, "out_dir"), root_build_dir)
20 src_shim_name = "libpnacl_irt_shim_browser.a"
21 desired_shim_name = "libpnacl_irt_shim.a"
22 shim_target_label = "$shim_target_dir:browser"
24 # Use the IRT toolchain to build the shim. We want similar properties
25 # (x86-64 sandbox base address hiding). One thing we don't want is the
26 # IRT's secondary TLS, but that is handled by tls_edit and not compiler
27 # flags (so IRT compiler flags should be fine).
28 shim_toolchain_base = "//native_client/build/toolchain/nacl:irt_"
29 shim_target_tc_label = "$shim_target_label($shim_toolchain_base$target_cpu)"
34 # Figure out the path of the shim library that we depend upon.
35 # TODO(jvoung): change this to:
36 # lib_path = rebase_path(
37 # get_label_info(shim_target_tc_label, "target_out_dir"),
39 # once https://crbug.com/524587 is fixed.
40 # For now, look up the root_out_dir and concatenate the out_dir on top
42 shim_toolchain_root_out =
43 get_label_info(shim_target_tc_label, "root_out_dir")
44 lib_path = rebase_path(
45 "$shim_toolchain_root_out/$shim_target_out_dir/$src_shim_name",
47 shim_override_args = [
49 "$target_cpu,$lib_path,$desired_shim_name",
52 output_prefix = "$root_out_dir/pnacl/pnacl_public_"
54 "${output_prefix}pnacl_json",
57 # Files that will be copied from the toolchain to output.
58 outputs_from_toolchain = [
64 "libpnacl_irt_shim_a",
67 if (target_cpu == "arm") {
68 foreach(output_elem, outputs_from_toolchain) {
69 outputs += [ output_prefix + "arm_" + output_elem ]
71 } else if (target_cpu == "mipsel") {
72 foreach(output_elem, outputs_from_toolchain) {
73 outputs += [ output_prefix + "mips32_" + output_elem ]
75 } else if (target_cpu == "x86") {
76 foreach(output_elem, outputs_from_toolchain) {
77 outputs += [ output_prefix + "x86_32_" + output_elem ]
80 # On Windows, for offline testing (i.e., without component updater
81 # selecting the platform-specific files with multi-CRXes), we need
82 # to stage both x86-32 and x86-64 (because 32-bit chrome on 64-bit
83 # windows will need 64-bit nexes).
85 foreach(output_elem, outputs_from_toolchain) {
86 outputs += [ output_prefix + "x86_64_" + output_elem ]
88 shim_target_tc_x64_label =
89 "$shim_target_label(${shim_toolchain_base}x64)"
90 deps += [ shim_target_tc_x64_label ]
92 # TODO(jvoung): change this to:
93 # lib_x64_path = rebase_path(
94 # get_label_info(shim_target_tc_x64_label, "target_out_dir"),
96 # once https://crbug.com/524587 is fixed.
97 # For now, look up the root_out_dir and concatenate the out_dir on top
99 shim_toolchain_x64_root_out =
100 get_label_info(shim_target_tc_x64_label, "root_out_dir")
101 lib_x64_path = rebase_path(
102 "$shim_toolchain_x64_root_out/$shim_target_out_dir/$src_shim_name",
104 shim_override_args = [
106 "x64,$lib_x64_path,$desired_shim_name",
109 } else if (target_cpu == "x64") {
110 foreach(output_elem, outputs_from_toolchain) {
111 outputs += [ output_prefix + "x86_64_" + output_elem ]
114 assert(false, "unhandled target_cpu")
118 rebase_path("$root_out_dir/pnacl", root_build_dir),
120 args += shim_override_args
125 "--info_template_path",
126 rebase_path("//native_client/pnacl/driver/pnacl_info_template.json",
128 "--pnacl_translator_path",
130 "//native_client/toolchain/${current_os}_x86/pnacl_translator",
132 "--package_version_path",
133 rebase_path("//native_client/build/package_version/package_version.py",
135 "--pnacl_package_name",