# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//components/nacl/features.gni")
import("//components/nacl/target_cpu.gni")
assert(enable_nacl)
# This target copies files from the prebuilt/DEPS'ed in pnacl_translator
# toolchain and copies the latest PNaCl IRT shim library.
# We could use 'copies', but we want to rename the files in a white-listed
# way first. Thus use an action.
action("pnacl_support_extension") {
script = "pnacl_component_crx_gen.py"
inputs = [
"//native_client/build/package_version/package_version.py",
"//native_client/pnacl/driver/pnacl_info_template.json",
"//native_client/toolchain_revisions/pnacl_translator.json",
]
shim_target_label =
"//ppapi/native_client/src/untrusted/pnacl_irt_shim:browser"
src_shim_name = "libpnacl_irt_shim_browser.a"
desired_shim_name = "libpnacl_irt_shim.a"
# Use the IRT toolchain to build the shim. We want similar properties
# (x86-64 sandbox base address hiding). One thing we don't want is the
# IRT's secondary TLS, but that is handled by tls_edit and not compiler
# flags (so IRT compiler flags should be fine).
shim_toolchain_base = "//build/toolchain/nacl:irt_"
shim_target_tc_label =
"$shim_target_label($shim_toolchain_base$nacl_target_cpu)"
deps = [ shim_target_tc_label ]
shim_cpu = nacl_target_cpu
output_prefix = "$root_out_dir/pnacl/pnacl_public_"
outputs = [ "${output_prefix}pnacl_json" ]
# Files that will be copied from the toolchain to output.
outputs_from_toolchain = [
"crtbegin_o",
"crtend_o",
"ld_nexe",
"libcrt_platform_a",
"libgcc_a",
"libpnacl_irt_shim_a",
"pnacl_llc_nexe",
"pnacl_sz_nexe",
]
if (nacl_target_cpu == "arm") {
output_cpu = "arm"
} else if (nacl_target_cpu == "mipsel") {
output_cpu = "mips32"
} else if (nacl_target_cpu == "x64") {
output_cpu = "x86_64"
} else if (nacl_target_cpu == "x86") {
output_cpu = "x86_32"
} else {
assert(false, "unhandled nacl_target_cpu")
}
foreach(output_elem, outputs_from_toolchain) {
outputs += [ output_prefix + output_cpu + "_" + output_elem ]
}
shim_lib_path =
rebase_path(get_label_info(shim_target_tc_label, "target_out_dir") +
"/$src_shim_name",
root_build_dir)
# This describes the irt shim library for the main architecture.
# On Windows x86, another switch will be added to this below.
lib_overrides = [
"--lib_override",
"$shim_cpu,$shim_lib_path,$desired_shim_name",
]
if (is_win && target_cpu == "x86") {
# On Windows, for offline testing (i.e., without component updater
# selecting the platform-specific files with multi-CRXes), we need
# to stage both x86-32 and x86-64 (because 32-bit chrome on 64-bit
# windows will need 64-bit nexes).
shim_target_tc_label = "$shim_target_label(${shim_toolchain_base}x64)"
shim_cpu = "x64"
shim_lib_path =
rebase_path(get_label_info(shim_target_tc_label, "target_out_dir") +
"/$src_shim_name",
root_build_dir)
# Pass a second --lib_override for the second architecture.
lib_overrides += [
"--lib_override",
"$shim_cpu,$shim_lib_path,$desired_shim_name",
]
deps += [ shim_target_tc_label ]
foreach(output_elem, outputs_from_toolchain) {
outputs += [ output_prefix + "x86_64_" + output_elem ]
}
}
if (current_os == "chromeos") {
toolchain_os = "linux"
} else {
toolchain_os = current_os
}
args = lib_overrides
args += [
"--dest",
rebase_path("$root_out_dir/pnacl", root_build_dir),
"--target_arch",
nacl_target_cpu,
"--info_template_path",
rebase_path("//native_client/pnacl/driver/pnacl_info_template.json",
root_build_dir),
"--pnacl_translator_path",
rebase_path(
"//native_client/toolchain/${toolchain_os}_x86/pnacl_translator",
root_build_dir),
"--package_version_path",
rebase_path("//native_client/build/package_version/package_version.py",
root_build_dir),
"--pnacl_package_name",
"pnacl_translator",
# ABI Version Number
"1",
]
}