Merge V8 5.2.361.47 DO NOT MERGE
https://chromium.googlesource.com/v8/v8/+/5.2.361.47
FPIIM-449
Change-Id: Ibec421b85a9b88cb3a432ada642e469fe7e78346
(cherry picked from commit bcf72ee8e3b26f1d0726869c7ddb3921c68b09a8)
diff --git a/gypfiles/OWNERS b/gypfiles/OWNERS
new file mode 100644
index 0000000..0e56af3
--- /dev/null
+++ b/gypfiles/OWNERS
@@ -0,0 +1 @@
+machenbach@chromium.org
diff --git a/gypfiles/README.txt b/gypfiles/README.txt
new file mode 100644
index 0000000..5f242ad
--- /dev/null
+++ b/gypfiles/README.txt
@@ -0,0 +1,9 @@
+For build instructions, please refer to:
+
+https://code.google.com/p/v8/wiki/BuildingWithGYP
+
+TL;DR version on *nix:
+$ make dependencies # Only needed once.
+$ make ia32.release -j8
+$ make ia32.release.check # Optionally: run tests.
+
diff --git a/gypfiles/all.gyp b/gypfiles/all.gyp
new file mode 100644
index 0000000..ff1bea4
--- /dev/null
+++ b/gypfiles/all.gyp
@@ -0,0 +1,54 @@
+# Copyright 2011 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'All',
+ 'type': 'none',
+ 'dependencies': [
+ '../src/d8.gyp:d8',
+ ],
+ 'conditions': [
+ ['component!="shared_library"', {
+ 'dependencies': [
+ '../tools/parser-shell.gyp:parser-shell',
+ ],
+ }],
+ # These items don't compile for Android on Mac.
+ ['host_os!="mac" or OS!="android"', {
+ 'dependencies': [
+ '../samples/samples.gyp:*',
+ '../test/cctest/cctest.gyp:*',
+ '../test/fuzzer/fuzzer.gyp:*',
+ '../test/unittests/unittests.gyp:*',
+ ],
+ }],
+ ['test_isolation_mode != "noop"', {
+ 'dependencies': [
+ '../test/bot_default.gyp:*',
+ '../test/benchmarks/benchmarks.gyp:*',
+ '../test/default.gyp:*',
+ '../test/ignition.gyp:*',
+ '../test/intl/intl.gyp:*',
+ '../test/message/message.gyp:*',
+ '../test/mjsunit/mjsunit.gyp:*',
+ '../test/mozilla/mozilla.gyp:*',
+ '../test/optimize_for_size.gyp:*',
+ '../test/perf.gyp:*',
+ '../test/preparser/preparser.gyp:*',
+ '../test/simdjs/simdjs.gyp:*',
+ '../test/test262/test262.gyp:*',
+ '../test/webkit/webkit.gyp:*',
+ '../tools/check-static-initializers.gyp:*',
+ '../tools/gcmole/run_gcmole.gyp:*',
+ '../tools/jsfunfuzz/jsfunfuzz.gyp:*',
+ '../tools/run-deopt-fuzzer.gyp:*',
+ '../tools/run-valgrind.gyp:*',
+ ],
+ }],
+ ]
+ }
+ ]
+}
diff --git a/gypfiles/config/win/msvs_dependencies.isolate b/gypfiles/config/win/msvs_dependencies.isolate
new file mode 100644
index 0000000..ff92227
--- /dev/null
+++ b/gypfiles/config/win/msvs_dependencies.isolate
@@ -0,0 +1,77 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+ 'conditions': [
+ # Copy the VS runtime DLLs into the isolate so that they
+ # don't have to be preinstalled on the target machine.
+ #
+ # VS2013 runtimes
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and CONFIGURATION_NAME=="Debug"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp120d.dll',
+ '<(PRODUCT_DIR)/x64/msvcr120d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and CONFIGURATION_NAME=="Release"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp120.dll',
+ '<(PRODUCT_DIR)/x64/msvcr120.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp120d.dll',
+ '<(PRODUCT_DIR)/msvcr120d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp120.dll',
+ '<(PRODUCT_DIR)/msvcr120.dll',
+ ],
+ },
+ }],
+ # VS2015 runtimes
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and CONFIGURATION_NAME=="Debug"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp140d.dll',
+ '<(PRODUCT_DIR)/x64/vccorlib140d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and CONFIGURATION_NAME=="Release"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp140.dll',
+ '<(PRODUCT_DIR)/x64/vccorlib140.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp140d.dll',
+ '<(PRODUCT_DIR)/vccorlib140d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp140.dll',
+ '<(PRODUCT_DIR)/vccorlib140.dll',
+ ],
+ },
+ }],
+ ],
+}
\ No newline at end of file
diff --git a/gypfiles/coverage_wrapper.py b/gypfiles/coverage_wrapper.py
new file mode 100755
index 0000000..5b365d8
--- /dev/null
+++ b/gypfiles/coverage_wrapper.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright 2016 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# CC/CXX wrapper script that excludes certain file patterns from coverage
+# instrumentation.
+
+import re
+import subprocess
+import sys
+
+exclusions = [
+ 'buildtools',
+ 'src/third_party',
+ 'third_party',
+ 'test',
+ 'testing',
+]
+
+def remove_if_exists(string_list, item):
+ if item in string_list:
+ string_list.remove(item)
+
+args = sys.argv[1:]
+text = ' '.join(sys.argv[2:])
+for exclusion in exclusions:
+ if re.search(r'\-o obj/%s[^ ]*\.o' % exclusion, text):
+ remove_if_exists(args, '-fprofile-arcs')
+ remove_if_exists(args, '-ftest-coverage')
+ remove_if_exists(args, '-fsanitize-coverage=func')
+ remove_if_exists(args, '-fsanitize-coverage=bb')
+ remove_if_exists(args, '-fsanitize-coverage=edge')
+ break
+
+sys.exit(subprocess.check_call(args))
diff --git a/gypfiles/detect_v8_host_arch.py b/gypfiles/detect_v8_host_arch.py
new file mode 100644
index 0000000..89e8286
--- /dev/null
+++ b/gypfiles/detect_v8_host_arch.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+# Copyright 2014 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.
+
+"""Outputs host CPU architecture in format recognized by gyp."""
+
+import platform
+import re
+import sys
+
+
+def main():
+ print DoMain([])
+ return 0
+
+def DoMain(_):
+ """Hook to be called from gyp without starting a separate python
+ interpreter."""
+ host_arch = platform.machine()
+ host_system = platform.system();
+
+ # Convert machine type to format recognized by gyp.
+ if re.match(r'i.86', host_arch) or host_arch == 'i86pc':
+ host_arch = 'ia32'
+ elif host_arch in ['x86_64', 'amd64']:
+ host_arch = 'x64'
+ elif host_arch.startswith('arm'):
+ host_arch = 'arm'
+ elif host_arch == 'aarch64':
+ host_arch = 'arm64'
+ elif host_arch == 'mips64':
+ host_arch = 'mips64el'
+ elif host_arch.startswith('mips'):
+ host_arch = 'mipsel'
+
+ # Under AIX the value returned by platform.machine is not
+ # the best indicator of the host architecture
+ # AIX 6.1 which is the lowest level supported only provides
+ # a 64 bit kernel
+ if host_system == 'AIX':
+ host_arch = 'ppc64'
+
+ # platform.machine is based on running kernel. It's possible to use 64-bit
+ # kernel with 32-bit userland, e.g. to give linker slightly more memory.
+ # Distinguish between different userland bitness by querying
+ # the python binary.
+ if host_arch == 'x64' and platform.architecture()[0] == '32bit':
+ host_arch = 'ia32'
+
+ return host_arch
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/gypfiles/download_gold_plugin.py b/gypfiles/download_gold_plugin.py
new file mode 100755
index 0000000..b8131fd
--- /dev/null
+++ b/gypfiles/download_gold_plugin.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Script to download LLVM gold plugin from google storage."""
+
+import json
+import os
+import re
+import platform
+import shutil
+import subprocess
+import sys
+import zipfile
+
+# Bail out on windows and cygwin.
+if "win" in platform.system().lower():
+ # Python 2.7.6 hangs at the second path.insert command on windows. Works
+ # with python 2.7.8.
+ print "Gold plugin download not supported on windows."
+ sys.exit(0)
+
+SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
+CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
+sys.path.insert(0, os.path.join(CHROME_SRC, 'tools'))
+
+import find_depot_tools
+
+DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
+GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py')
+
+LLVM_BUILD_PATH = os.path.join(CHROME_SRC, 'third_party', 'llvm-build',
+ 'Release+Asserts')
+CLANG_UPDATE_PY = os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts',
+ 'update.py')
+CLANG_REVISION = os.popen(CLANG_UPDATE_PY + ' --print-revision').read().rstrip()
+
+CLANG_BUCKET = 'gs://chromium-browser-clang/Linux_x64'
+
+GOLD_PLUGIN_PATH = os.path.join(LLVM_BUILD_PATH, 'lib', 'LLVMgold.so')
+
+sys.path.insert(0, os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts'))
+
+import update
+
+def main():
+ if not re.search(r'cfi_vptr=1', os.environ.get('GYP_DEFINES', '')):
+ # Bailout if this is not a cfi build.
+ print 'Skipping gold plugin download for non-cfi build.'
+ return 0
+ if (os.path.exists(GOLD_PLUGIN_PATH) and
+ update.ReadStampFile().strip() == update.PACKAGE_VERSION):
+ # Bailout if clang is up-to-date. This requires the script to be run before
+ # the clang update step! I.e. afterwards clang would always be up-to-date.
+ print 'Skipping gold plugin download. File present and clang up to date.'
+ return 0
+
+ # Make sure this works on empty checkouts (i.e. clang not downloaded yet).
+ if not os.path.exists(LLVM_BUILD_PATH):
+ os.makedirs(LLVM_BUILD_PATH)
+
+ targz_name = 'llvmgold-%s.tgz' % CLANG_REVISION
+ remote_path = '%s/%s' % (CLANG_BUCKET, targz_name)
+
+ os.chdir(LLVM_BUILD_PATH)
+
+ # TODO(pcc): Fix gsutil.py cp url file < /dev/null 2>&0
+ # (currently aborts with exit code 1,
+ # https://github.com/GoogleCloudPlatform/gsutil/issues/289) or change the
+ # stdin->stderr redirect in update.py to do something else (crbug.com/494442).
+ subprocess.check_call(['python', GSUTIL_PATH,
+ 'cp', remote_path, targz_name],
+ stderr=open('/dev/null', 'w'))
+ subprocess.check_call(['tar', 'xzf', targz_name])
+ os.remove(targz_name)
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/gypfiles/features.gypi b/gypfiles/features.gypi
new file mode 100644
index 0000000..5a21a63
--- /dev/null
+++ b/gypfiles/features.gypi
@@ -0,0 +1,136 @@
+# Copyright 2013 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.
+
+# Compile time controlled V8 features.
+
+{
+ 'variables': {
+ 'v8_enable_disassembler%': 0,
+
+ 'v8_enable_gdbjit%': 0,
+
+ 'v8_object_print%': 0,
+
+ 'v8_enable_verify_heap%': 0,
+
+ 'v8_trace_maps%': 0,
+
+ # Enable the snapshot feature, for fast context creation.
+ # http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html
+ 'v8_use_snapshot%': 'true',
+
+ 'v8_enable_verify_predictable%': 0,
+
+ # With post mortem support enabled, metadata is embedded into libv8 that
+ # describes various parameters of the VM for use by debuggers. See
+ # tools/gen-postmortem-metadata.py for details.
+ 'v8_postmortem_support%': 'false',
+
+ # Interpreted regexp engine exists as platform-independent alternative
+ # based where the regular expression is compiled to a bytecode.
+ 'v8_interpreted_regexp%': 0,
+
+ # Enable ECMAScript Internationalization API. Enabling this feature will
+ # add a dependency on the ICU library.
+ 'v8_enable_i18n_support%': 1,
+
+ # Enable compiler warnings when using V8_DEPRECATED apis.
+ 'v8_deprecation_warnings%': 0,
+
+ # Enable compiler warnings when using V8_DEPRECATE_SOON apis.
+ 'v8_imminent_deprecation_warnings%': 0,
+
+ # Set to 1 to enable DCHECKs in release builds.
+ 'dcheck_always_on%': 0,
+
+ # Enable/disable JavaScript API accessors.
+ 'v8_js_accessors%': 0,
+ },
+ 'target_defaults': {
+ 'conditions': [
+ ['v8_enable_disassembler==1', {
+ 'defines': ['ENABLE_DISASSEMBLER',],
+ }],
+ ['v8_enable_gdbjit==1', {
+ 'defines': ['ENABLE_GDB_JIT_INTERFACE',],
+ }],
+ ['v8_object_print==1', {
+ 'defines': ['OBJECT_PRINT',],
+ }],
+ ['v8_enable_verify_heap==1', {
+ 'defines': ['VERIFY_HEAP',],
+ }],
+ ['v8_trace_maps==1', {
+ 'defines': ['TRACE_MAPS',],
+ }],
+ ['v8_enable_verify_predictable==1', {
+ 'defines': ['VERIFY_PREDICTABLE',],
+ }],
+ ['v8_interpreted_regexp==1', {
+ 'defines': ['V8_INTERPRETED_REGEXP',],
+ }],
+ ['v8_deprecation_warnings==1', {
+ 'defines': ['V8_DEPRECATION_WARNINGS',],
+ }],
+ ['v8_imminent_deprecation_warnings==1', {
+ 'defines': ['V8_IMMINENT_DEPRECATION_WARNINGS',],
+ }],
+ ['v8_enable_i18n_support==1', {
+ 'defines': ['V8_I18N_SUPPORT',],
+ }],
+ ['v8_use_snapshot=="true" and v8_use_external_startup_data==1', {
+ 'defines': ['V8_USE_EXTERNAL_STARTUP_DATA',],
+ }],
+ ['dcheck_always_on!=0', {
+ 'defines': ['DEBUG',],
+ }],
+ ], # conditions
+ 'configurations': {
+ 'DebugBaseCommon': {
+ 'abstract': 1,
+ 'variables': {
+ 'v8_enable_handle_zapping%': 1,
+ },
+ 'conditions': [
+ ['v8_enable_handle_zapping==1', {
+ 'defines': ['ENABLE_HANDLE_ZAPPING',],
+ }],
+ ],
+ }, # Debug
+ 'Release': {
+ 'variables': {
+ 'v8_enable_handle_zapping%': 0,
+ },
+ 'conditions': [
+ ['v8_enable_handle_zapping==1', {
+ 'defines': ['ENABLE_HANDLE_ZAPPING',],
+ }],
+ ], # conditions
+ }, # Release
+ }, # configurations
+ }, # target_defaults
+}
diff --git a/gypfiles/get_landmines.py b/gypfiles/get_landmines.py
new file mode 100755
index 0000000..2bbf7a6
--- /dev/null
+++ b/gypfiles/get_landmines.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+# Copyright 2014 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+This file emits the list of reasons why a particular build needs to be clobbered
+(or a list of 'landmines').
+"""
+
+import sys
+
+
+def main():
+ """
+ ALL LANDMINES ARE EMITTED FROM HERE.
+ """
+ print 'Need to clobber after ICU52 roll.'
+ print 'Landmines test.'
+ print 'Activating MSVS 2013.'
+ print 'Revert activation of MSVS 2013.'
+ print 'Activating MSVS 2013 again.'
+ print 'Clobber after ICU roll.'
+ print 'Moar clobbering...'
+ print 'Remove build/android.gypi'
+ print 'Cleanup after windows ninja switch attempt.'
+ print 'Switching to pinned msvs toolchain.'
+ print 'Clobbering to hopefully resolve problem with mksnapshot'
+ print 'Clobber after ICU roll.'
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/gypfiles/gyp_environment.py b/gypfiles/gyp_environment.py
new file mode 100644
index 0000000..7a4e622
--- /dev/null
+++ b/gypfiles/gyp_environment.py
@@ -0,0 +1,54 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Sets up various automatic gyp environment variables. These are used by
+gyp_v8 and landmines.py which run at different stages of runhooks. To
+make sure settings are consistent between them, all setup should happen here.
+"""
+
+import os
+import sys
+import vs_toolchain
+
+SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
+V8_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
+
+
+def apply_gyp_environment(file_path=None):
+ """
+ Reads in a *.gyp_env file and applies the valid keys to os.environ.
+ """
+ if not file_path or not os.path.exists(file_path):
+ return
+ file_contents = open(file_path).read()
+ try:
+ file_data = eval(file_contents, {'__builtins__': None}, None)
+ except SyntaxError, e:
+ e.filename = os.path.abspath(file_path)
+ raise
+ supported_vars = ( 'V8_GYP_FILE',
+ 'V8_GYP_SYNTAX_CHECK',
+ 'GYP_DEFINES',
+ 'GYP_GENERATOR_FLAGS',
+ 'GYP_GENERATOR_OUTPUT', )
+ for var in supported_vars:
+ val = file_data.get(var)
+ if val:
+ if var in os.environ:
+ print 'INFO: Environment value for "%s" overrides value in %s.' % (
+ var, os.path.abspath(file_path)
+ )
+ else:
+ os.environ[var] = val
+
+
+def set_environment():
+ """Sets defaults for GYP_* variables."""
+
+ if 'SKIP_V8_GYP_ENV' not in os.environ:
+ # Update the environment based on v8.gyp_env
+ gyp_env_path = os.path.join(os.path.dirname(V8_ROOT), 'v8.gyp_env')
+ apply_gyp_environment(gyp_env_path)
+ vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
diff --git a/gypfiles/gyp_v8 b/gypfiles/gyp_v8
new file mode 100755
index 0000000..e97507a
--- /dev/null
+++ b/gypfiles/gyp_v8
@@ -0,0 +1,181 @@
+#!/usr/bin/env python
+#
+# Copyright 2012 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.
+
+# This script is wrapper for V8 that adds some support for how GYP
+# is invoked by V8 beyond what can be done in the gclient hooks.
+
+import argparse
+import glob
+import gyp_environment
+import os
+import platform
+import shlex
+import subprocess
+import sys
+import vs_toolchain
+
+script_dir = os.path.dirname(os.path.realpath(__file__))
+v8_root = os.path.abspath(os.path.join(script_dir, os.pardir))
+
+sys.path.insert(0, os.path.join(v8_root, 'tools', 'gyp', 'pylib'))
+import gyp
+
+# Add paths so that pymod_do_main(...) can import files.
+sys.path.insert(
+ 1, os.path.abspath(os.path.join(v8_root, 'tools', 'generate_shim_headers')))
+
+
+def GetOutputDirectory():
+ """Returns the output directory that GYP will use."""
+
+ # Handle command line generator flags.
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-G', dest='genflags', default=[], action='append')
+ genflags = parser.parse_known_args()[0].genflags
+
+ # Handle generator flags from the environment.
+ genflags += shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', ''))
+
+ needle = 'output_dir='
+ for item in genflags:
+ if item.startswith(needle):
+ return item[len(needle):]
+
+ return 'out'
+
+
+def additional_include_files(args=[]):
+ """
+ Returns a list of additional (.gypi) files to include, without
+ duplicating ones that are already specified on the command line.
+ """
+ # Determine the include files specified on the command line.
+ # This doesn't cover all the different option formats you can use,
+ # but it's mainly intended to avoid duplicating flags on the automatic
+ # makefile regeneration which only uses this format.
+ specified_includes = set()
+ for arg in args:
+ if arg.startswith('-I') and len(arg) > 2:
+ specified_includes.add(os.path.realpath(arg[2:]))
+
+ result = []
+ def AddInclude(path):
+ if os.path.realpath(path) not in specified_includes:
+ result.append(path)
+
+ # Always include standalone.gypi
+ AddInclude(os.path.join(v8_root, 'gypfiles', 'standalone.gypi'))
+
+ # Optionally add supplemental .gypi files if present.
+ supplements = glob.glob(os.path.join(v8_root, '*', 'supplement.gypi'))
+ for supplement in supplements:
+ AddInclude(supplement)
+
+ return result
+
+
+def run_gyp(args):
+ rc = gyp.main(args)
+
+ vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
+ if vs2013_runtime_dll_dirs:
+ x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
+ vs_toolchain.CopyVsRuntimeDlls(
+ os.path.join(v8_root, GetOutputDirectory()),
+ (x86_runtime, x64_runtime))
+
+ if rc != 0:
+ print 'Error running GYP'
+ sys.exit(rc)
+
+
+if __name__ == '__main__':
+ args = sys.argv[1:]
+
+ gyp_environment.set_environment()
+
+ # This could give false positives since it doesn't actually do real option
+ # parsing. Oh well.
+ gyp_file_specified = False
+ for arg in args:
+ if arg.endswith('.gyp'):
+ gyp_file_specified = True
+ break
+
+ # If we didn't get a file, check an env var, and then fall back to
+ # assuming 'all.gyp' from the same directory as the script.
+ if not gyp_file_specified:
+ gyp_file = os.environ.get('V8_GYP_FILE')
+ if gyp_file:
+ # Note that V8_GYP_FILE values can't have backslashes as
+ # path separators even on Windows due to the use of shlex.split().
+ args.extend(shlex.split(gyp_file))
+ else:
+ args.append(os.path.join(script_dir, 'all.gyp'))
+
+ args.extend(['-I' + i for i in additional_include_files(args)])
+
+ # There shouldn't be a circular dependency relationship between .gyp files
+ args.append('--no-circular-check')
+
+ # Set the GYP DEPTH variable to the root of the V8 project.
+ args.append('--depth=' + os.path.relpath(v8_root))
+
+ # If V8_GYP_SYNTAX_CHECK is set to 1, it will invoke gyp with --check
+ # to enfore syntax checking.
+ syntax_check = os.environ.get('V8_GYP_SYNTAX_CHECK')
+ if syntax_check and int(syntax_check):
+ args.append('--check')
+
+ print 'Updating projects from gyp files...'
+ sys.stdout.flush()
+
+ # Generate for the architectures supported on the given platform.
+ gyp_args = list(args)
+ gyp_args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()])
+ gyp_generators = os.environ.get('GYP_GENERATORS', '')
+ if platform.system() == 'Linux' and gyp_generators != 'ninja':
+ # Work around for crbug.com/331475.
+ for f in glob.glob(os.path.join(v8_root, 'out', 'Makefile.*')):
+ os.unlink(f)
+ # --generator-output defines where the Makefile goes.
+ gyp_args.append('--generator-output=out')
+ # -Goutput_dir defines where the build output goes, relative to the
+ # Makefile. Set it to . so that the build output doesn't end up in out/out.
+ gyp_args.append('-Goutput_dir=.')
+
+ gyp_defines = os.environ.get('GYP_DEFINES', '')
+
+ # Automatically turn on crosscompile support for platforms that need it.
+ if all(('ninja' in gyp_generators,
+ 'OS=android' in gyp_defines,
+ 'GYP_CROSSCOMPILE' not in os.environ)):
+ os.environ['GYP_CROSSCOMPILE'] = '1'
+
+ run_gyp(gyp_args)
diff --git a/gypfiles/gyp_v8.py b/gypfiles/gyp_v8.py
new file mode 100644
index 0000000..462ee67
--- /dev/null
+++ b/gypfiles/gyp_v8.py
@@ -0,0 +1,41 @@
+# Copyright 2013 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.
+
+# This file is (possibly, depending on python version) imported by
+# gyp_v8 when GYP_PARALLEL=1 and it creates sub-processes through the
+# multiprocessing library.
+
+# Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for imports
+# that don't end in .py (and aren't directories with an __init__.py). This
+# wrapper makes "import gyp_v8" work with those old versions and makes it
+# possible to execute gyp_v8.py directly on Windows where the extension is
+# useful.
+
+import os
+
+path = os.path.abspath(os.path.split(__file__)[0])
+execfile(os.path.join(path, 'gyp_v8'))
diff --git a/gypfiles/has_valgrind.py b/gypfiles/has_valgrind.py
new file mode 100755
index 0000000..83a848d
--- /dev/null
+++ b/gypfiles/has_valgrind.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+# Copyright 2016 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+VALGRIND_DIR = os.path.join(BASE_DIR, 'third_party', 'valgrind')
+LINUX32_DIR = os.path.join(VALGRIND_DIR, 'linux_x86')
+LINUX64_DIR = os.path.join(VALGRIND_DIR, 'linux_x64')
+
+
+def DoMain(_):
+ """Hook to be called from gyp without starting a separate python
+ interpreter."""
+ return int(os.path.exists(LINUX32_DIR) and os.path.exists(LINUX64_DIR))
+
+
+if __name__ == '__main__':
+ print DoMain([])
diff --git a/gypfiles/isolate.gypi b/gypfiles/isolate.gypi
new file mode 100644
index 0000000..a9614b5
--- /dev/null
+++ b/gypfiles/isolate.gypi
@@ -0,0 +1,100 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file is meant to be included into a target to provide a rule
+# to "build" .isolate files into a .isolated file.
+#
+# To use this, create a gyp target with the following form:
+# 'conditions': [
+# ['test_isolation_mode != "noop"', {
+# 'targets': [
+# {
+# 'target_name': 'foo_test_run',
+# 'type': 'none',
+# 'dependencies': [
+# 'foo_test',
+# ],
+# 'includes': [
+# '../gypfiles/isolate.gypi',
+# ],
+# 'sources': [
+# 'foo_test.isolate',
+# ],
+# },
+# ],
+# }],
+# ],
+#
+# Note: foo_test.isolate is included and a source file. It is an inherent
+# property of the .isolate format. This permits to define GYP variables but is
+# a stricter format than GYP so isolate.py can read it.
+#
+# The generated .isolated file will be:
+# <(PRODUCT_DIR)/foo_test.isolated
+#
+# See http://dev.chromium.org/developers/testing/isolated-testing/for-swes
+# for more information.
+
+{
+ 'rules': [
+ {
+ 'rule_name': 'isolate',
+ 'extension': 'isolate',
+ 'inputs': [
+ # Files that are known to be involved in this step.
+ '<(DEPTH)/tools/isolate_driver.py',
+ '<(DEPTH)/tools/swarming_client/isolate.py',
+ '<(DEPTH)/tools/swarming_client/run_isolated.py',
+ ],
+ 'outputs': [
+ '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
+ ],
+ 'action': [
+ 'python',
+ '<(DEPTH)/tools/isolate_driver.py',
+ '<(test_isolation_mode)',
+ '--isolated', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
+ '--isolate', '<(RULE_INPUT_PATH)',
+
+ # Variables should use the -V FOO=<(FOO) form so frequent values,
+ # like '0' or '1', aren't stripped out by GYP. Run 'isolate.py help'
+ # for more details.
+
+ # Path variables are used to replace file paths when loading a .isolate
+ # file
+ '--path-variable', 'DEPTH', '<(DEPTH)',
+ '--path-variable', 'PRODUCT_DIR', '<(PRODUCT_DIR)',
+
+ '--config-variable', 'CONFIGURATION_NAME=<(CONFIGURATION_NAME)',
+ '--config-variable', 'OS=<(OS)',
+ '--config-variable', 'asan=<(asan)',
+ '--config-variable', 'cfi_vptr=<(cfi_vptr)',
+ '--config-variable', 'gcmole=<(gcmole)',
+ '--config-variable', 'has_valgrind=<(has_valgrind)',
+ '--config-variable', 'icu_use_data_file_flag=0',
+ '--config-variable', 'msan=<(msan)',
+ '--config-variable', 'tsan=<(tsan)',
+ '--config-variable', 'coverage=<(coverage)',
+ '--config-variable', 'sanitizer_coverage=<(sanitizer_coverage)',
+ '--config-variable', 'component=<(component)',
+ '--config-variable', 'target_arch=<(target_arch)',
+ '--config-variable', 'use_custom_libcxx=<(use_custom_libcxx)',
+ '--config-variable', 'v8_use_external_startup_data=<(v8_use_external_startup_data)',
+ '--config-variable', 'v8_use_snapshot=<(v8_use_snapshot)',
+ ],
+ 'conditions': [
+ ['OS=="win"', {
+ 'action': [
+ '--config-variable', 'msvs_version=2013',
+ ],
+ }, {
+ 'action': [
+ '--config-variable', 'msvs_version=0',
+ ],
+ }],
+ ],
+ },
+ ],
+}
diff --git a/gypfiles/landmine_utils.py b/gypfiles/landmine_utils.py
new file mode 100644
index 0000000..cb34991
--- /dev/null
+++ b/gypfiles/landmine_utils.py
@@ -0,0 +1,123 @@
+# Copyright 2014 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+import functools
+import logging
+import os
+import shlex
+import sys
+
+
+def memoize(default=None):
+ """This decorator caches the return value of a parameterless pure function"""
+ def memoizer(func):
+ val = []
+ @functools.wraps(func)
+ def inner():
+ if not val:
+ ret = func()
+ val.append(ret if ret is not None else default)
+ if logging.getLogger().isEnabledFor(logging.INFO):
+ print '%s -> %r' % (func.__name__, val[0])
+ return val[0]
+ return inner
+ return memoizer
+
+
+@memoize()
+def IsWindows():
+ return sys.platform in ['win32', 'cygwin']
+
+
+@memoize()
+def IsLinux():
+ return sys.platform.startswith(('linux', 'freebsd'))
+
+
+@memoize()
+def IsMac():
+ return sys.platform == 'darwin'
+
+
+@memoize()
+def gyp_defines():
+ """Parses and returns GYP_DEFINES env var as a dictionary."""
+ return dict(arg.split('=', 1)
+ for arg in shlex.split(os.environ.get('GYP_DEFINES', '')))
+
+
+@memoize()
+def gyp_generator_flags():
+ """Parses and returns GYP_GENERATOR_FLAGS env var as a dictionary."""
+ return dict(arg.split('=', 1)
+ for arg in shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', '')))
+
+
+@memoize()
+def gyp_msvs_version():
+ return os.environ.get('GYP_MSVS_VERSION', '')
+
+
+@memoize()
+def distributor():
+ """
+ Returns a string which is the distributed build engine in use (if any).
+ Possible values: 'goma', 'ib', ''
+ """
+ if 'goma' in gyp_defines():
+ return 'goma'
+ elif IsWindows():
+ if 'CHROME_HEADLESS' in os.environ:
+ return 'ib' # use (win and !goma and headless) as approximation of ib
+
+
+@memoize()
+def platform():
+ """
+ Returns a string representing the platform this build is targetted for.
+ Possible values: 'win', 'mac', 'linux', 'ios', 'android'
+ """
+ if 'OS' in gyp_defines():
+ if 'android' in gyp_defines()['OS']:
+ return 'android'
+ else:
+ return gyp_defines()['OS']
+ elif IsWindows():
+ return 'win'
+ elif IsLinux():
+ return 'linux'
+ else:
+ return 'mac'
+
+
+@memoize()
+def builder():
+ """
+ Returns a string representing the build engine (not compiler) to use.
+ Possible values: 'make', 'ninja', 'xcode', 'msvs', 'scons'
+ """
+ if 'GYP_GENERATORS' in os.environ:
+ # for simplicity, only support the first explicit generator
+ generator = os.environ['GYP_GENERATORS'].split(',')[0]
+ if generator.endswith('-android'):
+ return generator.split('-')[0]
+ elif generator.endswith('-ninja'):
+ return 'ninja'
+ else:
+ return generator
+ else:
+ if platform() == 'android':
+ # Good enough for now? Do any android bots use make?
+ return 'make'
+ elif platform() == 'ios':
+ return 'xcode'
+ elif IsWindows():
+ return 'msvs'
+ elif IsLinux():
+ return 'make'
+ elif IsMac():
+ return 'xcode'
+ else:
+ assert False, 'Don\'t know what builder we\'re using!'
diff --git a/gypfiles/landmines.py b/gypfiles/landmines.py
new file mode 100755
index 0000000..2a81c66
--- /dev/null
+++ b/gypfiles/landmines.py
@@ -0,0 +1,245 @@
+#!/usr/bin/env python
+# Copyright 2014 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+This script runs every build as the first hook (See DEPS). If it detects that
+the build should be clobbered, it will delete the contents of the build
+directory.
+
+A landmine is tripped when a builder checks out a different revision, and the
+diff between the new landmines and the old ones is non-null. At this point, the
+build is clobbered.
+"""
+
+import difflib
+import errno
+import gyp_environment
+import logging
+import optparse
+import os
+import re
+import shutil
+import sys
+import subprocess
+import time
+
+import landmine_utils
+
+
+SRC_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+
+
+def get_build_dir(build_tool, is_iphone=False):
+ """
+ Returns output directory absolute path dependent on build and targets.
+ Examples:
+ r'c:\b\build\slave\win\build\src\out'
+ '/mnt/data/b/build/slave/linux/build/src/out'
+ '/b/build/slave/ios_rel_device/build/src/xcodebuild'
+
+ Keep this function in sync with tools/build/scripts/slave/compile.py
+ """
+ ret = None
+ if build_tool == 'xcode':
+ ret = os.path.join(SRC_DIR, 'xcodebuild')
+ elif build_tool in ['make', 'ninja', 'ninja-ios']: # TODO: Remove ninja-ios.
+ if 'CHROMIUM_OUT_DIR' in os.environ:
+ output_dir = os.environ.get('CHROMIUM_OUT_DIR').strip()
+ if not output_dir:
+ raise Error('CHROMIUM_OUT_DIR environment variable is set but blank!')
+ else:
+ output_dir = landmine_utils.gyp_generator_flags().get('output_dir', 'out')
+ ret = os.path.join(SRC_DIR, output_dir)
+ elif build_tool in ['msvs', 'vs', 'ib']:
+ ret = os.path.join(SRC_DIR, 'build')
+ else:
+ raise NotImplementedError('Unexpected GYP_GENERATORS (%s)' % build_tool)
+ return os.path.abspath(ret)
+
+
+def extract_gn_build_commands(build_ninja_file):
+ """Extracts from a build.ninja the commands to run GN.
+
+ The commands to run GN are the gn rule and build.ninja build step at the
+ top of the build.ninja file. We want to keep these when deleting GN builds
+ since we want to preserve the command-line flags to GN.
+
+ On error, returns the empty string."""
+ result = ""
+ with open(build_ninja_file, 'r') as f:
+ # Read until the second blank line. The first thing GN writes to the file
+ # is the "rule gn" and the second is the section for "build build.ninja",
+ # separated by blank lines.
+ num_blank_lines = 0
+ while num_blank_lines < 2:
+ line = f.readline()
+ if len(line) == 0:
+ return '' # Unexpected EOF.
+ result += line
+ if line[0] == '\n':
+ num_blank_lines = num_blank_lines + 1
+ return result
+
+def delete_build_dir(build_dir):
+ # GN writes a build.ninja.d file. Note that not all GN builds have args.gn.
+ build_ninja_d_file = os.path.join(build_dir, 'build.ninja.d')
+ if not os.path.exists(build_ninja_d_file):
+ shutil.rmtree(build_dir)
+ return
+
+ # GN builds aren't automatically regenerated when you sync. To avoid
+ # messing with the GN workflow, erase everything but the args file, and
+ # write a dummy build.ninja file that will automatically rerun GN the next
+ # time Ninja is run.
+ build_ninja_file = os.path.join(build_dir, 'build.ninja')
+ build_commands = extract_gn_build_commands(build_ninja_file)
+
+ try:
+ gn_args_file = os.path.join(build_dir, 'args.gn')
+ with open(gn_args_file, 'r') as f:
+ args_contents = f.read()
+ except IOError:
+ args_contents = ''
+
+ shutil.rmtree(build_dir)
+
+ # Put back the args file (if any).
+ os.mkdir(build_dir)
+ if args_contents != '':
+ with open(gn_args_file, 'w') as f:
+ f.write(args_contents)
+
+ # Write the build.ninja file sufficiently to regenerate itself.
+ with open(os.path.join(build_dir, 'build.ninja'), 'w') as f:
+ if build_commands != '':
+ f.write(build_commands)
+ else:
+ # Couldn't parse the build.ninja file, write a default thing.
+ f.write('''rule gn
+command = gn -q gen //out/%s/
+description = Regenerating ninja files
+
+build build.ninja: gn
+generator = 1
+depfile = build.ninja.d
+''' % (os.path.split(build_dir)[1]))
+
+ # Write a .d file for the build which references a nonexistant file. This
+ # will make Ninja always mark the build as dirty.
+ with open(build_ninja_d_file, 'w') as f:
+ f.write('build.ninja: nonexistant_file.gn\n')
+
+
+def needs_clobber(landmines_path, new_landmines):
+ if os.path.exists(landmines_path):
+ with open(landmines_path, 'r') as f:
+ old_landmines = f.readlines()
+ if old_landmines != new_landmines:
+ old_date = time.ctime(os.stat(landmines_path).st_ctime)
+ diff = difflib.unified_diff(old_landmines, new_landmines,
+ fromfile='old_landmines', tofile='new_landmines',
+ fromfiledate=old_date, tofiledate=time.ctime(), n=0)
+ sys.stdout.write('Clobbering due to:\n')
+ sys.stdout.writelines(diff)
+ return True
+ else:
+ sys.stdout.write('Clobbering due to missing landmines file.\n')
+ return True
+ return False
+
+
+def clobber_if_necessary(new_landmines):
+ """Does the work of setting, planting, and triggering landmines."""
+ out_dir = get_build_dir(landmine_utils.builder())
+ landmines_path = os.path.normpath(os.path.join(out_dir, '..', '.landmines'))
+ try:
+ os.makedirs(out_dir)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ pass
+
+ if needs_clobber(landmines_path, new_landmines):
+ # Clobber contents of build directory but not directory itself: some
+ # checkouts have the build directory mounted.
+ for f in os.listdir(out_dir):
+ path = os.path.join(out_dir, f)
+ if os.path.basename(out_dir) == 'build':
+ # Only delete build directories and files for MSVS builds as the folder
+ # shares some checked out files and directories.
+ if (os.path.isdir(path) and
+ re.search(r'(?:[Rr]elease)|(?:[Dd]ebug)', f)):
+ delete_build_dir(path)
+ elif (os.path.isfile(path) and
+ (path.endswith('.sln') or
+ path.endswith('.vcxproj') or
+ path.endswith('.vcxproj.user'))):
+ os.unlink(path)
+ else:
+ if os.path.isfile(path):
+ os.unlink(path)
+ elif os.path.isdir(path):
+ delete_build_dir(path)
+ if os.path.basename(out_dir) == 'xcodebuild':
+ # Xcodebuild puts an additional project file structure into build,
+ # while the output folder is xcodebuild.
+ project_dir = os.path.join(SRC_DIR, 'build', 'all.xcodeproj')
+ if os.path.exists(project_dir) and os.path.isdir(project_dir):
+ delete_build_dir(project_dir)
+
+ # Save current set of landmines for next time.
+ with open(landmines_path, 'w') as f:
+ f.writelines(new_landmines)
+
+
+def process_options():
+ """Returns a list of landmine emitting scripts."""
+ parser = optparse.OptionParser()
+ parser.add_option(
+ '-s', '--landmine-scripts', action='append',
+ default=[os.path.join(SRC_DIR, 'gypfiles', 'get_landmines.py')],
+ help='Path to the script which emits landmines to stdout. The target '
+ 'is passed to this script via option -t. Note that an extra '
+ 'script can be specified via an env var EXTRA_LANDMINES_SCRIPT.')
+ parser.add_option('-v', '--verbose', action='store_true',
+ default=('LANDMINES_VERBOSE' in os.environ),
+ help=('Emit some extra debugging information (default off). This option '
+ 'is also enabled by the presence of a LANDMINES_VERBOSE environment '
+ 'variable.'))
+
+ options, args = parser.parse_args()
+
+ if args:
+ parser.error('Unknown arguments %s' % args)
+
+ logging.basicConfig(
+ level=logging.DEBUG if options.verbose else logging.ERROR)
+
+ extra_script = os.environ.get('EXTRA_LANDMINES_SCRIPT')
+ if extra_script:
+ return options.landmine_scripts + [extra_script]
+ else:
+ return options.landmine_scripts
+
+
+def main():
+ landmine_scripts = process_options()
+
+ if landmine_utils.builder() in ('dump_dependency_json', 'eclipse'):
+ return 0
+
+ gyp_environment.set_environment()
+
+ landmines = []
+ for s in landmine_scripts:
+ proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE)
+ output, _ = proc.communicate()
+ landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()])
+ clobber_if_necessary(landmines)
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/gypfiles/mac/asan.gyp b/gypfiles/mac/asan.gyp
new file mode 100644
index 0000000..3fc7f58
--- /dev/null
+++ b/gypfiles/mac/asan.gyp
@@ -0,0 +1,31 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'asan_dynamic_runtime',
+ 'toolsets': ['target', 'host'],
+ 'type': 'none',
+ 'variables': {
+ # Every target is going to depend on asan_dynamic_runtime, so allow
+ # this one to depend on itself.
+ 'prune_self_dependency': 1,
+ # Path is relative to this GYP file.
+ 'asan_rtl_mask_path':
+ '../../third_party/llvm-build/Release+Asserts/lib/clang/*/lib/darwin',
+ 'asan_osx_dynamic':
+ '<(asan_rtl_mask_path)/libclang_rt.asan_osx_dynamic.dylib',
+ },
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)',
+ 'files': [
+ '<!(/bin/ls <(asan_osx_dynamic))',
+ ],
+ },
+ ],
+ },
+ ],
+}
diff --git a/gypfiles/set_clang_warning_flags.gypi b/gypfiles/set_clang_warning_flags.gypi
new file mode 100644
index 0000000..63d5f14
--- /dev/null
+++ b/gypfiles/set_clang_warning_flags.gypi
@@ -0,0 +1,59 @@
+# Copyright 2016 the V8 project authors. All rights reserved.
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file is meant to be included to set clang-specific compiler flags.
+# To use this the following variable can be defined:
+# clang_warning_flags: list: Compiler flags to pass to clang.
+# clang_warning_flags_unset: list: Compiler flags to not pass to clang.
+#
+# Only use this in third-party code. In chromium_code, fix your code to not
+# warn instead!
+#
+# Note that the gypi file is included in target_defaults, so it does not need
+# to be explicitly included.
+#
+# Warning flags set by this will be used on all platforms. If you want to set
+# warning flags on only some platforms, you have to do so manually.
+#
+# To use this, create a gyp target with the following form:
+# {
+# 'target_name': 'my_target',
+# 'variables': {
+# 'clang_warning_flags': ['-Wno-awesome-warning'],
+# 'clang_warning_flags_unset': ['-Wpreviously-set-flag'],
+# }
+# }
+
+{
+ 'variables': {
+ 'clang_warning_flags_unset%': [], # Provide a default value.
+ },
+ 'conditions': [
+ ['clang==1', {
+ # This uses >@ instead of @< to also see clang_warning_flags set in
+ # targets directly, not just the clang_warning_flags in target_defaults.
+ 'cflags': [ '>@(clang_warning_flags)' ],
+ 'cflags!': [ '>@(clang_warning_flags_unset)' ],
+ 'xcode_settings': {
+ 'WARNING_CFLAGS': ['>@(clang_warning_flags)'],
+ 'WARNING_CFLAGS!': ['>@(clang_warning_flags_unset)'],
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'AdditionalOptions': [ '>@(clang_warning_flags)' ],
+ 'AdditionalOptions!': [ '>@(clang_warning_flags_unset)' ],
+ },
+ },
+ }],
+ ['clang==0 and host_clang==1', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'cflags': [ '>@(clang_warning_flags)' ],
+ 'cflags!': [ '>@(clang_warning_flags_unset)' ],
+ }],
+ ],
+ }],
+ ],
+}
diff --git a/gypfiles/shim_headers.gypi b/gypfiles/shim_headers.gypi
new file mode 100644
index 0000000..940211c
--- /dev/null
+++ b/gypfiles/shim_headers.gypi
@@ -0,0 +1,73 @@
+# Copyright 2013 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.
+
+# This file is meant to be included into a target to handle shim headers
+# in a consistent manner. To use this the following variables need to be
+# defined:
+# headers_root_path: string: path to directory containing headers
+# header_filenames: list: list of header file names
+
+{
+ 'variables': {
+ 'shim_headers_path': '<(SHARED_INTERMEDIATE_DIR)/shim_headers/<(_target_name)/<(_toolset)',
+ 'shim_generator_additional_args%': [],
+ },
+ 'include_dirs++': [
+ '<(shim_headers_path)',
+ ],
+ 'all_dependent_settings': {
+ 'include_dirs+++': [
+ '<(shim_headers_path)',
+ ],
+ },
+ 'actions': [
+ {
+ 'variables': {
+ 'generator_path': '<(DEPTH)/tools/generate_shim_headers/generate_shim_headers.py',
+ 'generator_args': [
+ '--headers-root', '<(headers_root_path)',
+ '--output-directory', '<(shim_headers_path)',
+ '<@(shim_generator_additional_args)',
+ '<@(header_filenames)',
+ ],
+ },
+ 'action_name': 'generate_<(_target_name)_shim_headers',
+ 'inputs': [
+ '<(generator_path)',
+ ],
+ 'outputs': [
+ '<!@pymod_do_main(generate_shim_headers <@(generator_args) --outputs)',
+ ],
+ 'action': ['python',
+ '<(generator_path)',
+ '<@(generator_args)',
+ '--generate',
+ ],
+ 'message': 'Generating <(_target_name) shim headers.',
+ },
+ ],
+}
diff --git a/gypfiles/standalone.gypi b/gypfiles/standalone.gypi
new file mode 100644
index 0000000..630c45e
--- /dev/null
+++ b/gypfiles/standalone.gypi
@@ -0,0 +1,1460 @@
+# Copyright 2012 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.
+
+# Definitions to be used when building stand-alone V8 binaries.
+
+{
+ # We need to include toolchain.gypi here for third-party sources that don't
+ # directly include it themselves.
+ 'includes': ['toolchain.gypi'],
+ 'variables': {
+ 'component%': 'static_library',
+ 'clang_xcode%': 0,
+ # Track where uninitialized memory originates from. From fastest to
+ # slowest: 0 - no tracking, 1 - track only the initial allocation site, 2
+ # - track the chain of stores leading from allocation site to use site.
+ 'msan_track_origins%': 2,
+ 'visibility%': 'hidden',
+ 'v8_enable_backtrace%': 0,
+ 'v8_enable_i18n_support%': 1,
+ 'v8_deprecation_warnings': 1,
+ 'v8_imminent_deprecation_warnings': 1,
+ 'msvs_multi_core_compile%': '1',
+ 'mac_deployment_target%': '10.7',
+ 'release_extra_cflags%': '',
+ 'variables': {
+ 'variables': {
+ 'variables': {
+ 'conditions': [
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
+ OS=="netbsd" or OS=="mac" or OS=="qnx" or OS=="aix"', {
+ # This handles the Unix platforms we generally deal with.
+ # Anything else gets passed through, which probably won't work
+ # very well; such hosts should pass an explicit target_arch
+ # to gyp.
+ 'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
+ }, {
+ # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
+ # OS!="netbsd" and OS!="mac" and OS!="aix"
+ 'host_arch%': 'ia32',
+ }],
+ ],
+ },
+ 'host_arch%': '<(host_arch)',
+ 'target_arch%': '<(host_arch)',
+ 'base_dir%': '<!(cd <(DEPTH) && python -c "import os; print os.getcwd()")',
+
+ # Instrument for code coverage and use coverage wrapper to exclude some
+ # files. Uses gcov if clang=0 is set explicitly. Otherwise,
+ # sanitizer_coverage must be set too.
+ 'coverage%': 0,
+ },
+ 'base_dir%': '<(base_dir)',
+ 'host_arch%': '<(host_arch)',
+ 'target_arch%': '<(target_arch)',
+ 'v8_target_arch%': '<(target_arch)',
+ 'coverage%': '<(coverage)',
+ 'asan%': 0,
+ 'lsan%': 0,
+ 'msan%': 0,
+ 'tsan%': 0,
+ # Enable coverage gathering instrumentation in sanitizer tools. This flag
+ # also controls coverage granularity (1 for function-level, 2 for
+ # block-level, 3 for edge-level).
+ 'sanitizer_coverage%': 0,
+ # Use libc++ (buildtools/third_party/libc++ and
+ # buildtools/third_party/libc++abi) instead of stdlibc++ as standard
+ # library. This is intended to be used for instrumented builds.
+ 'use_custom_libcxx%': 0,
+
+ 'clang_dir%': '<(base_dir)/third_party/llvm-build/Release+Asserts',
+
+ 'use_lto%': 0,
+
+ # Control Flow Integrity for virtual calls and casts.
+ # See http://clang.llvm.org/docs/ControlFlowIntegrity.html
+ 'cfi_vptr%': 0,
+ 'cfi_diag%': 0,
+
+ 'cfi_blacklist%': '<(base_dir)/tools/cfi/blacklist.txt',
+
+ # Set to 1 to enable fast builds.
+ # TODO(machenbach): Only configured for windows.
+ 'fastbuild%': 0,
+
+ # goma settings.
+ # 1 to use goma.
+ # If no gomadir is set, it uses the default gomadir.
+ 'use_goma%': 0,
+ 'gomadir%': '',
+
+ # Check if valgrind directories are present.
+ 'has_valgrind%': '<!pymod_do_main(has_valgrind)',
+
+ 'test_isolation_mode%': 'noop',
+
+ 'conditions': [
+ # Set default gomadir.
+ ['OS=="win"', {
+ 'gomadir': 'c:\\goma\\goma-win',
+ }, {
+ 'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
+ }],
+ ['host_arch!="ppc" and host_arch!="ppc64" and host_arch!="ppc64le" and host_arch!="s390" and host_arch!="s390x"', {
+ 'host_clang%': 1,
+ }, {
+ 'host_clang%': 0,
+ }],
+ # linux_use_bundled_gold: whether to use the gold linker binary checked
+ # into third_party/binutils. Force this off via GYP_DEFINES when you
+ # are using a custom toolchain and need to control -B in ldflags.
+ # Do not use 32-bit gold on 32-bit hosts as it runs out address space
+ # for component=static_library builds.
+ ['(OS=="linux" or OS=="android") and (target_arch=="x64" or target_arch=="arm" or (target_arch=="ia32" and host_arch=="x64"))', {
+ 'linux_use_bundled_gold%': 1,
+ }, {
+ 'linux_use_bundled_gold%': 0,
+ }],
+ ],
+ },
+ 'base_dir%': '<(base_dir)',
+ 'clang_dir%': '<(clang_dir)',
+ 'host_arch%': '<(host_arch)',
+ 'host_clang%': '<(host_clang)',
+ 'target_arch%': '<(target_arch)',
+ 'v8_target_arch%': '<(v8_target_arch)',
+ 'werror%': '-Werror',
+ 'use_goma%': '<(use_goma)',
+ 'gomadir%': '<(gomadir)',
+ 'asan%': '<(asan)',
+ 'lsan%': '<(lsan)',
+ 'msan%': '<(msan)',
+ 'tsan%': '<(tsan)',
+ 'sanitizer_coverage%': '<(sanitizer_coverage)',
+ 'use_custom_libcxx%': '<(use_custom_libcxx)',
+ 'linux_use_bundled_gold%': '<(linux_use_bundled_gold)',
+ 'use_lto%': '<(use_lto)',
+ 'cfi_vptr%': '<(cfi_vptr)',
+ 'cfi_diag%': '<(cfi_diag)',
+ 'cfi_blacklist%': '<(cfi_blacklist)',
+ 'test_isolation_mode%': '<(test_isolation_mode)',
+ 'fastbuild%': '<(fastbuild)',
+ 'coverage%': '<(coverage)',
+ 'has_valgrind%': '<(has_valgrind)',
+
+ # Add a simple extras solely for the purpose of the cctests
+ 'v8_extra_library_files': ['../test/cctest/test-extra.js'],
+ 'v8_experimental_extra_library_files': ['../test/cctest/test-experimental-extra.js'],
+
+ # .gyp files or targets should set v8_code to 1 if they build V8 specific
+ # code, as opposed to external code. This variable is used to control such
+ # things as the set of warnings to enable, and whether warnings are treated
+ # as errors.
+ 'v8_code%': 0,
+
+ # Speeds up Debug builds:
+ # 0 - Compiler optimizations off (debuggable) (default). This may
+ # be 5x slower than Release (or worse).
+ # 1 - Turn on optimizations and disable slow DCHECKs, but leave
+ # V8_ENABLE_CHECKS and most other assertions enabled. This may cause
+ # some v8 tests to fail in the Debug configuration. This roughly
+ # matches the performance of a Release build and can be used by
+ # embedders that need to build their own code as debug but don't want
+ # or need a debug version of V8. This should produce near-release
+ # speeds.
+ 'v8_optimized_debug%': 0,
+
+ # Use external files for startup data blobs:
+ # the JS builtins sources and the start snapshot.
+ # Embedders that don't use standalone.gypi will need to add
+ # their own default value.
+ 'v8_use_external_startup_data%': 1,
+
+ # Relative path to icu.gyp from this file.
+ 'icu_gyp_path': '../third_party/icu/icu.gyp',
+
+ 'conditions': [
+ ['(v8_target_arch=="arm" and host_arch!="arm") or \
+ (v8_target_arch=="arm64" and host_arch!="arm64") or \
+ (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
+ (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
+ (v8_target_arch=="x64" and host_arch!="x64") or \
+ (OS=="android" or OS=="qnx")', {
+ 'want_separate_host_toolset': 1,
+ }, {
+ 'want_separate_host_toolset': 0,
+ }],
+ ['OS == "win"', {
+ 'os_posix%': 0,
+ }, {
+ 'os_posix%': 1,
+ }],
+ ['OS=="win" and use_goma==1', {
+ # goma doesn't support pch yet.
+ 'chromium_win_pch': 0,
+ # goma doesn't support PDB yet.
+ 'fastbuild%': 1,
+ }],
+ ['((v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
+ (OS=="linux" or OS=="mac")) or (v8_target_arch=="ppc64" and OS=="linux")', {
+ 'v8_enable_gdbjit%': 1,
+ }, {
+ 'v8_enable_gdbjit%': 0,
+ }],
+ ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64") and \
+ (v8_target_arch!="x87" and v8_target_arch!="x32")', {
+ 'clang%': 1,
+ }, {
+ 'clang%': 0,
+ }],
+ ['asan==1 or lsan==1 or msan==1 or tsan==1', {
+ 'clang%': 1,
+ 'use_allocator%': 'none',
+ }],
+ ['asan==1 and OS=="linux"', {
+ 'use_custom_libcxx%': 1,
+ }],
+ ['tsan==1', {
+ 'use_custom_libcxx%': 1,
+ }],
+ ['msan==1', {
+ # Use a just-built, MSan-instrumented libc++ instead of the system-wide
+ # libstdc++. This is required to avoid false positive reports whenever
+ # the C++ standard library is used.
+ 'use_custom_libcxx%': 1,
+ }],
+ ['cfi_vptr==1', {
+ 'use_lto%': 1,
+ }],
+ ['OS=="android"', {
+ # Location of Android NDK.
+ 'variables': {
+ 'variables': {
+ # The Android toolchain needs to use the absolute path to the NDK
+ # because it is used at different levels in the GYP files.
+ 'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
+ 'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
+ 'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
+ 'os_folder_name%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/darwin/')",
+ },
+
+ # Copy conditionally-set variables out one scope.
+ 'android_ndk_root%': '<(android_ndk_root)',
+ 'host_os%': '<(host_os)',
+ 'os_folder_name%': '<(os_folder_name)',
+
+ 'conditions': [
+ ['target_arch == "ia32"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'x86',
+ 'android_target_platform%': '16',
+ 'arm_version%': 'default',
+ }],
+ ['target_arch == "x64"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/x86_64-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'x86_64',
+ 'android_target_platform%': '21',
+ 'arm_version%': 'default',
+ }],
+ ['target_arch=="arm"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'arm',
+ 'android_target_platform%': '16',
+ 'arm_version%': 7,
+ }],
+ ['target_arch == "arm64"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'arm64',
+ 'android_target_platform%': '21',
+ 'arm_version%': 'default',
+ }],
+ ['target_arch == "mipsel"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'mips',
+ 'android_target_platform%': '16',
+ 'arm_version%': 'default',
+ }],
+ ['target_arch == "mips64el"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'mips64',
+ 'android_target_platform%': '21',
+ 'arm_version%': 'default',
+ }],
+ ],
+ },
+
+ # Copy conditionally-set variables out one scope.
+ 'android_target_arch%': '<(android_target_arch)',
+ 'android_target_platform%': '<(android_target_platform)',
+ 'android_toolchain%': '<(android_toolchain)',
+ 'arm_version%': '<(arm_version)',
+ 'host_os%': '<(host_os)',
+
+ 'conditions': [
+ ['android_ndk_root==""', {
+ 'variables': {
+ 'android_sysroot': '<(android_toolchain)/sysroot/',
+ 'android_stl': '<(android_toolchain)/sources/cxx-stl/',
+ },
+ 'conditions': [
+ ['target_arch=="x64"', {
+ 'android_lib': '<(android_sysroot)/usr/lib64',
+ }, {
+ 'android_lib': '<(android_sysroot)/usr/lib',
+ }],
+ ],
+ 'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
+ 'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
+ 'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
+ 'android_support_include': '<(android_toolchain)/sources/android/support/include',
+ 'android_sysroot': '<(android_sysroot)',
+ }, {
+ 'variables': {
+ 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
+ 'android_stl': '<(android_ndk_root)/sources/cxx-stl/',
+ },
+ 'conditions': [
+ ['target_arch=="x64"', {
+ 'android_lib': '<(android_sysroot)/usr/lib64',
+ }, {
+ 'android_lib': '<(android_sysroot)/usr/lib',
+ }],
+ ],
+ 'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
+ 'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
+ 'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
+ 'android_support_include': '<(android_ndk_root)/sources/android/support/include',
+ 'android_sysroot': '<(android_sysroot)',
+ }],
+ ],
+ 'android_libcpp_library': 'c++_static',
+ }], # OS=="android"
+ ['host_clang==1', {
+ 'conditions':[
+ ['OS=="android"', {
+ 'host_ld': '<!(which ld)',
+ 'host_ranlib': '<!(which ranlib)',
+ }],
+ ],
+ 'host_cc': '<(clang_dir)/bin/clang',
+ 'host_cxx': '<(clang_dir)/bin/clang++',
+ }, {
+ 'host_cc': '<!(which gcc)',
+ 'host_cxx': '<!(which g++)',
+ }],
+ ],
+ # Default ARM variable settings.
+ 'arm_version%': 'default',
+ 'arm_fpu%': 'vfpv3',
+ 'arm_float_abi%': 'default',
+ 'arm_thumb': 'default',
+
+ # Default MIPS variable settings.
+ 'mips_arch_variant%': 'r2',
+ # Possible values fp32, fp64, fpxx.
+ # fp32 - 32 32-bit FPU registers are available, doubles are placed in
+ # register pairs.
+ # fp64 - 32 64-bit FPU registers are available.
+ # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
+ # detection
+ 'mips_fpu_mode%': 'fp32',
+
+ # Indicates if gcmole tools are downloaded by a hook.
+ 'gcmole%': 0,
+ },
+ 'target_defaults': {
+ 'variables': {
+ 'v8_code%': '<(v8_code)',
+ 'clang_warning_flags': [
+ # TODO(thakis): https://crbug.com/604888
+ '-Wno-undefined-var-template',
+ ],
+ 'conditions':[
+ ['OS=="android"', {
+ 'host_os%': '<(host_os)',
+ }],
+ ],
+ },
+ 'includes': [ 'set_clang_warning_flags.gypi', ],
+ 'default_configuration': 'Debug',
+ 'configurations': {
+ 'DebugBaseCommon': {
+ 'conditions': [
+ ['OS=="aix"', {
+ 'cflags': [ '-g', '-Og', '-gxcoff' ],
+ }, {
+ 'cflags': [ '-g', '-O0' ],
+ }],
+ ],
+ },
+ 'Optdebug': {
+ 'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
+ },
+ 'Debug': {
+ # Xcode insists on this empty entry.
+ },
+ 'Release': {
+ 'cflags+': ['<@(release_extra_cflags)'],
+ },
+ 'conditions': [
+ ['OS=="win"', {
+ 'Optdebug_x64': {
+ 'inherit_from': ['Optdebug'],
+ },
+ 'Debug_x64': {
+ 'inherit_from': ['Debug'],
+ },
+ 'Release_x64': {
+ 'inherit_from': ['Release'],
+ },
+ }],
+ ],
+ },
+ 'conditions':[
+ ['clang==0', {
+ 'cflags+': ['-Wno-sign-compare',],
+ }],
+ ['clang==1 or host_clang==1', {
+ # This is here so that all files get recompiled after a clang roll and
+ # when turning clang on or off.
+ # (defines are passed via the command line, and build systems rebuild
+ # things when their commandline changes). Nothing should ever read this
+ # define.
+ 'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
+ 'conditions': [
+ ['host_clang==1', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'cflags+': [
+ '-Wno-format-pedantic',
+ ],
+ }],
+ ],
+ }],
+ ['clang==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags+': [
+ '-Wno-format-pedantic',
+ ],
+ }],
+ ],
+ }],
+ ],
+ }],
+ ['clang==1 and target_arch=="ia32"', {
+ 'cflags': ['-mstack-alignment=16', '-mstackrealign'],
+ }],
+ ['fastbuild!=0', {
+ 'conditions': [
+ ['OS=="win" and fastbuild==1', {
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ # This tells the linker to generate .pdbs, so that
+ # we can get meaningful stack traces.
+ 'GenerateDebugInformation': 'true',
+ },
+ 'VCCLCompilerTool': {
+ # No debug info to be generated by compiler.
+ 'DebugInformationFormat': '0',
+ },
+ },
+ }],
+ ],
+ }], # fastbuild!=0
+ ],
+ 'target_conditions': [
+ ['v8_code == 0', {
+ 'defines!': [
+ 'DEBUG',
+ ],
+ 'conditions': [
+ ['os_posix == 1 and OS != "mac"', {
+ # We don't want to get warnings from third-party code,
+ # so remove any existing warning-enabling flags like -Wall.
+ 'cflags!': [
+ '-pedantic',
+ '-Wall',
+ '-Werror',
+ '-Wextra',
+ '-Wshorten-64-to-32',
+ ],
+ 'cflags+': [
+ # Clang considers the `register` keyword as deprecated, but
+ # ICU uses it all over the place.
+ '-Wno-deprecated-register',
+ # ICU uses its own deprecated functions.
+ '-Wno-deprecated-declarations',
+ # ICU prefers `a && b || c` over `(a && b) || c`.
+ '-Wno-logical-op-parentheses',
+ # ICU has some `unsigned < 0` checks.
+ '-Wno-tautological-compare',
+ # uresdata.c has switch(RES_GET_TYPE(x)) code. The
+ # RES_GET_TYPE macro returns an UResType enum, but some switch
+ # statement contains case values that aren't part of that
+ # enum (e.g. URES_TABLE32 which is in UResInternalType). This
+ # is on purpose.
+ '-Wno-switch',
+ ],
+ 'cflags_cc!': [
+ '-Wnon-virtual-dtor',
+ ],
+ }],
+ ['OS == "mac"', {
+ 'xcode_settings': {
+ 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
+ },
+ }],
+ ['OS == "win"', {
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'WarnAsError': 'false',
+ },
+ },
+ }],
+ ],
+ }],
+ ],
+ },
+ 'conditions': [
+ ['os_posix==1 and OS!="mac"', {
+ 'target_defaults': {
+ 'conditions': [
+ # Common options for AddressSanitizer, LeakSanitizer,
+ # ThreadSanitizer, MemorySanitizer and CFI builds.
+ ['asan==1 or lsan==1 or tsan==1 or msan==1 or cfi_vptr==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fno-omit-frame-pointer',
+ '-gline-tables-only',
+ ],
+ 'cflags!': [
+ '-fomit-frame-pointer',
+ ],
+ }],
+ ],
+ }],
+ ['asan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=address',
+ ],
+ 'ldflags': [
+ '-fsanitize=address',
+ ],
+ 'defines': [
+ 'ADDRESS_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['lsan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=leak',
+ ],
+ 'ldflags': [
+ '-fsanitize=leak',
+ ],
+ 'defines': [
+ 'LEAK_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['tsan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=thread',
+ ],
+ 'ldflags': [
+ '-fsanitize=thread',
+ ],
+ 'defines': [
+ 'THREAD_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['msan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=memory',
+ '-fsanitize-memory-track-origins=<(msan_track_origins)',
+ '-fPIC',
+ ],
+ 'ldflags': [
+ '-fsanitize=memory',
+ '-pie',
+ ],
+ 'defines': [
+ 'MEMORY_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['use_custom_libcxx==1', {
+ 'dependencies': [
+ '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy',
+ ],
+ }],
+ ['sanitizer_coverage!=0', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize-coverage=<(sanitizer_coverage)',
+ ],
+ 'defines': [
+ 'SANITIZER_COVERAGE',
+ ],
+ }],
+ ],
+ }],
+ ['linux_use_bundled_gold==1 and not (clang==0 and use_lto==1)', {
+ # Put our binutils, which contains gold in the search path. We pass
+ # the path to gold to the compiler. gyp leaves unspecified what the
+ # cwd is when running the compiler, so the normal gyp path-munging
+ # fails us. This hack gets the right path.
+ #
+ # Disabled when using GCC LTO because GCC also uses the -B search
+ # path at link time to find "as", and our bundled "as" can only
+ # target x86.
+ 'ldflags': [
+ # Note, Chromium allows ia32 host arch as well, we limit this to
+ # x64 in v8.
+ '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['OS=="mac"', {
+ 'target_defaults': {
+ 'conditions': [
+ ['asan==1', {
+ 'xcode_settings': {
+ # FIXME(machenbach): This is outdated compared to common.gypi.
+ 'OTHER_CFLAGS+': [
+ '-fno-omit-frame-pointer',
+ '-gline-tables-only',
+ '-fsanitize=address',
+ '-w', # http://crbug.com/162783
+ ],
+ 'OTHER_CFLAGS!': [
+ '-fomit-frame-pointer',
+ ],
+ 'defines': [
+ 'ADDRESS_SANITIZER',
+ ],
+ },
+ 'dependencies': [
+ '<(DEPTH)/gypfiles/mac/asan.gyp:asan_dynamic_runtime',
+ ],
+ 'target_conditions': [
+ ['_type!="static_library"', {
+ 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
+ }],
+ ],
+ }],
+ ['sanitizer_coverage!=0', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize-coverage=<(sanitizer_coverage)',
+ ],
+ 'defines': [
+ 'SANITIZER_COVERAGE',
+ ],
+ }],
+ ],
+ }],
+ ],
+ }, # target_defaults
+ }], # OS=="mac"
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
+ or OS=="netbsd" or OS=="aix"', {
+ 'target_defaults': {
+ 'cflags': [
+ '-Wall',
+ '<(werror)',
+ '-Wno-unused-parameter',
+ '-Wno-long-long',
+ '-pthread',
+ '-pedantic',
+ '-Wmissing-field-initializers',
+ '-Wno-gnu-zero-variadic-macro-arguments',
+ ],
+ 'cflags_cc': [
+ '-Wnon-virtual-dtor',
+ '-fno-exceptions',
+ '-fno-rtti',
+ '-std=gnu++11',
+ ],
+ 'ldflags': [ '-pthread', ],
+ 'conditions': [
+ # Don't warn about TRACE_EVENT_* macros with zero arguments passed to
+ # ##__VA_ARGS__. C99 strict mode prohibits having zero variadic macro
+ # arguments in gcc.
+ [ 'clang==0', {
+ 'cflags!' : [
+ '-pedantic' ,
+ # Don't warn about unrecognized command line option.
+ '-Wno-gnu-zero-variadic-macro-arguments',
+ ],
+ }],
+ [ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
+ or v8_target_arch=="mips64el")', {
+ 'cflags': [ '-Wshorten-64-to-32' ],
+ }],
+ [ 'host_arch=="ppc64" and OS!="aix"', {
+ 'cflags': [ '-mminimal-toc' ],
+ }],
+ [ 'visibility=="hidden" and v8_enable_backtrace==0', {
+ 'cflags': [ '-fvisibility=hidden' ],
+ }],
+ [ 'component=="shared_library"', {
+ 'cflags': [ '-fPIC', ],
+ }],
+ [ 'clang==0 and coverage==1', {
+ 'cflags': [ '-fprofile-arcs', '-ftest-coverage'],
+ 'ldflags': [ '-fprofile-arcs'],
+ }],
+ ],
+ },
+ }],
+ # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
+ # or OS=="netbsd"'
+ ['OS=="qnx"', {
+ 'target_defaults': {
+ 'cflags': [
+ '-Wall',
+ '<(werror)',
+ '-Wno-unused-parameter',
+ # Don't warn about the "struct foo f = {0};" initialization pattern.
+ '-Wno-missing-field-initializers',
+ '-Wno-gnu-zero-variadic-macro-arguments',
+ ],
+ 'cflags_cc': [
+ '-Wnon-virtual-dtor',
+ '-fno-exceptions',
+ '-fno-rtti',
+ '-std=gnu++11',
+ ],
+ 'conditions': [
+ [ 'visibility=="hidden"', {
+ 'cflags': [ '-fvisibility=hidden' ],
+ }],
+ [ 'component=="shared_library"', {
+ 'cflags': [ '-fPIC' ],
+ }],
+ ],
+ 'target_conditions': [
+ [ '_toolset=="host" and host_os=="linux"', {
+ 'cflags': [ '-pthread' ],
+ 'ldflags': [ '-pthread' ],
+ 'libraries': [ '-lrt' ],
+ }],
+ [ '_toolset=="target"', {
+ 'cflags': [ '-Wno-psabi' ],
+ 'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
+ }],
+ ],
+ },
+ }], # OS=="qnx"
+ ['OS=="win"', {
+ 'target_defaults': {
+ 'defines': [
+ '_CRT_SECURE_NO_DEPRECATE',
+ '_CRT_NONSTDC_NO_DEPRECATE',
+ '_USING_V110_SDK71_',
+ ],
+ 'conditions': [
+ ['component=="static_library"', {
+ 'defines': [
+ '_HAS_EXCEPTIONS=0',
+ ],
+ }],
+ ],
+ 'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
+ 'msvs_disabled_warnings': [
+ # C4091: 'typedef ': ignored on left of 'X' when no variable is
+ # declared.
+ # This happens in a number of Windows headers. Dumb.
+ 4091,
+
+ # C4127: conditional expression is constant
+ # This warning can in theory catch dead code and other problems, but
+ # triggers in far too many desirable cases where the conditional
+ # expression is either set by macros or corresponds some legitimate
+ # compile-time constant expression (due to constant template args,
+ # conditionals comparing the sizes of different types, etc.). Some of
+ # these can be worked around, but it's not worth it.
+ 4127,
+
+ # C4351: new behavior: elements of array 'array' will be default
+ # initialized
+ # This is a silly "warning" that basically just alerts you that the
+ # compiler is going to actually follow the language spec like it's
+ # supposed to, instead of not following it like old buggy versions
+ # did. There's absolutely no reason to turn this on.
+ 4351,
+
+ # C4355: 'this': used in base member initializer list
+ # It's commonly useful to pass |this| to objects in a class'
+ # initializer list. While this warning can catch real bugs, most of
+ # the time the constructors in question don't attempt to call methods
+ # on the passed-in pointer (until later), and annotating every legit
+ # usage of this is simply more hassle than the warning is worth.
+ 4355,
+
+ # C4503: 'identifier': decorated name length exceeded, name was
+ # truncated
+ # This only means that some long error messages might have truncated
+ # identifiers in the presence of lots of templates. It has no effect
+ # on program correctness and there's no real reason to waste time
+ # trying to prevent it.
+ 4503,
+
+ # Warning C4589 says: "Constructor of abstract class ignores
+ # initializer for virtual base class." Disable this warning because it
+ # is flaky in VS 2015 RTM. It triggers on compiler generated
+ # copy-constructors in some cases.
+ 4589,
+
+ # C4611: interaction between 'function' and C++ object destruction is
+ # non-portable
+ # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
+ # suggests using exceptions instead of setjmp/longjmp for C++, but
+ # Chromium code compiles without exception support. We therefore have
+ # to use setjmp/longjmp for e.g. JPEG decode error handling, which
+ # means we have to turn off this warning (and be careful about how
+ # object destruction happens in such cases).
+ 4611,
+
+ # TODO(jochen): These warnings are level 4. They will be slowly
+ # removed as code is fixed.
+ 4100, # Unreferenced formal parameter
+ 4121, # Alignment of a member was sensitive to packing
+ 4244, # Conversion from 'type1' to 'type2', possible loss of data
+ 4302, # Truncation from 'type 1' to 'type 2'
+ 4309, # Truncation of constant value
+ 4311, # Pointer truncation from 'type' to 'type'
+ 4312, # Conversion from 'type1' to 'type2' of greater size
+ 4505, # Unreferenced local function has been removed
+ 4510, # Default constructor could not be generated
+ 4512, # Assignment operator could not be generated
+ 4610, # Object can never be instantiated
+ 4800, # Forcing value to bool.
+ 4838, # Narrowing conversion. Doesn't seem to be very useful.
+ 4995, # 'X': name was marked as #pragma deprecated
+ 4996, # 'X': was declared deprecated (for GetVersionEx).
+
+ # These are variable shadowing warnings that are new in VS2015. We
+ # should work through these at some point -- they may be removed from
+ # the RTM release in the /W4 set.
+ 4456, 4457, 4458, 4459,
+ ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'MinimalRebuild': 'false',
+ 'BufferSecurityCheck': 'true',
+ 'EnableFunctionLevelLinking': 'true',
+ 'RuntimeTypeInfo': 'false',
+ 'WarningLevel': '3',
+ 'WarnAsError': 'true',
+ 'DebugInformationFormat': '3',
+ 'Detect64BitPortabilityProblems': 'false',
+ 'conditions': [
+ [ 'msvs_multi_core_compile', {
+ 'AdditionalOptions': ['/MP'],
+ }],
+ ['component=="shared_library"', {
+ 'ExceptionHandling': '1', # /EHsc
+ }, {
+ 'ExceptionHandling': '0',
+ }],
+ ],
+ },
+ 'VCLibrarianTool': {
+ 'AdditionalOptions': ['/ignore:4221'],
+ 'conditions': [
+ ['v8_target_arch=="x64"', {
+ 'TargetMachine': '17', # x64
+ }, {
+ 'TargetMachine': '1', # ia32
+ }],
+ ],
+ },
+ 'VCLinkerTool': {
+ 'AdditionalDependencies': [
+ 'ws2_32.lib',
+ ],
+ 'GenerateDebugInformation': 'true',
+ 'MapFileName': '$(OutDir)\\$(TargetName).map',
+ 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
+ 'FixedBaseAddress': '1',
+ # LinkIncremental values:
+ # 0 == default
+ # 1 == /INCREMENTAL:NO
+ # 2 == /INCREMENTAL
+ 'LinkIncremental': '1',
+ # SubSystem values:
+ # 0 == not set
+ # 1 == /SUBSYSTEM:CONSOLE
+ # 2 == /SUBSYSTEM:WINDOWS
+ 'SubSystem': '1',
+
+ 'conditions': [
+ ['v8_enable_i18n_support==1', {
+ 'AdditionalDependencies': [
+ 'advapi32.lib',
+ ],
+ }],
+ ['v8_target_arch=="x64"', {
+ 'MinimumRequiredVersion': '5.02', # Server 2003.
+ 'TargetMachine': '17', # x64
+ }, {
+ 'MinimumRequiredVersion': '5.01', # XP.
+ 'TargetMachine': '1', # ia32
+ }],
+ ],
+ },
+ 'conditions': [
+ ['clang==1', {
+ 'VCCLCompilerTool': {
+ 'AdditionalOptions': [
+ # Don't warn about unused function parameters.
+ # (This is also used on other platforms.)
+ '-Wno-unused-parameter',
+ # Don't warn about the "struct foo f = {0};" initialization
+ # pattern.
+ '-Wno-missing-field-initializers',
+
+ # Many files use intrinsics without including this header.
+ # TODO(hans): Fix those files, or move this to sub-GYPs.
+ '/FIIntrin.h',
+
+ # TODO(hans): Make this list shorter eventually, http://crbug.com/504657
+ '-Qunused-arguments', # http://crbug.com/504658
+ '-Wno-microsoft-enum-value', # http://crbug.com/505296
+ '-Wno-unknown-pragmas', # http://crbug.com/505314
+ '-Wno-microsoft-cast', # http://crbug.com/550065
+ ],
+ },
+ }],
+ ['clang==1 and MSVS_VERSION == "2013"', {
+ 'VCCLCompilerTool': {
+ 'AdditionalOptions': [
+ '-fmsc-version=1800',
+ ],
+ },
+ }],
+ ['clang==1 and MSVS_VERSION == "2015"', {
+ 'VCCLCompilerTool': {
+ 'AdditionalOptions': [
+ '-fmsc-version=1900',
+ ],
+ },
+ }],
+ ],
+ },
+ },
+ }], # OS=="win"
+ ['OS=="mac"', {
+ 'xcode_settings': {
+ 'SDKROOT': 'macosx',
+ 'SYMROOT': '<(DEPTH)/xcodebuild',
+ },
+ 'target_defaults': {
+ 'xcode_settings': {
+ 'ALWAYS_SEARCH_USER_PATHS': 'NO',
+ 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
+ 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
+ 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
+ # (Equivalent to -fPIC)
+ 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
+ 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
+ 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
+ # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
+ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
+ 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
+ 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
+ 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
+ # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
+ 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
+ 'PREBINDING': 'NO', # No -Wl,-prebind
+ 'SYMROOT': '<(DEPTH)/xcodebuild',
+ 'USE_HEADERMAP': 'NO',
+ 'OTHER_CFLAGS': [
+ '-fno-strict-aliasing',
+ ],
+ 'WARNING_CFLAGS': [
+ '-Wall',
+ '-Wendif-labels',
+ '-Wno-unused-parameter',
+ # Don't warn about the "struct foo f = {0};" initialization pattern.
+ '-Wno-missing-field-initializers',
+ '-Wno-gnu-zero-variadic-macro-arguments',
+ ],
+ },
+ 'conditions': [
+ ['werror==""', {
+ 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
+ }, {
+ 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
+ }],
+ ['clang==1', {
+ 'xcode_settings': {
+ 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
+ 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', # -std=c++11
+ },
+ 'conditions': [
+ ['clang_xcode==0', {
+ 'xcode_settings': {
+ 'CC': '<(clang_dir)/bin/clang',
+ 'LDPLUSPLUS': '<(clang_dir)/bin/clang++',
+ 'CLANG_CXX_LIBRARY': 'libc++'
+ },
+ }],
+ ['v8_target_arch=="x64" or v8_target_arch=="arm64" \
+ or v8_target_arch=="mips64el"', {
+ 'xcode_settings': {'WARNING_CFLAGS': ['-Wshorten-64-to-32']},
+ }],
+ ],
+ }],
+ ],
+ 'target_conditions': [
+ ['_type!="static_library"', {
+ 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
+ }],
+ ], # target_conditions
+ }, # target_defaults
+ }], # OS=="mac"
+ ['OS=="android"', {
+ 'target_defaults': {
+ 'defines': [
+ 'ANDROID',
+ 'V8_ANDROID_LOG_STDOUT',
+ ],
+ 'configurations': {
+ 'Release': {
+ 'cflags': [
+ '-fomit-frame-pointer',
+ ],
+ }, # Release
+ }, # configurations
+ 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
+ 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
+ '-std=gnu++11' ],
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags!': [
+ '-pthread', # Not supported by Android toolchain.
+ ],
+ 'cflags': [
+ '-ffunction-sections',
+ '-funwind-tables',
+ '-fstack-protector',
+ '-fno-short-enums',
+ '-finline-limit=64',
+ '-Wa,--noexecstack',
+ '--sysroot=<(android_sysroot)',
+ ],
+ 'cflags_cc': [
+ '-isystem<(android_libcpp_include)',
+ '-isystem<(android_libcpp_abi_include)',
+ '-isystem<(android_support_include)',
+ ],
+ 'defines': [
+ 'ANDROID',
+ #'__GNU_SOURCE=1', # Necessary for clone()
+ 'HAVE_OFF64_T',
+ 'HAVE_SYS_UIO_H',
+ 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
+ ],
+ 'ldflags!': [
+ '-pthread', # Not supported by Android toolchain.
+ ],
+ 'ldflags': [
+ '-Wl,--no-undefined',
+ '--sysroot=<(android_sysroot)',
+ '-nostdlib',
+ ],
+ 'libraries!': [
+ '-lrt', # librt is built into Bionic.
+ # Not supported by Android toolchain.
+ # Where do these come from? Can't find references in
+ # any Chromium gyp or gypi file. Maybe they come from
+ # gyp itself?
+ '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
+ ],
+ 'libraries': [
+ '-l<(android_libcpp_library)',
+ '-latomic',
+ # Manually link the libgcc.a that the cross compiler uses.
+ '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
+ '-lc',
+ '-ldl',
+ '-lm',
+ ],
+ 'conditions': [
+ ['target_arch == "arm"', {
+ 'ldflags': [
+ # Enable identical code folding to reduce size.
+ '-Wl,--icf=safe',
+ ],
+ }],
+ ['target_arch=="arm" and arm_version==7', {
+ 'cflags': [
+ '-march=armv7-a',
+ '-mtune=cortex-a8',
+ '-mfpu=vfp3',
+ ],
+ 'ldflags': [
+ '-L<(android_libcpp_libs)/armeabi-v7a',
+ ],
+ }],
+ ['target_arch=="arm" and arm_version < 7', {
+ 'ldflags': [
+ '-L<(android_libcpp_libs)/armeabi',
+ ],
+ }],
+ ['target_arch=="x64"', {
+ 'ldflags': [
+ '-L<(android_libcpp_libs)/x86_64',
+ ],
+ }],
+ ['target_arch=="arm64"', {
+ 'ldflags': [
+ '-L<(android_libcpp_libs)/arm64-v8a',
+ ],
+ }],
+ ['target_arch=="ia32" or target_arch=="x87"', {
+ # The x86 toolchain currently has problems with stack-protector.
+ 'cflags!': [
+ '-fstack-protector',
+ ],
+ 'cflags': [
+ '-fno-stack-protector',
+ ],
+ 'ldflags': [
+ '-L<(android_libcpp_libs)/x86',
+ ],
+ }],
+ ['target_arch=="mipsel"', {
+ # The mips toolchain currently has problems with stack-protector.
+ 'cflags!': [
+ '-fstack-protector',
+ '-U__linux__'
+ ],
+ 'cflags': [
+ '-fno-stack-protector',
+ ],
+ 'ldflags': [
+ '-L<(android_libcpp_libs)/mips',
+ ],
+ }],
+ ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64" or target_arch=="ia32") and component!="shared_library"', {
+ 'cflags': [
+ '-fPIE',
+ ],
+ 'ldflags': [
+ '-pie',
+ ],
+ }],
+ ],
+ 'target_conditions': [
+ ['_type=="executable"', {
+ 'conditions': [
+ ['target_arch=="arm64" or target_arch=="x64"', {
+ 'ldflags': [
+ '-Wl,-dynamic-linker,/system/bin/linker64',
+ ],
+ }, {
+ 'ldflags': [
+ '-Wl,-dynamic-linker,/system/bin/linker',
+ ],
+ }]
+ ],
+ 'ldflags': [
+ '-Bdynamic',
+ '-Wl,-z,nocopyreloc',
+ # crtbegin_dynamic.o should be the last item in ldflags.
+ '<(android_lib)/crtbegin_dynamic.o',
+ ],
+ 'libraries': [
+ # crtend_android.o needs to be the last item in libraries.
+ # Do not add any libraries after this!
+ '<(android_lib)/crtend_android.o',
+ ],
+ }],
+ ['_type=="shared_library"', {
+ 'ldflags': [
+ '-Wl,-shared,-Bsymbolic',
+ '<(android_lib)/crtbegin_so.o',
+ ],
+ }],
+ ['_type=="static_library"', {
+ 'ldflags': [
+ # Don't export symbols from statically linked libraries.
+ '-Wl,--exclude-libs=ALL',
+ ],
+ }],
+ ],
+ }], # _toolset=="target"
+ # Settings for building host targets using the system toolchain.
+ ['_toolset=="host"', {
+ 'cflags': [ '-pthread' ],
+ 'ldflags': [ '-pthread' ],
+ 'ldflags!': [
+ '-Wl,-z,noexecstack',
+ '-Wl,--gc-sections',
+ '-Wl,-O1',
+ '-Wl,--as-needed',
+ ],
+ }],
+ ], # target_conditions
+ }, # target_defaults
+ }], # OS=="android"
+ ['OS=="android" and clang==0', {
+ # Hardcode the compiler names in the Makefile so that
+ # it won't depend on the environment at make time.
+ 'make_global_settings': [
+ ['LD', '<!(/bin/echo -n <(android_toolchain)/../*/bin/ld)'],
+ ['RANLIB', '<!(/bin/echo -n <(android_toolchain)/../*/bin/ranlib)'],
+ ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
+ ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
+ ['LD.host', '<(host_ld)'],
+ ['RANLIB.host', '<(host_ranlib)'],
+ ['CC.host', '<(host_cc)'],
+ ['CXX.host', '<(host_cxx)'],
+ ],
+ }],
+ ['clang!=1 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
+ 'make_global_settings': [
+ ['CC.host', '<(clang_dir)/bin/clang'],
+ ['CXX.host', '<(clang_dir)/bin/clang++'],
+ ],
+ }],
+ ['clang==0 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'cflags_cc': [ '-std=gnu++11', ],
+ }],
+ ],
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="host"', { 'cflags!': [ '-Wno-unused-local-typedefs' ]}],
+ ],
+ },
+ }],
+ ['clang==1 and "<(GENERATOR)"=="ninja"', {
+ # See http://crbug.com/110262
+ 'target_defaults': {
+ 'cflags': [ '-fcolor-diagnostics' ],
+ 'xcode_settings': { 'OTHER_CFLAGS': [ '-fcolor-diagnostics' ] },
+ },
+ }],
+ ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
+ 'and OS!="win" and "<(GENERATOR)"=="make"', {
+ 'make_global_settings': [
+ ['CC', '<(clang_dir)/bin/clang'],
+ ['CXX', '<(clang_dir)/bin/clang++'],
+ ['CC.host', '$(CC)'],
+ ['CXX.host', '$(CXX)'],
+ ],
+ }],
+ ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
+ 'and OS!="win" and "<(GENERATOR)"=="ninja"', {
+ 'make_global_settings': [
+ ['CC', '<(clang_dir)/bin/clang'],
+ ['CXX', '<(clang_dir)/bin/clang++'],
+ ['CC.host', '$(CC)'],
+ ['CXX.host', '$(CXX)'],
+ ],
+ }],
+ ['clang==1 and OS=="win"', {
+ 'make_global_settings': [
+ # On Windows, gyp's ninja generator only looks at CC.
+ ['CC', '<(clang_dir)/bin/clang-cl'],
+ ],
+ }],
+ ['OS=="linux" and target_arch=="arm" and host_arch!="arm" and clang==0 and "<(GENERATOR)"=="ninja"', {
+ # Set default ARM cross tools on linux. These can be overridden
+ # using CC,CXX,CC.host and CXX.host environment variables.
+ 'make_global_settings': [
+ ['CC', '<!(which arm-linux-gnueabihf-gcc)'],
+ ['CXX', '<!(which arm-linux-gnueabihf-g++)'],
+ ['CC.host', '<(host_cc)'],
+ ['CXX.host', '<(host_cxx)'],
+ ],
+ }],
+ # TODO(yyanagisawa): supports GENERATOR==make
+ # make generator doesn't support CC_wrapper without CC
+ # in make_global_settings yet.
+ ['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', {
+ 'conditions': [
+ ['coverage==1', {
+ # Wrap goma with coverage wrapper.
+ 'make_global_settings': [
+ ['CC_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
+ ['CXX_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
+ ['CC.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
+ ['CXX.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
+ ],
+ }, {
+ # Use only goma wrapper.
+ 'make_global_settings': [
+ ['CC_wrapper', '<(gomadir)/gomacc'],
+ ['CXX_wrapper', '<(gomadir)/gomacc'],
+ ['CC.host_wrapper', '<(gomadir)/gomacc'],
+ ['CXX.host_wrapper', '<(gomadir)/gomacc'],
+ ],
+ }],
+ ],
+ }, {
+ 'conditions': [
+ ['coverage==1', {
+ # Use only coverage wrapper.
+ 'make_global_settings': [
+ ['CC_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
+ ['CXX_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
+ ['CC.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
+ ['CXX.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
+ ],
+ }],
+ ],
+ }],
+ ['use_lto==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-flto',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==0', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-ffat-lto-objects',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'arflags': [
+ '--plugin', '<(clang_dir)/lib/LLVMgold.so',
+ ],
+ # Apply a lower optimization level with lto. Chromium does this
+ # for non-official builds only - a differentiation that doesn't
+ # exist in v8.
+ 'ldflags': [
+ '-Wl,--plugin-opt,O1',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==0', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'ldflags': [
+ '-flto=32',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'ldflags': [
+ '-flto',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['cfi_diag==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fno-sanitize-trap=cfi',
+ '-fno-sanitize-recover=cfi',
+ ],
+ 'cflags_cc!': [
+ '-fno-rtti',
+ ],
+ 'cflags!': [
+ '-fno-rtti',
+ ],
+ 'ldflags': [
+ '-fno-sanitize-trap=cfi',
+ '-fno-sanitize-recover=cfi',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['cfi_vptr==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=cfi-vcall',
+ '-fsanitize=cfi-derived-cast',
+ '-fsanitize=cfi-unrelated-cast',
+ '-fsanitize-blacklist=<(cfi_blacklist)',
+ ],
+ 'ldflags': [
+ '-fsanitize=cfi-vcall',
+ '-fsanitize=cfi-derived-cast',
+ '-fsanitize=cfi-unrelated-cast',
+ ],
+ }],
+ ],
+ },
+ }],
+ ],
+}
diff --git a/gypfiles/toolchain.gypi b/gypfiles/toolchain.gypi
new file mode 100644
index 0000000..bc3ee5e
--- /dev/null
+++ b/gypfiles/toolchain.gypi
@@ -0,0 +1,1394 @@
+# Copyright 2013 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.
+
+# Shared definitions for all V8-related targets.
+
+{
+ 'variables': {
+ 'msvs_use_common_release': 0,
+ 'clang%': 0,
+ 'asan%': 0,
+ 'lsan%': 0,
+ 'msan%': 0,
+ 'tsan%': 0,
+ 'ubsan%': 0,
+ 'ubsan_vptr%': 0,
+ 'v8_target_arch%': '<(target_arch)',
+ 'v8_host_byteorder%': '<!(python -c "import sys; print sys.byteorder")',
+ # Native Client builds currently use the V8 ARM JIT and
+ # arm/simulator-arm.cc to defer the significant effort required
+ # for NaCl JIT support. The nacl_target_arch variable provides
+ # the 'true' target arch for places in this file that need it.
+ # TODO(bradchen): get rid of nacl_target_arch when someday
+ # NaCl V8 builds stop using the ARM simulator
+ 'nacl_target_arch%': 'none', # must be set externally
+
+ # Setting 'v8_can_use_vfp32dregs' to 'true' will cause V8 to use the VFP
+ # registers d16-d31 in the generated code, both in the snapshot and for the
+ # ARM target. Leaving the default value of 'false' will avoid the use of
+ # these registers in the snapshot and use CPU feature probing when running
+ # on the target.
+ 'v8_can_use_vfp32dregs%': 'false',
+ 'arm_test_noprobe%': 'off',
+
+ # Similar to vfp but on MIPS.
+ 'v8_can_use_fpu_instructions%': 'true',
+
+ # Similar to the ARM hard float ABI but on MIPS.
+ 'v8_use_mips_abi_hardfloat%': 'true',
+
+ # Force disable libstdc++ debug mode.
+ 'disable_glibcxx_debug%': 0,
+
+ 'v8_enable_backtrace%': 0,
+
+ # Enable profiling support. Only required on Windows.
+ 'v8_enable_prof%': 0,
+
+ # Some versions of GCC 4.5 seem to need -fno-strict-aliasing.
+ 'v8_no_strict_aliasing%': 0,
+
+ # Chrome needs this definition unconditionally. For standalone V8 builds,
+ # it's handled in gypfiles/standalone.gypi.
+ 'want_separate_host_toolset%': 1,
+
+ # Toolset the shell binary should be compiled for. Possible values are
+ # 'host' and 'target'.
+ # The setting is ignored if want_separate_host_toolset is 0.
+ 'v8_toolset_for_shell%': 'target',
+
+ 'host_os%': '<(OS)',
+ 'werror%': '-Werror',
+ # For a shared library build, results in "libv8-<(soname_version).so".
+ 'soname_version%': '',
+
+ # Allow to suppress the array bounds warning (default is no suppression).
+ 'wno_array_bounds%': '',
+
+ # Override where to find binutils
+ 'binutils_dir%': '',
+
+ 'conditions': [
+ ['OS=="linux" and host_arch=="x64"', {
+ 'binutils_dir%': 'third_party/binutils/Linux_x64/Release/bin',
+ }],
+ ['OS=="linux" and host_arch=="ia32"', {
+ 'binutils_dir%': 'third_party/binutils/Linux_ia32/Release/bin',
+ }],
+
+ # linux_use_bundled_gold: whether to use the gold linker binary checked
+ # into third_party/binutils. Force this off via GYP_DEFINES when you
+ # are using a custom toolchain and need to control -B in ldflags.
+ # Do not use 32-bit gold on 32-bit hosts as it runs out address space
+ # for component=static_library builds.
+ ['OS=="linux" and (target_arch=="x64" or target_arch=="arm")', {
+ 'linux_use_bundled_gold%': 1,
+ }, {
+ 'linux_use_bundled_gold%': 0,
+ }],
+ # linux_use_bundled_binutils: whether to use the binary binutils
+ # checked into third_party/binutils. These are not multi-arch so cannot
+ # be used except on x86 and x86-64 (the only two architectures which
+ # are currently checke in). Force this off via GYP_DEFINES when you
+ # are using a custom toolchain and need to control -B in cflags.
+ ['OS=="linux" and (target_arch=="ia32" or target_arch=="x64")', {
+ 'linux_use_bundled_binutils%': 1,
+ }, {
+ 'linux_use_bundled_binutils%': 0,
+ }],
+ # linux_use_gold_flags: whether to use build flags that rely on gold.
+ # On by default for x64 Linux.
+ ['OS=="linux" and target_arch=="x64"', {
+ 'linux_use_gold_flags%': 1,
+ }, {
+ 'linux_use_gold_flags%': 0,
+ }],
+ ],
+
+ # Link-Time Optimizations
+ 'use_lto%': 0,
+ },
+ 'conditions': [
+ ['host_arch=="ia32" or host_arch=="x64" or \
+ host_arch=="ppc" or host_arch=="ppc64" or \
+ host_arch=="s390" or host_arch=="s390x" or \
+ clang==1', {
+ 'variables': {
+ 'host_cxx_is_biarch%': 1,
+ },
+ }, {
+ 'variables': {
+ 'host_cxx_is_biarch%': 0,
+ },
+ }],
+ ['target_arch=="ia32" or target_arch=="x64" or target_arch=="x87" or \
+ target_arch=="ppc" or target_arch=="ppc64" or target_arch=="s390" or \
+ target_arch=="s390x" or clang==1', {
+ 'variables': {
+ 'target_cxx_is_biarch%': 1,
+ },
+ }, {
+ 'variables': {
+ 'target_cxx_is_biarch%': 0,
+ },
+ }],
+ ],
+ 'target_defaults': {
+ 'conditions': [
+ ['v8_target_arch=="arm"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_ARM',
+ ],
+ 'conditions': [
+ [ 'arm_version==7 or arm_version=="default"', {
+ 'defines': [
+ 'CAN_USE_ARMV7_INSTRUCTIONS',
+ ],
+ }],
+ [ 'arm_fpu=="vfpv3-d16" or arm_fpu=="default"', {
+ 'defines': [
+ 'CAN_USE_VFP3_INSTRUCTIONS',
+ ],
+ }],
+ [ 'arm_fpu=="vfpv3"', {
+ 'defines': [
+ 'CAN_USE_VFP3_INSTRUCTIONS',
+ 'CAN_USE_VFP32DREGS',
+ ],
+ }],
+ [ 'arm_fpu=="neon"', {
+ 'defines': [
+ 'CAN_USE_VFP3_INSTRUCTIONS',
+ 'CAN_USE_VFP32DREGS',
+ 'CAN_USE_NEON',
+ ],
+ }],
+ [ 'arm_test_noprobe=="on"', {
+ 'defines': [
+ 'ARM_TEST_NO_FEATURE_PROBE',
+ ],
+ }],
+ ],
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'conditions': [
+ ['v8_target_arch==host_arch', {
+ # Host built with an Arm CXX compiler.
+ 'conditions': [
+ [ 'arm_version==7', {
+ 'cflags': ['-march=armv7-a',],
+ }],
+ [ 'arm_version==7 or arm_version=="default"', {
+ 'conditions': [
+ [ 'arm_fpu!="default"', {
+ 'cflags': ['-mfpu=<(arm_fpu)',],
+ }],
+ ],
+ }],
+ [ 'arm_float_abi!="default"', {
+ 'cflags': ['-mfloat-abi=<(arm_float_abi)',],
+ }],
+ [ 'arm_thumb==1', {
+ 'cflags': ['-mthumb',],
+ }],
+ [ 'arm_thumb==0', {
+ 'cflags': ['-marm',],
+ }],
+ ],
+ }, {
+ # 'v8_target_arch!=host_arch'
+ # Host not built with an Arm CXX compiler (simulator build).
+ 'conditions': [
+ [ 'arm_float_abi=="hard"', {
+ 'defines': [
+ 'USE_EABI_HARDFLOAT=1',
+ ],
+ }],
+ [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
+ 'defines': [
+ 'USE_EABI_HARDFLOAT=0',
+ ],
+ }],
+ ],
+ }],
+ ],
+ }], # _toolset=="host"
+ ['_toolset=="target"', {
+ 'conditions': [
+ ['v8_target_arch==target_arch', {
+ # Target built with an Arm CXX compiler.
+ 'conditions': [
+ [ 'arm_version==7', {
+ 'cflags': ['-march=armv7-a',],
+ }],
+ [ 'arm_version==7 or arm_version=="default"', {
+ 'conditions': [
+ [ 'arm_fpu!="default"', {
+ 'cflags': ['-mfpu=<(arm_fpu)',],
+ }],
+ ],
+ }],
+ [ 'arm_float_abi!="default"', {
+ 'cflags': ['-mfloat-abi=<(arm_float_abi)',],
+ }],
+ [ 'arm_thumb==1', {
+ 'cflags': ['-mthumb',],
+ }],
+ [ 'arm_thumb==0', {
+ 'cflags': ['-marm',],
+ }],
+ ],
+ }, {
+ # 'v8_target_arch!=target_arch'
+ # Target not built with an Arm CXX compiler (simulator build).
+ 'conditions': [
+ [ 'arm_float_abi=="hard"', {
+ 'defines': [
+ 'USE_EABI_HARDFLOAT=1',
+ ],
+ }],
+ [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
+ 'defines': [
+ 'USE_EABI_HARDFLOAT=0',
+ ],
+ }],
+ ],
+ }],
+ # Disable GCC LTO for v8
+ # v8 is optimized for speed. Because GCC LTO merges flags at link
+ # time, we disable LTO to prevent any -O2 flags from taking
+ # precedence over v8's -Os flag. However, LLVM LTO does not work
+ # this way so we keep LTO enabled under LLVM.
+ ['clang==0 and use_lto==1', {
+ 'cflags!': [
+ '-flto',
+ '-ffat-lto-objects',
+ ],
+ }],
+ ],
+ }], # _toolset=="target"
+ ],
+ }], # v8_target_arch=="arm"
+ ['v8_target_arch=="arm64"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_ARM64',
+ ],
+ }],
+ ['v8_target_arch=="s390" or v8_target_arch=="s390x"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_S390',
+ ],
+ 'conditions': [
+ ['v8_target_arch=="s390x"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_S390X',
+ ],
+ }],
+ ['v8_host_byteorder=="little"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_S390_LE_SIM',
+ ],
+ }],
+ ],
+ }], # s390
+ ['v8_target_arch=="ppc" or v8_target_arch=="ppc64"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC',
+ ],
+ 'conditions': [
+ ['v8_target_arch=="ppc64"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC64',
+ ],
+ }],
+ ['v8_host_byteorder=="little"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC_LE',
+ ],
+ }],
+ ['v8_host_byteorder=="big"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC_BE',
+ ],
+ 'conditions': [
+ ['OS=="aix"', {
+ # Work around AIX ceil, trunc and round oddities.
+ 'cflags': [ '-mcpu=power5+ -mfprnd' ],
+ }],
+ ['OS=="aix"', {
+ # Work around AIX assembler popcntb bug.
+ 'cflags': [ '-mno-popcntb' ],
+ }],
+ ],
+ }],
+ ],
+ }], # ppc
+ ['v8_target_arch=="ia32"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_IA32',
+ ],
+ }], # v8_target_arch=="ia32"
+ ['v8_target_arch=="x87"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_X87',
+ ],
+ 'cflags': ['-march=i586'],
+ }], # v8_target_arch=="x87"
+ ['(v8_target_arch=="mips" or v8_target_arch=="mipsel" \
+ or v8_target_arch=="mips64" or v8_target_arch=="mips64el") \
+ and v8_target_arch==target_arch', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ # Target built with a Mips CXX compiler.
+ 'variables': {
+ 'ldso_path%': '<!(/bin/echo -n $LDSO_PATH)',
+ 'ld_r_path%': '<!(/bin/echo -n $LD_R_PATH)',
+ },
+ 'conditions': [
+ ['ldso_path!=""', {
+ 'ldflags': ['-Wl,--dynamic-linker=<(ldso_path)'],
+ }],
+ ['ld_r_path!=""', {
+ 'ldflags': ['-Wl,--rpath=<(ld_r_path)'],
+ }],
+ [ 'clang==1', {
+ 'cflags': ['-integrated-as'],
+ }],
+ ],
+ }],
+ ],
+ }],
+ ['v8_target_arch=="mips"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_MIPS',
+ ],
+ 'conditions': [
+ [ 'v8_can_use_fpu_instructions=="true"', {
+ 'defines': [
+ 'CAN_USE_FPU_INSTRUCTIONS',
+ ],
+ }],
+ [ 'v8_use_mips_abi_hardfloat=="true"', {
+ 'defines': [
+ '__mips_hard_float=1',
+ 'CAN_USE_FPU_INSTRUCTIONS',
+ ],
+ }, {
+ 'defines': [
+ '__mips_soft_float=1'
+ ]
+ }],
+ ],
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'conditions': [
+ ['v8_target_arch==target_arch', {
+ # Target built with a Mips CXX compiler.
+ 'cflags': [
+ '-EB',
+ '-Wno-error=array-bounds', # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
+ ],
+ 'ldflags': ['-EB'],
+ 'conditions': [
+ [ 'v8_use_mips_abi_hardfloat=="true"', {
+ 'cflags': ['-mhard-float'],
+ 'ldflags': ['-mhard-float'],
+ }, {
+ 'cflags': ['-msoft-float'],
+ 'ldflags': ['-msoft-float'],
+ }],
+ ['mips_arch_variant=="r6"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R6',
+ 'FPU_MODE_FP64',
+ ],
+ 'cflags!': ['-mfp32', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r6'],
+ }],
+ ],
+ 'cflags': ['-mips32r6'],
+ 'ldflags': ['-mips32r6'],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'conditions': [
+ [ 'mips_fpu_mode=="fp64"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP64',
+ ],
+ 'cflags': ['-mfp64'],
+ }],
+ ['mips_fpu_mode=="fpxx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FPXX',
+ ],
+ 'cflags': ['-mfpxx'],
+ }],
+ ['mips_fpu_mode=="fp32"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP32',
+ ],
+ 'cflags': ['-mfp32'],
+ }],
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r2'],
+ }],
+ ],
+ 'cflags': ['-mips32r2'],
+ 'ldflags': ['-mips32r2'],
+ }],
+ ['mips_arch_variant=="r1"', {
+ 'defines': [
+ 'FPU_MODE_FP32',
+ ],
+ 'cflags!': ['-mfp64', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32'],
+ 'ldflags': ['-mips32'],
+ }],
+ ['mips_arch_variant=="rx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32RX',
+ 'FPU_MODE_FPXX',
+ ],
+ 'cflags!': ['-mfp64', '-mfp32'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32', '-mfpxx'],
+ 'ldflags': ['-mips32'],
+ }],
+ ],
+ }, {
+ # 'v8_target_arch!=target_arch'
+ # Target not built with an MIPS CXX compiler (simulator build).
+ 'conditions': [
+ ['mips_arch_variant=="r6"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R6',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'conditions': [
+ [ 'mips_fpu_mode=="fp64"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_fpu_mode=="fpxx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ['mips_fpu_mode=="fp32"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP32',
+ ],
+ }],
+ ],
+ }],
+ ['mips_arch_variant=="r1"', {
+ 'defines': [
+ 'FPU_MODE_FP32',
+ ],
+ }],
+ ['mips_arch_variant=="rx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32RX',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ],
+ }],
+ ],
+ }], #_toolset=="target"
+ ['_toolset=="host"', {
+ 'conditions': [
+ ['mips_arch_variant=="rx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32RX',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ['mips_arch_variant=="r6"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R6',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'conditions': [
+ ['mips_fpu_mode=="fp64"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_fpu_mode=="fpxx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ['mips_fpu_mode=="fp32"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP32'
+ ],
+ }],
+ ],
+ }],
+ ['mips_arch_variant=="r1"', {
+ 'defines': ['FPU_MODE_FP32',],
+ }],
+ ]
+ }], #_toolset=="host"
+ ],
+ }], # v8_target_arch=="mips"
+ ['v8_target_arch=="mipsel"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_MIPS',
+ ],
+ 'conditions': [
+ [ 'v8_can_use_fpu_instructions=="true"', {
+ 'defines': [
+ 'CAN_USE_FPU_INSTRUCTIONS',
+ ],
+ }],
+ [ 'v8_use_mips_abi_hardfloat=="true"', {
+ 'defines': [
+ '__mips_hard_float=1',
+ 'CAN_USE_FPU_INSTRUCTIONS',
+ ],
+ }, {
+ 'defines': [
+ '__mips_soft_float=1'
+ ],
+ }],
+ ],
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'conditions': [
+ ['v8_target_arch==target_arch', {
+ # Target built with a Mips CXX compiler.
+ 'cflags': [
+ '-EL',
+ '-Wno-error=array-bounds', # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
+ ],
+ 'ldflags': ['-EL'],
+ 'conditions': [
+ [ 'v8_use_mips_abi_hardfloat=="true"', {
+ 'cflags': ['-mhard-float'],
+ 'ldflags': ['-mhard-float'],
+ }, {
+ 'cflags': ['-msoft-float'],
+ 'ldflags': ['-msoft-float'],
+ }],
+ ['mips_arch_variant=="r6"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R6',
+ 'FPU_MODE_FP64',
+ ],
+ 'cflags!': ['-mfp32', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r6'],
+ }],
+ ],
+ 'cflags': ['-mips32r6'],
+ 'ldflags': ['-mips32r6'],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'conditions': [
+ [ 'mips_fpu_mode=="fp64"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP64',
+ ],
+ 'cflags': ['-mfp64'],
+ }],
+ ['mips_fpu_mode=="fpxx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FPXX',
+ ],
+ 'cflags': ['-mfpxx'],
+ }],
+ ['mips_fpu_mode=="fp32"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP32',
+ ],
+ 'cflags': ['-mfp32'],
+ }],
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r2'],
+ }],
+ ],
+ 'cflags': ['-mips32r2'],
+ 'ldflags': ['-mips32r2'],
+ }],
+ ['mips_arch_variant=="r1"', {
+ 'defines': [
+ 'FPU_MODE_FP32',
+ ],
+ 'cflags!': ['-mfp64', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32'],
+ 'ldflags': ['-mips32'],
+ }],
+ ['mips_arch_variant=="rx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32RX',
+ 'FPU_MODE_FPXX',
+ ],
+ 'cflags!': ['-mfp64', '-mfp32'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32', '-mfpxx'],
+ 'ldflags': ['-mips32'],
+ }],
+ ['mips_arch_variant=="loongson"', {
+ 'defines': [
+ '_MIPS_ARCH_LOONGSON',
+ 'FPU_MODE_FP32',
+ ],
+ 'cflags!': ['-mfp64', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips3'],
+ }],
+ ],
+ 'cflags': ['-mips3', '-mfp32'],
+ }],
+ ],
+ }, {
+ # 'v8_target_arch!=target_arch'
+ # Target not built with an MIPS CXX compiler (simulator build).
+ 'conditions': [
+ ['mips_arch_variant=="r6"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R6',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'conditions': [
+ [ 'mips_fpu_mode=="fp64"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_fpu_mode=="fpxx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ['mips_fpu_mode=="fp32"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP32',
+ ],
+ }],
+ ],
+ }],
+ ['mips_arch_variant=="r1"', {
+ 'defines': [
+ 'FPU_MODE_FP32',
+ ],
+ }],
+ ['mips_arch_variant=="rx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32RX',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ['mips_arch_variant=="loongson"', {
+ 'defines': [
+ '_MIPS_ARCH_LOONGSON',
+ 'FPU_MODE_FP32',
+ ],
+ }],
+ ],
+ }],
+ ],
+ }], #_toolset=="target
+ ['_toolset=="host"', {
+ 'conditions': [
+ ['mips_arch_variant=="rx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32RX',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ['mips_arch_variant=="r6"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R6',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'conditions': [
+ ['mips_fpu_mode=="fp64"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP64',
+ ],
+ }],
+ ['mips_fpu_mode=="fpxx"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FPXX',
+ ],
+ }],
+ ['mips_fpu_mode=="fp32"', {
+ 'defines': [
+ '_MIPS_ARCH_MIPS32R2',
+ 'FPU_MODE_FP32'
+ ],
+ }],
+ ],
+ }],
+ ['mips_arch_variant=="r1"', {
+ 'defines': ['FPU_MODE_FP32',],
+ }],
+ ['mips_arch_variant=="loongson"', {
+ 'defines': [
+ '_MIPS_ARCH_LOONGSON',
+ 'FPU_MODE_FP32',
+ ],
+ }],
+ ]
+ }],
+ ],
+ }], # v8_target_arch=="mipsel"
+ ['v8_target_arch=="mips64el" or v8_target_arch=="mips64"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_MIPS64',
+ ],
+ 'conditions': [
+ [ 'v8_can_use_fpu_instructions=="true"', {
+ 'defines': [
+ 'CAN_USE_FPU_INSTRUCTIONS',
+ ],
+ }],
+ [ 'v8_host_byteorder=="little"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_MIPS64_LE',
+ ],
+ }],
+ [ 'v8_host_byteorder=="big"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_MIPS64_BE',
+ ],
+ }],
+ [ 'v8_use_mips_abi_hardfloat=="true"', {
+ 'defines': [
+ '__mips_hard_float=1',
+ 'CAN_USE_FPU_INSTRUCTIONS',
+ ],
+ }, {
+ 'defines': [
+ '__mips_soft_float=1'
+ ],
+ }],
+ ],
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'conditions': [
+ ['v8_target_arch==target_arch', {
+ 'cflags': [
+ '-Wno-error=array-bounds', # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
+ ],
+ 'conditions': [
+ ['v8_target_arch=="mips64el"', {
+ 'cflags': ['-EL'],
+ 'ldflags': ['-EL'],
+ }],
+ ['v8_target_arch=="mips64"', {
+ 'cflags': ['-EB'],
+ 'ldflags': ['-EB'],
+ }],
+ [ 'v8_use_mips_abi_hardfloat=="true"', {
+ 'cflags': ['-mhard-float'],
+ 'ldflags': ['-mhard-float'],
+ }, {
+ 'cflags': ['-msoft-float'],
+ 'ldflags': ['-msoft-float'],
+ }],
+ ['mips_arch_variant=="r6"', {
+ 'defines': ['_MIPS_ARCH_MIPS64R6',],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips64r6'],
+ }],
+ ],
+ 'cflags': ['-mips64r6', '-mabi=64'],
+ 'ldflags': ['-mips64r6', '-mabi=64'],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'defines': ['_MIPS_ARCH_MIPS64R2',],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips64r2'],
+ }],
+ ],
+ 'cflags': ['-mips64r2', '-mabi=64'],
+ 'ldflags': ['-mips64r2', '-mabi=64'],
+ }],
+ ],
+ }, {
+ # 'v8_target_arch!=target_arch'
+ # Target not built with an MIPS CXX compiler (simulator build).
+ 'conditions': [
+ ['mips_arch_variant=="r6"', {
+ 'defines': ['_MIPS_ARCH_MIPS64R6',],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'defines': ['_MIPS_ARCH_MIPS64R2',],
+ }],
+ ],
+ }],
+ ],
+ }], #'_toolset=="target"
+ ['_toolset=="host"', {
+ 'conditions': [
+ ['mips_arch_variant=="r6"', {
+ 'defines': ['_MIPS_ARCH_MIPS64R6',],
+ }],
+ ['mips_arch_variant=="r2"', {
+ 'defines': ['_MIPS_ARCH_MIPS64R2',],
+ }],
+ ],
+ }], #'_toolset=="host"
+ ],
+ }], # v8_target_arch=="mips64el"
+ ['v8_target_arch=="x64"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_X64',
+ ],
+ 'xcode_settings': {
+ 'ARCHS': [ 'x86_64' ],
+ },
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'StackReserveSize': '2097152',
+ },
+ },
+ 'msvs_configuration_platform': 'x64',
+ }], # v8_target_arch=="x64"
+ ['v8_target_arch=="x32"', {
+ 'defines': [
+ # x32 port shares the source code with x64 port.
+ 'V8_TARGET_ARCH_X64',
+ 'V8_TARGET_ARCH_32_BIT',
+ ],
+ 'cflags': [
+ '-mx32',
+ # Inhibit warning if long long type is used.
+ '-Wno-long-long',
+ ],
+ 'ldflags': [
+ '-mx32',
+ ],
+ }], # v8_target_arch=="x32"
+ ['linux_use_gold_flags==1', {
+ # Newer gccs and clangs support -fuse-ld, use the flag to force gold
+ # selection.
+ # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html
+ 'ldflags': [ '-fuse-ld=gold', ],
+ }],
+ ['linux_use_bundled_binutils==1', {
+ 'cflags': [
+ '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
+ ],
+ }],
+ ['linux_use_bundled_gold==1', {
+ # Put our binutils, which contains gold in the search path. We pass
+ # the path to gold to the compiler. gyp leaves unspecified what the
+ # cwd is when running the compiler, so the normal gyp path-munging
+ # fails us. This hack gets the right path.
+ 'ldflags': [
+ '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
+ ],
+ }],
+ ['OS=="win"', {
+ 'defines': [
+ 'WIN32',
+ ],
+ # 4351: VS 2005 and later are warning us that they've fixed a bug
+ # present in VS 2003 and earlier.
+ 'msvs_disabled_warnings': [4351],
+ 'msvs_configuration_attributes': {
+ 'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)',
+ 'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
+ 'CharacterSet': '1',
+ },
+ }],
+ ['OS=="win" and v8_target_arch=="ia32"', {
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ # Ensure no surprising artifacts from 80bit double math with x86.
+ 'AdditionalOptions': ['/arch:SSE2'],
+ },
+ },
+ }],
+ ['OS=="win" and v8_enable_prof==1', {
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'GenerateMapFile': 'true',
+ },
+ },
+ }],
+ ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
+ or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
+ v8_target_arch=="ia32"', {
+ 'cflags': [
+ '-msse2',
+ '-mfpmath=sse',
+ '-mmmx', # Allows mmintrin.h for MMX intrinsics.
+ ],
+ }],
+ ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
+ or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
+ (v8_target_arch=="arm" or v8_target_arch=="ia32" or \
+ v8_target_arch=="x87" or v8_target_arch=="mips" or \
+ v8_target_arch=="mipsel" or v8_target_arch=="ppc" or \
+ v8_target_arch=="s390")', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'conditions': [
+ ['host_cxx_is_biarch==1', {
+ 'conditions': [
+ ['host_arch=="s390" or host_arch=="s390x"', {
+ 'cflags': [ '-m31' ],
+ 'ldflags': [ '-m31' ]
+ },{
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ]
+ }],
+ ],
+ }],
+ ],
+ 'xcode_settings': {
+ 'ARCHS': [ 'i386' ],
+ },
+ }],
+ ['_toolset=="target"', {
+ 'conditions': [
+ ['target_cxx_is_biarch==1 and nacl_target_arch!="nacl_x64"', {
+ 'conditions': [
+ ['host_arch=="s390" or host_arch=="s390x"', {
+ 'cflags': [ '-m31' ],
+ 'ldflags': [ '-m31' ]
+ },{
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ],
+ }],
+ ],
+ }],
+ ],
+ 'xcode_settings': {
+ 'ARCHS': [ 'i386' ],
+ },
+ }],
+ ],
+ }],
+ ['(OS=="linux" or OS=="android") and \
+ (v8_target_arch=="x64" or v8_target_arch=="arm64" or \
+ v8_target_arch=="ppc64" or v8_target_arch=="s390x")', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'conditions': [
+ ['host_cxx_is_biarch==1', {
+ 'cflags': [ '-m64' ],
+ 'ldflags': [ '-m64' ]
+ }],
+ ],
+ }],
+ ['_toolset=="target"', {
+ 'conditions': [
+ ['target_cxx_is_biarch==1', {
+ 'cflags': [ '-m64' ],
+ 'ldflags': [ '-m64' ],
+ }],
+ ]
+ }],
+ ],
+ }],
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
+ or OS=="netbsd" or OS=="qnx" or OS=="aix"', {
+ 'conditions': [
+ [ 'v8_no_strict_aliasing==1', {
+ 'cflags': [ '-fno-strict-aliasing' ],
+ }],
+ ], # conditions
+ }],
+ ['OS=="solaris"', {
+ 'defines': [ '__C99FEATURES__=1' ], # isinf() etc.
+ }],
+ ['OS=="freebsd" or OS=="openbsd"', {
+ 'cflags': [ '-I/usr/local/include' ],
+ }],
+ ['OS=="netbsd"', {
+ 'cflags': [ '-I/usr/pkg/include' ],
+ }],
+ ['OS=="aix"', {
+ 'defines': [
+ # Support for malloc(0)
+ '_LINUX_SOURCE_COMPAT=1',
+ '_ALL_SOURCE=1'],
+ 'conditions': [
+ [ 'v8_target_arch=="ppc"', {
+ 'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ],
+ }],
+ [ 'v8_target_arch=="ppc64"', {
+ 'cflags': [ '-maix64' ],
+ 'ldflags': [ '-maix64' ],
+ }],
+ ],
+ }],
+ ], # conditions
+ 'configurations': {
+ # Abstract configuration for v8_optimized_debug == 0.
+ 'DebugBase0': {
+ 'abstract': 1,
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'Optimization': '0',
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'RuntimeLibrary': '3', # /MDd
+ }, {
+ 'RuntimeLibrary': '1', # /MTd
+ }],
+ ],
+ },
+ 'VCLinkerTool': {
+ 'LinkIncremental': '2',
+ },
+ },
+ 'variables': {
+ 'v8_enable_slow_dchecks%': 1,
+ },
+ 'conditions': [
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
+ OS=="qnx" or OS=="aix"', {
+ 'cflags!': [
+ '-O3',
+ '-O2',
+ '-O1',
+ '-Os',
+ ],
+ 'cflags': [
+ '-fdata-sections',
+ '-ffunction-sections',
+ ],
+ }],
+ ['OS=="mac"', {
+ 'xcode_settings': {
+ 'GCC_OPTIMIZATION_LEVEL': '0', # -O0
+ },
+ }],
+ ['v8_enable_slow_dchecks==1', {
+ 'defines': [
+ 'ENABLE_SLOW_DCHECKS',
+ ],
+ }],
+ ],
+ }, # DebugBase0
+ # Abstract configuration for v8_optimized_debug == 1.
+ 'DebugBase1': {
+ 'abstract': 1,
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'Optimization': '2',
+ 'InlineFunctionExpansion': '2',
+ 'EnableIntrinsicFunctions': 'true',
+ 'FavorSizeOrSpeed': '0',
+ 'StringPooling': 'true',
+ 'BasicRuntimeChecks': '0',
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'RuntimeLibrary': '3', #/MDd
+ }, {
+ 'RuntimeLibrary': '1', #/MTd
+ }],
+ ],
+ },
+ 'VCLinkerTool': {
+ 'LinkIncremental': '1',
+ 'OptimizeReferences': '2',
+ 'EnableCOMDATFolding': '2',
+ },
+ },
+ 'variables': {
+ 'v8_enable_slow_dchecks%': 0,
+ },
+ 'conditions': [
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
+ OS=="qnx" or OS=="aix"', {
+ 'cflags!': [
+ '-O0',
+ '-O1',
+ '-Os',
+ ],
+ 'cflags': [
+ '-fdata-sections',
+ '-ffunction-sections',
+ ],
+ 'conditions': [
+ # TODO(crbug.com/272548): Avoid -O3 in NaCl
+ # Don't use -O3 with sanitizers.
+ ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
+ and tsan==0 and ubsan==0 and ubsan_vptr==0', {
+ 'cflags': ['-O3'],
+ 'cflags!': ['-O2'],
+ }, {
+ 'cflags': ['-O2'],
+ 'cflags!': ['-O3'],
+ }],
+ ],
+ }],
+ ['OS=="mac"', {
+ 'xcode_settings': {
+ 'GCC_OPTIMIZATION_LEVEL': '3', # -O3
+ 'GCC_STRICT_ALIASING': 'YES',
+ },
+ }],
+ ['v8_enable_slow_dchecks==1', {
+ 'defines': [
+ 'ENABLE_SLOW_DCHECKS',
+ ],
+ }],
+ ],
+ }, # DebugBase1
+ # Common settings for the Debug configuration.
+ 'DebugBaseCommon': {
+ 'abstract': 1,
+ 'defines': [
+ 'ENABLE_DISASSEMBLER',
+ 'V8_ENABLE_CHECKS',
+ 'OBJECT_PRINT',
+ 'VERIFY_HEAP',
+ 'DEBUG',
+ 'TRACE_MAPS'
+ ],
+ 'conditions': [
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
+ OS=="qnx" or OS=="aix"', {
+ 'cflags': [ '-Woverloaded-virtual', '<(wno_array_bounds)', ],
+ }],
+ ['OS=="linux" and v8_enable_backtrace==1', {
+ # Support for backtrace_symbols.
+ 'ldflags': [ '-rdynamic' ],
+ }],
+ ['OS=="linux" and disable_glibcxx_debug==0', {
+ # Enable libstdc++ debugging facilities to help catch problems
+ # early, see http://crbug.com/65151 .
+ 'defines': ['_GLIBCXX_DEBUG=1',],
+ }],
+ ['OS=="aix"', {
+ 'ldflags': [ '-Wl,-bbigtoc' ],
+ 'conditions': [
+ ['v8_target_arch=="ppc64"', {
+ 'cflags': [ '-maix64 -mcmodel=large' ],
+ }],
+ ],
+ }],
+ ['OS=="android"', {
+ 'variables': {
+ 'android_full_debug%': 1,
+ },
+ 'conditions': [
+ ['android_full_debug==0', {
+ # Disable full debug if we want a faster v8 in a debug build.
+ # TODO(2304): pass DISABLE_DEBUG_ASSERT instead of hiding DEBUG.
+ 'defines!': [
+ 'DEBUG',
+ 'ENABLE_SLOW_DCHECKS',
+ ],
+ }],
+ ],
+ }],
+ # TODO(pcc): Re-enable in LTO builds once we've fixed the intermittent
+ # link failures (crbug.com/513074).
+ ['linux_use_gold_flags==1 and use_lto==0', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'ldflags': [
+ # Experimentation found that using four linking threads
+ # saved ~20% of link time.
+ # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+ # Only apply this to the target linker, since the host
+ # linker might not be gold, but isn't used much anyway.
+ '-Wl,--threads',
+ '-Wl,--thread-count=4',
+ ],
+ }],
+ ],
+ }],
+ ],
+ }, # DebugBaseCommon
+ 'Debug': {
+ 'inherit_from': ['DebugBaseCommon'],
+ 'conditions': [
+ ['v8_optimized_debug==0', {
+ 'inherit_from': ['DebugBase0'],
+ }, {
+ 'inherit_from': ['DebugBase1'],
+ }],
+ ],
+ }, # Debug
+ 'ReleaseBase': {
+ 'abstract': 1,
+ 'variables': {
+ 'v8_enable_slow_dchecks%': 0,
+ },
+ 'conditions': [
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
+ or OS=="aix"', {
+ 'cflags!': [
+ '-Os',
+ ],
+ 'cflags': [
+ '-fdata-sections',
+ '-ffunction-sections',
+ '<(wno_array_bounds)',
+ ],
+ 'conditions': [
+ # TODO(crbug.com/272548): Avoid -O3 in NaCl
+ # Don't use -O3 with sanitizers.
+ ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
+ and tsan==0 and ubsan==0 and ubsan_vptr==0', {
+ 'cflags': ['-O3'],
+ 'cflags!': ['-O2'],
+ }, {
+ 'cflags': ['-O2'],
+ 'cflags!': ['-O3'],
+ }],
+ ],
+ }],
+ ['OS=="android"', {
+ 'cflags!': [
+ '-O3',
+ '-Os',
+ ],
+ 'cflags': [
+ '-fdata-sections',
+ '-ffunction-sections',
+ '-O2',
+ ],
+ }],
+ ['OS=="mac"', {
+ 'xcode_settings': {
+ 'GCC_OPTIMIZATION_LEVEL': '3', # -O3
+
+ # -fstrict-aliasing. Mainline gcc
+ # enables this at -O2 and above,
+ # but Apple gcc does not unless it
+ # is specified explicitly.
+ 'GCC_STRICT_ALIASING': 'YES',
+ },
+ }], # OS=="mac"
+ ['OS=="win"', {
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'Optimization': '2',
+ 'InlineFunctionExpansion': '2',
+ 'EnableIntrinsicFunctions': 'true',
+ 'FavorSizeOrSpeed': '0',
+ 'StringPooling': 'true',
+ 'conditions': [
+ ['component=="shared_library"', {
+ 'RuntimeLibrary': '2', #/MD
+ }, {
+ 'RuntimeLibrary': '0', #/MT
+ }],
+ ],
+ },
+ 'VCLinkerTool': {
+ 'LinkIncremental': '1',
+ 'OptimizeReferences': '2',
+ 'EnableCOMDATFolding': '2',
+ },
+ },
+ }], # OS=="win"
+ ['v8_enable_slow_dchecks==1', {
+ 'defines': [
+ 'ENABLE_SLOW_DCHECKS',
+ ],
+ }],
+ ], # conditions
+ }, # Release
+ 'Release': {
+ 'inherit_from': ['ReleaseBase'],
+ }, # Debug
+ 'conditions': [
+ [ 'OS=="win"', {
+ # TODO(bradnelson): add a gyp mechanism to make this more graceful.
+ 'Debug_x64': {
+ 'inherit_from': ['DebugBaseCommon'],
+ 'conditions': [
+ ['v8_optimized_debug==0', {
+ 'inherit_from': ['DebugBase0'],
+ }, {
+ 'inherit_from': ['DebugBase1'],
+ }],
+ ],
+ },
+ 'Release_x64': {
+ 'inherit_from': ['ReleaseBase'],
+ },
+ }],
+ ],
+ }, # configurations
+ }, # target_defaults
+}
diff --git a/gypfiles/vs_toolchain.py b/gypfiles/vs_toolchain.py
new file mode 100644
index 0000000..1693647
--- /dev/null
+++ b/gypfiles/vs_toolchain.py
@@ -0,0 +1,379 @@
+#!/usr/bin/env python
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import glob
+import json
+import os
+import pipes
+import shutil
+import subprocess
+import sys
+
+
+script_dir = os.path.dirname(os.path.realpath(__file__))
+chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
+SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(1, os.path.join(chrome_src, 'tools'))
+sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
+json_data_file = os.path.join(script_dir, 'win_toolchain.json')
+
+
+import gyp
+
+
+# Use MSVS2013 as the default toolchain.
+CURRENT_DEFAULT_TOOLCHAIN_VERSION = '2013'
+
+
+def SetEnvironmentAndGetRuntimeDllDirs():
+ """Sets up os.environ to use the depot_tools VS toolchain with gyp, and
+ returns the location of the VS runtime DLLs so they can be copied into
+ the output directory after gyp generation.
+ """
+ vs_runtime_dll_dirs = None
+ depot_tools_win_toolchain = \
+ bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
+ # When running on a non-Windows host, only do this if the SDK has explicitly
+ # been downloaded before (in which case json_data_file will exist).
+ if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file))
+ and depot_tools_win_toolchain):
+ if ShouldUpdateToolchain():
+ Update()
+ with open(json_data_file, 'r') as tempf:
+ toolchain_data = json.load(tempf)
+
+ toolchain = toolchain_data['path']
+ version = toolchain_data['version']
+ win_sdk = toolchain_data.get('win_sdk')
+ if not win_sdk:
+ win_sdk = toolchain_data['win8sdk']
+ wdk = toolchain_data['wdk']
+ # TODO(scottmg): The order unfortunately matters in these. They should be
+ # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
+ # below). http://crbug.com/345992
+ vs_runtime_dll_dirs = toolchain_data['runtime_dirs']
+
+ os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
+ os.environ['GYP_MSVS_VERSION'] = version
+ # We need to make sure windows_sdk_path is set to the automated
+ # toolchain values in GYP_DEFINES, but don't want to override any
+ # otheroptions.express
+ # values there.
+ gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
+ gyp_defines_dict['windows_sdk_path'] = win_sdk
+ os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
+ for k, v in gyp_defines_dict.iteritems())
+ os.environ['WINDOWSSDKDIR'] = win_sdk
+ os.environ['WDK_DIR'] = wdk
+ # Include the VS runtime in the PATH in case it's not machine-installed.
+ runtime_path = os.path.pathsep.join(vs_runtime_dll_dirs)
+ os.environ['PATH'] = runtime_path + os.path.pathsep + os.environ['PATH']
+ elif sys.platform == 'win32' and not depot_tools_win_toolchain:
+ if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
+ os.environ['GYP_MSVS_OVERRIDE_PATH'] = DetectVisualStudioPath()
+ if not 'GYP_MSVS_VERSION' in os.environ:
+ os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
+
+ return vs_runtime_dll_dirs
+
+
+def _RegistryGetValueUsingWinReg(key, value):
+ """Use the _winreg module to obtain the value of a registry key.
+
+ Args:
+ key: The registry key.
+ value: The particular registry value to read.
+ Return:
+ contents of the registry key's value, or None on failure. Throws
+ ImportError if _winreg is unavailable.
+ """
+ import _winreg
+ try:
+ root, subkey = key.split('\\', 1)
+ assert root == 'HKLM' # Only need HKLM for now.
+ with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey:
+ return _winreg.QueryValueEx(hkey, value)[0]
+ except WindowsError:
+ return None
+
+
+def _RegistryGetValue(key, value):
+ try:
+ return _RegistryGetValueUsingWinReg(key, value)
+ except ImportError:
+ raise Exception('The python library _winreg not found.')
+
+
+def GetVisualStudioVersion():
+ """Return GYP_MSVS_VERSION of Visual Studio.
+ """
+ return os.environ.get('GYP_MSVS_VERSION', CURRENT_DEFAULT_TOOLCHAIN_VERSION)
+
+
+def DetectVisualStudioPath():
+ """Return path to the GYP_MSVS_VERSION of Visual Studio.
+ """
+
+ # Note that this code is used from
+ # build/toolchain/win/setup_toolchain.py as well.
+ version_as_year = GetVisualStudioVersion()
+ year_to_version = {
+ '2013': '12.0',
+ '2015': '14.0',
+ }
+ if version_as_year not in year_to_version:
+ raise Exception(('Visual Studio version %s (from GYP_MSVS_VERSION)'
+ ' not supported. Supported versions are: %s') % (
+ version_as_year, ', '.join(year_to_version.keys())))
+ version = year_to_version[version_as_year]
+ keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version,
+ r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version]
+ for key in keys:
+ path = _RegistryGetValue(key, 'InstallDir')
+ if not path:
+ continue
+ path = os.path.normpath(os.path.join(path, '..', '..'))
+ return path
+
+ raise Exception(('Visual Studio Version %s (from GYP_MSVS_VERSION)'
+ ' not found.') % (version_as_year))
+
+
+def _VersionNumber():
+ """Gets the standard version number ('120', '140', etc.) based on
+ GYP_MSVS_VERSION."""
+ vs_version = GetVisualStudioVersion()
+ if vs_version == '2013':
+ return '120'
+ elif vs_version == '2015':
+ return '140'
+ else:
+ raise ValueError('Unexpected GYP_MSVS_VERSION')
+
+
+def _CopyRuntimeImpl(target, source, verbose=True):
+ """Copy |source| to |target| if it doesn't already exist or if it
+ needs to be updated.
+ """
+ if (os.path.isdir(os.path.dirname(target)) and
+ (not os.path.isfile(target) or
+ os.stat(target).st_mtime != os.stat(source).st_mtime)):
+ if verbose:
+ print 'Copying %s to %s...' % (source, target)
+ if os.path.exists(target):
+ os.unlink(target)
+ shutil.copy2(source, target)
+
+
+def _CopyRuntime2013(target_dir, source_dir, dll_pattern):
+ """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
+ exist, but the target directory does exist."""
+ for file_part in ('p', 'r'):
+ dll = dll_pattern % file_part
+ target = os.path.join(target_dir, dll)
+ source = os.path.join(source_dir, dll)
+ _CopyRuntimeImpl(target, source)
+
+
+def _CopyRuntime2015(target_dir, source_dir, dll_pattern, suffix):
+ """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
+ exist, but the target directory does exist."""
+ for file_part in ('msvcp', 'vccorlib', 'vcruntime'):
+ dll = dll_pattern % file_part
+ target = os.path.join(target_dir, dll)
+ source = os.path.join(source_dir, dll)
+ _CopyRuntimeImpl(target, source)
+ ucrt_src_dir = os.path.join(source_dir, 'api-ms-win-*.dll')
+ print 'Copying %s to %s...' % (ucrt_src_dir, target_dir)
+ for ucrt_src_file in glob.glob(ucrt_src_dir):
+ file_part = os.path.basename(ucrt_src_file)
+ ucrt_dst_file = os.path.join(target_dir, file_part)
+ _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False)
+ _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
+ os.path.join(source_dir, 'ucrtbase' + suffix))
+
+
+def _CopyRuntime(target_dir, source_dir, target_cpu, debug):
+ """Copy the VS runtime DLLs, only if the target doesn't exist, but the target
+ directory does exist. Handles VS 2013 and VS 2015."""
+ suffix = "d.dll" if debug else ".dll"
+ if GetVisualStudioVersion() == '2015':
+ _CopyRuntime2015(target_dir, source_dir, '%s140' + suffix, suffix)
+ else:
+ _CopyRuntime2013(target_dir, source_dir, 'msvc%s120' + suffix)
+
+ # Copy the PGO runtime library to the release directories.
+ if not debug and os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
+ pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
+ 'VC', 'bin')
+ pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
+ pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll'
+ if target_cpu == "x86":
+ source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll)
+ if os.path.exists(source_x86):
+ _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll), source_x86)
+ elif target_cpu == "x64":
+ source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll)
+ if os.path.exists(source_x64):
+ _CopyRuntimeImpl(os.path.join(target_dir, pgo_runtime_dll),
+ source_x64)
+ else:
+ raise NotImplementedError("Unexpected target_cpu value:" + target_cpu)
+
+
+def CopyVsRuntimeDlls(output_dir, runtime_dirs):
+ """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
+ directory so that even if not system-installed, built binaries are likely to
+ be able to run.
+
+ This needs to be run after gyp has been run so that the expected target
+ output directories are already created.
+
+ This is used for the GYP build and gclient runhooks.
+ """
+ x86, x64 = runtime_dirs
+ out_debug = os.path.join(output_dir, 'Debug')
+ out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64')
+ out_release = os.path.join(output_dir, 'Release')
+ out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64')
+ out_debug_x64 = os.path.join(output_dir, 'Debug_x64')
+ out_release_x64 = os.path.join(output_dir, 'Release_x64')
+
+ if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64):
+ os.makedirs(out_debug_nacl64)
+ if os.path.exists(out_release) and not os.path.exists(out_release_nacl64):
+ os.makedirs(out_release_nacl64)
+ _CopyRuntime(out_debug, x86, "x86", debug=True)
+ _CopyRuntime(out_release, x86, "x86", debug=False)
+ _CopyRuntime(out_debug_x64, x64, "x64", debug=True)
+ _CopyRuntime(out_release_x64, x64, "x64", debug=False)
+ _CopyRuntime(out_debug_nacl64, x64, "x64", debug=True)
+ _CopyRuntime(out_release_nacl64, x64, "x64", debug=False)
+
+
+def CopyDlls(target_dir, configuration, target_cpu):
+ """Copy the VS runtime DLLs into the requested directory as needed.
+
+ configuration is one of 'Debug' or 'Release'.
+ target_cpu is one of 'x86' or 'x64'.
+
+ The debug configuration gets both the debug and release DLLs; the
+ release config only the latter.
+
+ This is used for the GN build.
+ """
+ vs_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
+ if not vs_runtime_dll_dirs:
+ return
+
+ x64_runtime, x86_runtime = vs_runtime_dll_dirs
+ runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime
+ _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False)
+ if configuration == 'Debug':
+ _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
+
+
+def _GetDesiredVsToolchainHashes():
+ """Load a list of SHA1s corresponding to the toolchains that we want installed
+ to build with."""
+ if GetVisualStudioVersion() == '2015':
+ # Update 2.
+ return ['95ddda401ec5678f15eeed01d2bee08fcbc5ee97']
+ else:
+ return ['03a4e939cd325d6bc5216af41b92d02dda1366a6']
+
+
+def ShouldUpdateToolchain():
+ """Check if the toolchain should be upgraded."""
+ if not os.path.exists(json_data_file):
+ return True
+ with open(json_data_file, 'r') as tempf:
+ toolchain_data = json.load(tempf)
+ version = toolchain_data['version']
+ env_version = GetVisualStudioVersion()
+ # If there's a mismatch between the version set in the environment and the one
+ # in the json file then the toolchain should be updated.
+ return version != env_version
+
+
+def Update(force=False):
+ """Requests an update of the toolchain to the specific hashes we have at
+ this revision. The update outputs a .json of the various configuration
+ information required to pass to gyp which we use in |GetToolchainDir()|.
+ """
+ if force != False and force != '--force':
+ print >>sys.stderr, 'Unknown parameter "%s"' % force
+ return 1
+ if force == '--force' or os.path.exists(json_data_file):
+ force = True
+
+ depot_tools_win_toolchain = \
+ bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
+ if ((sys.platform in ('win32', 'cygwin') or force) and
+ depot_tools_win_toolchain):
+ import find_depot_tools
+ depot_tools_path = find_depot_tools.add_depot_tools_to_path()
+ # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit
+ # in the correct directory.
+ os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion()
+ get_toolchain_args = [
+ sys.executable,
+ os.path.join(depot_tools_path,
+ 'win_toolchain',
+ 'get_toolchain_if_necessary.py'),
+ '--output-json', json_data_file,
+ ] + _GetDesiredVsToolchainHashes()
+ if force:
+ get_toolchain_args.append('--force')
+ subprocess.check_call(get_toolchain_args)
+
+ return 0
+
+
+def NormalizePath(path):
+ while path.endswith("\\"):
+ path = path[:-1]
+ return path
+
+
+def GetToolchainDir():
+ """Gets location information about the current toolchain (must have been
+ previously updated by 'update'). This is used for the GN build."""
+ runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
+
+ # If WINDOWSSDKDIR is not set, search the default SDK path and set it.
+ if not 'WINDOWSSDKDIR' in os.environ:
+ default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\10'
+ if os.path.isdir(default_sdk_path):
+ os.environ['WINDOWSSDKDIR'] = default_sdk_path
+
+ print '''vs_path = "%s"
+sdk_path = "%s"
+vs_version = "%s"
+wdk_dir = "%s"
+runtime_dirs = "%s"
+''' % (
+ NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH']),
+ NormalizePath(os.environ['WINDOWSSDKDIR']),
+ GetVisualStudioVersion(),
+ NormalizePath(os.environ.get('WDK_DIR', '')),
+ os.path.pathsep.join(runtime_dll_dirs or ['None']))
+
+
+def main():
+ commands = {
+ 'update': Update,
+ 'get_toolchain_dir': GetToolchainDir,
+ 'copy_dlls': CopyDlls,
+ }
+ if len(sys.argv) < 2 or sys.argv[1] not in commands:
+ print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
+ return 1
+ return commands[sys.argv[1]](*sys.argv[2:])
+
+
+if __name__ == '__main__':
+ sys.exit(main())