Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ppapi / native_client / src / untrusted / pnacl_support_extension / BUILD.gn
bloba502f98bada4497f7bbdab0b4fa237ddffc05e7e
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   # This target copies files from the prebuilt/DEPS'ed in pnacl_translator
9   # toolchain and copies the latest PNaCl IRT shim library.
10   # We could use 'copies', but we want to rename the files in a white-listed
11   # way first.  Thus use an action.
12   action("pnacl_support_extension") {
13     script = "pnacl_component_crx_gen.py"
14     inputs = [
15       "//native_client/build/package_version/package_version.py",
16       "//native_client/pnacl/driver/pnacl_info_template.json",
17       "//native_client/toolchain_revisions/pnacl_translator.json",
18     ]
19     shim_target_label =
20         "//ppapi/native_client/src/untrusted/pnacl_irt_shim:browser"
21     src_shim_name = "libpnacl_irt_shim_browser.a"
22     desired_shim_name = "libpnacl_irt_shim.a"
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 = "//build/toolchain/nacl:irt_"
30     shim_target_tc_label = "$shim_target_label($shim_toolchain_base$target_cpu)"
31     deps = [
32       shim_target_tc_label,
33     ]
34     shim_lib_path =
35         rebase_path(get_label_info(shim_target_tc_label, "target_out_dir") +
36                         "/$src_shim_name",
37                     root_build_dir)
38     shim_override_args = [
39       "--lib_override",
40       "$target_cpu,$shim_lib_path,$desired_shim_name",
41     ]
43     output_prefix = "$root_out_dir/pnacl/pnacl_public_"
44     outputs = [
45       "${output_prefix}pnacl_json",
46     ]
48     # Files that will be copied from the toolchain to output.
49     outputs_from_toolchain = [
50       "crtbegin_o",
51       "crtend_o",
52       "ld_nexe",
53       "libcrt_platform_a",
54       "libgcc_a",
55       "libpnacl_irt_shim_a",
56       "pnacl_llc_nexe",
57     ]
58     if (target_cpu == "arm") {
59       foreach(output_elem, outputs_from_toolchain) {
60         outputs += [ output_prefix + "arm_" + output_elem ]
61       }
62     } else if (target_cpu == "mipsel") {
63       foreach(output_elem, outputs_from_toolchain) {
64         outputs += [ output_prefix + "mips32_" + output_elem ]
65       }
66     } else if (target_cpu == "x86") {
67       foreach(output_elem, outputs_from_toolchain) {
68         outputs += [ output_prefix + "x86_32_" + output_elem ]
69       }
71       # On Windows, for offline testing (i.e., without component updater
72       # selecting the platform-specific files with multi-CRXes), we need
73       # to stage both x86-32 and x86-64 (because 32-bit chrome on 64-bit
74       # windows will need 64-bit nexes).
75       if (is_win) {
76         foreach(output_elem, outputs_from_toolchain) {
77           outputs += [ output_prefix + "x86_64_" + output_elem ]
78         }
79         shim_target_tc_x64_label =
80             "$shim_target_label(${shim_toolchain_base}x64)"
81         deps += [ shim_target_tc_x64_label ]
82         shim_lib_x64_path =
83             rebase_path(get_label_info(shim_target_tc_x64_label,
84                                        "target_out_dir") + "/$src_shim_name",
85                         root_build_dir)
86         shim_override_args = [
87           "--lib_override",
88           "x64,$shim_lib_x64_path,$desired_shim_name",
89         ]
90       }
91     } else if (target_cpu == "x64") {
92       foreach(output_elem, outputs_from_toolchain) {
93         outputs += [ output_prefix + "x86_64_" + output_elem ]
94       }
95     } else {
96       assert(false, "unhandled target_cpu")
97     }
98     args = [
99       "--dest",
100       rebase_path("$root_out_dir/pnacl", root_build_dir),
101     ]
102     args += shim_override_args
104     args += [
105       "--target_arch",
106       target_cpu,
107       "--info_template_path",
108       rebase_path("//native_client/pnacl/driver/pnacl_info_template.json",
109                   root_build_dir),
110       "--pnacl_translator_path",
111       rebase_path(
112           "//native_client/toolchain/${current_os}_x86/pnacl_translator",
113           root_build_dir),
114       "--package_version_path",
115       rebase_path("//native_client/build/package_version/package_version.py",
116                   root_build_dir),
117       "--pnacl_package_name",
118       "pnacl_translator",
120       # ABI Version Number
121       "1",
122     ]
123   }