2015-09-22 02:28:32 +00:00
|
|
|
# Copyright 2015 the V8 project authors. All rights reserved.
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials provided
|
|
|
|
# with the distribution.
|
|
|
|
# * Neither the name of Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2016-07-15 22:32:55 +00:00
|
|
|
import("//build/config/v8_target_cpu.gni")
|
|
|
|
|
2016-05-20 06:57:45 +00:00
|
|
|
declare_args() {
|
2016-07-25 09:29:17 +00:00
|
|
|
# The v8 snapshot needs to be built by code that is compiled with a
|
|
|
|
# toolchain that matches the bit-width of the target CPU, but runs on
|
|
|
|
# the host.
|
2016-05-20 06:57:45 +00:00
|
|
|
v8_snapshot_toolchain = ""
|
|
|
|
}
|
2015-09-22 02:28:32 +00:00
|
|
|
|
2016-07-25 09:29:17 +00:00
|
|
|
# Try to infer the appropriate snapshot toolchain for the v8_current_cpu
|
|
|
|
# where possible.
|
|
|
|
#
|
|
|
|
# Assume that v8_target_cpu (and hence v8_current_cpu) has been validated
|
|
|
|
# as supported on the current host CPU and OS in v8_target_cpu.gni. The
|
|
|
|
# logic below is complicated enough without also needing to do input
|
|
|
|
# validation.
|
|
|
|
#
|
|
|
|
# There are test cases for this code posted as an attachment to
|
|
|
|
# https://crbug.com/625353.
|
|
|
|
#
|
|
|
|
# TODO(GYP): Currently only regular (non-cross) compiles, and cross-compiles
|
|
|
|
# from x64 hosts to Intel, ARM, or MIPS targets, are implemented. Add support
|
|
|
|
# for the other supported configurations.
|
|
|
|
|
2016-05-20 06:57:45 +00:00
|
|
|
if (v8_snapshot_toolchain == "") {
|
2016-07-25 09:29:17 +00:00
|
|
|
if (current_os == host_os && current_cpu == host_cpu) {
|
|
|
|
# This is not a cross-compile, so build the snapshot with the current
|
|
|
|
# toolchain.
|
|
|
|
v8_snapshot_toolchain = current_toolchain
|
|
|
|
} else if (current_os == host_os && current_cpu == "x86" &&
|
|
|
|
host_cpu == "x64") {
|
|
|
|
# This is an x64 -> x86 cross-compile, but x64 hosts can usually run x86
|
|
|
|
# binaries built for the same OS, so build the snapshot with the current
|
|
|
|
# toolchain here, too.
|
|
|
|
v8_snapshot_toolchain = current_toolchain
|
|
|
|
} else if (current_os == "win" && host_os == "mac" && is_clang) {
|
|
|
|
# This is a mac -> win cross-compile, which is only supported w/ clang.
|
|
|
|
v8_snapshot_toolchain = "//build/toolchain/mac:clang_${v8_current_cpu}"
|
|
|
|
} else if (host_cpu == "x64") {
|
|
|
|
# This is a cross-compile from an x64 host to either a non-Intel target
|
2016-08-23 14:04:06 +00:00
|
|
|
# cpu or a different target OS. Clang will always be used by default on the
|
|
|
|
# host, unless this is a ChromeOS build, in which case the same toolchain
|
|
|
|
# (Clang or GCC) will be used for target and host by default.
|
|
|
|
if (is_chromeos && !is_clang) {
|
2016-07-25 09:29:17 +00:00
|
|
|
_clang = ""
|
2016-08-23 14:04:06 +00:00
|
|
|
} else {
|
|
|
|
_clang = "clang_"
|
2016-07-22 13:21:10 +00:00
|
|
|
}
|
2016-05-20 06:57:45 +00:00
|
|
|
|
2016-07-25 09:29:17 +00:00
|
|
|
if (v8_current_cpu == "x64" || v8_current_cpu == "x86") {
|
|
|
|
_cpus = v8_current_cpu
|
|
|
|
} else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") {
|
|
|
|
_cpus = "x64_v8_${v8_current_cpu}"
|
|
|
|
} else if (v8_current_cpu == "arm" || v8_current_cpu == "mipsel") {
|
|
|
|
_cpus = "x86_v8_${v8_current_cpu}"
|
2016-07-22 13:21:10 +00:00
|
|
|
} else {
|
2016-07-25 09:29:17 +00:00
|
|
|
# This branch should not be reached; leave _cpus blank so the assert
|
|
|
|
# below will fail.
|
|
|
|
_cpus = ""
|
2016-07-22 13:21:10 +00:00
|
|
|
}
|
2016-07-15 22:32:55 +00:00
|
|
|
|
2016-07-25 09:29:17 +00:00
|
|
|
if (_cpus != "") {
|
|
|
|
v8_snapshot_toolchain = "//build/toolchain/${host_os}:${_clang}${_cpus}"
|
2016-07-15 22:32:55 +00:00
|
|
|
}
|
2015-09-22 02:28:32 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-25 09:29:17 +00:00
|
|
|
|
|
|
|
assert(v8_snapshot_toolchain != "",
|
|
|
|
"Do not know how to build a snapshot for $current_toolchain " +
|
2016-08-23 14:04:06 +00:00
|
|
|
"on $host_os $host_cpu")
|