From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../ar/gyptest-make_global_settings_ar.py | 126 ++++++++++++++++++++ .../ar/make_global_settings_ar.gyp | 29 +++++ .../basics/gyptest-make_global_settings.py | 51 ++++++++ .../basics/make_global_settings.gyp | 17 +++ .../env-wrapper/gyptest-wrapper.py | 51 ++++++++ .../make_global_settings/env-wrapper/wrapper.gyp | 17 +++ .../make_global_settings/full-toolchain/bar.cc | 1 + .../test/make_global_settings/full-toolchain/foo.c | 1 + .../full-toolchain/gyptest-make_global_settings.py | 53 +++++++++ .../full-toolchain/make_global_settings.gyp | 22 ++++ .../make_global_settings/full-toolchain/my_nm.py | 9 ++ .../full-toolchain/my_readelf.py | 9 ++ .../ld/gyptest-make_global_settings_ld.py | 130 +++++++++++++++++++++ .../ld/make_global_settings_ld.gyp | 29 +++++ .../wrapper/gyptest-wrapper.py | 52 +++++++++ .../test/make_global_settings/wrapper/wrapper.gyp | 21 ++++ 16 files changed, 618 insertions(+) create mode 100644 third_party/python/gyp/test/make_global_settings/ar/gyptest-make_global_settings_ar.py create mode 100644 third_party/python/gyp/test/make_global_settings/ar/make_global_settings_ar.gyp create mode 100644 third_party/python/gyp/test/make_global_settings/basics/gyptest-make_global_settings.py create mode 100644 third_party/python/gyp/test/make_global_settings/basics/make_global_settings.gyp create mode 100644 third_party/python/gyp/test/make_global_settings/env-wrapper/gyptest-wrapper.py create mode 100644 third_party/python/gyp/test/make_global_settings/env-wrapper/wrapper.gyp create mode 100644 third_party/python/gyp/test/make_global_settings/full-toolchain/bar.cc create mode 100644 third_party/python/gyp/test/make_global_settings/full-toolchain/foo.c create mode 100644 third_party/python/gyp/test/make_global_settings/full-toolchain/gyptest-make_global_settings.py create mode 100644 third_party/python/gyp/test/make_global_settings/full-toolchain/make_global_settings.gyp create mode 100755 third_party/python/gyp/test/make_global_settings/full-toolchain/my_nm.py create mode 100755 third_party/python/gyp/test/make_global_settings/full-toolchain/my_readelf.py create mode 100644 third_party/python/gyp/test/make_global_settings/ld/gyptest-make_global_settings_ld.py create mode 100644 third_party/python/gyp/test/make_global_settings/ld/make_global_settings_ld.gyp create mode 100644 third_party/python/gyp/test/make_global_settings/wrapper/gyptest-wrapper.py create mode 100644 third_party/python/gyp/test/make_global_settings/wrapper/wrapper.gyp (limited to 'third_party/python/gyp/test/make_global_settings') diff --git a/third_party/python/gyp/test/make_global_settings/ar/gyptest-make_global_settings_ar.py b/third_party/python/gyp/test/make_global_settings/ar/gyptest-make_global_settings_ar.py new file mode 100644 index 0000000000..aabc5618d5 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/ar/gyptest-make_global_settings_ar.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies 'AR' in make_global_settings. +""" + +import os +import sys +import TestGyp + +def resolve_path(test, path): + if path is None: + return None + elif test.format == 'make': + return '$(abspath %s)' % path + elif test.format in ['ninja', 'xcode-ninja']: + return os.path.join('..', '..', path) + else: + test.fail_test() + + +def verify_ar_target(test, ar=None, rel_path=False): + if rel_path: + ar_expected = resolve_path(test, ar) + else: + ar_expected = ar + # Resolve default values + if ar_expected is None: + if test.format == 'make': + # Make generator hasn't set the default value for AR. + # You can remove the following assertion as long as it doesn't + # break existing projects. + test.must_not_contain('Makefile', 'AR ?= ') + return + elif test.format in ['ninja', 'xcode-ninja']: + if sys.platform == 'win32': + ar_expected = 'lib.exe' + else: + ar_expected = 'ar' + if test.format == 'make': + test.must_contain('Makefile', 'AR ?= %s' % ar_expected) + elif test.format in ['ninja', 'xcode-ninja']: + test.must_contain('out/Default/build.ninja', 'ar = %s' % ar_expected) + else: + test.fail_test() + + +def verify_ar_host(test, ar=None, rel_path=False): + if rel_path: + ar_expected = resolve_path(test, ar) + else: + ar_expected = ar + # Resolve default values + if ar_expected is None: + if sys.platform == 'win32': + ar_expected = 'lib.exe' + else: + ar_expected = 'ar' + if test.format == 'make': + test.must_contain('Makefile', 'AR.host ?= %s' % ar_expected) + elif test.format in ['ninja', 'xcode-ninja']: + test.must_contain('out/Default/build.ninja', 'ar_host = %s' % ar_expected) + else: + test.fail_test() + + +test_format = ['ninja'] +if sys.platform.startswith('linux') or sys.platform == 'darwin': + test_format += ['make'] + +test = TestGyp.TestGyp(formats=test_format) + +# Check default values +test.run_gyp('make_global_settings_ar.gyp') +verify_ar_target(test) + + +# Check default values with GYP_CROSSCOMPILE enabled. +with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): + test.run_gyp('make_global_settings_ar.gyp') +verify_ar_target(test) +verify_ar_host(test) + + +# Test 'AR' in 'make_global_settings'. +with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): + test.run_gyp('make_global_settings_ar.gyp', '-Dcustom_ar_target=my_ar') +verify_ar_target(test, ar='my_ar', rel_path=True) + + +# Test 'AR'/'AR.host' in 'make_global_settings'. +with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): + test.run_gyp('make_global_settings_ar.gyp', + '-Dcustom_ar_target=my_ar_target1', + '-Dcustom_ar_host=my_ar_host1') +verify_ar_target(test, ar='my_ar_target1', rel_path=True) +verify_ar_host(test, ar='my_ar_host1', rel_path=True) + + +# Test $AR and $AR_host environment variables. +with TestGyp.LocalEnv({'AR': 'my_ar_target2', + 'AR_host': 'my_ar_host2'}): + test.run_gyp('make_global_settings_ar.gyp') +# Ninja generator resolves $AR in gyp phase. Make generator doesn't. +if test.format == 'ninja': + if sys.platform == 'win32': + # TODO(yukawa): Make sure if this is an expected result or not. + verify_ar_target(test, ar='lib.exe', rel_path=False) + else: + verify_ar_target(test, ar='my_ar_target2', rel_path=False) +verify_ar_host(test, ar='my_ar_host2', rel_path=False) + + +# Test 'AR' in 'make_global_settings' with $AR_host environment variable. +with TestGyp.LocalEnv({'AR_host': 'my_ar_host3'}): + test.run_gyp('make_global_settings_ar.gyp', + '-Dcustom_ar_target=my_ar_target3') +verify_ar_target(test, ar='my_ar_target3', rel_path=True) +verify_ar_host(test, ar='my_ar_host3', rel_path=False) + + +test.pass_test() diff --git a/third_party/python/gyp/test/make_global_settings/ar/make_global_settings_ar.gyp b/third_party/python/gyp/test/make_global_settings/ar/make_global_settings_ar.gyp new file mode 100644 index 0000000000..3430d82a51 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/ar/make_global_settings_ar.gyp @@ -0,0 +1,29 @@ +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style licence that can be +# found in the LICENSE file. + +{ + 'variables': { + 'custom_ar_target%': '', + 'custom_ar_host%': '', + }, + 'conditions': [ + ['"<(custom_ar_target)"!=""', { + 'make_global_settings': [ + ['AR', '<(custom_ar_target)'], + ], + }], + ['"<(custom_ar_host)"!=""', { + 'make_global_settings': [ + ['AR.host', '<(custom_ar_host)'], + ], + }], + ], + 'targets': [ + { + 'target_name': 'make_global_settings_ar_test', + 'type': 'static_library', + 'sources': [ 'foo.c' ], + }, + ], +} diff --git a/third_party/python/gyp/test/make_global_settings/basics/gyptest-make_global_settings.py b/third_party/python/gyp/test/make_global_settings/basics/gyptest-make_global_settings.py new file mode 100644 index 0000000000..8f48875967 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/basics/gyptest-make_global_settings.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +# Copyright (c) 2013 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies make_global_settings. +""" + +from __future__ import print_function + +import os +import sys +import TestGyp + +print("This test is currently disabled: https://crbug.com/483696.") +sys.exit(0) + +test_format = ['ninja'] +if sys.platform.startswith('linux') or sys.platform == 'darwin': + test_format += ['make'] + +test = TestGyp.TestGyp(formats=test_format) + +test.run_gyp('make_global_settings.gyp') + +if test.format == 'make': + cc_expected = """ifneq (,$(filter $(origin CC), undefined default)) + CC = $(abspath clang) +endif +""" + if sys.platform.startswith('linux'): + link_expected = """ +LINK ?= $(abspath clang) +""" + elif sys.platform == 'darwin': + link_expected = """ +LINK ?= $(abspath clang) +""" + test.must_contain('Makefile', cc_expected) + test.must_contain('Makefile', link_expected) +if test.format == 'ninja': + cc_expected = 'cc = ' + os.path.join('..', '..', 'clang') + ld_expected = 'ld = $cc' + if sys.platform == 'win32': + ld_expected = 'link.exe' + test.must_contain('out/Default/build.ninja', cc_expected) + test.must_contain('out/Default/build.ninja', ld_expected) + +test.pass_test() diff --git a/third_party/python/gyp/test/make_global_settings/basics/make_global_settings.gyp b/third_party/python/gyp/test/make_global_settings/basics/make_global_settings.gyp new file mode 100644 index 0000000000..47dbc8570f --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/basics/make_global_settings.gyp @@ -0,0 +1,17 @@ +# Copyright (c) 2013 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style licence that can be +# found in the LICENSE file. + +{ + 'make_global_settings': [ + ['CC', 'clang'], + ['LINK', 'clang'], + ], + 'targets': [ + { + 'target_name': 'test', + 'type': 'static_library', + 'sources': [ 'foo.c' ], + }, + ], +} diff --git a/third_party/python/gyp/test/make_global_settings/env-wrapper/gyptest-wrapper.py b/third_party/python/gyp/test/make_global_settings/env-wrapper/gyptest-wrapper.py new file mode 100644 index 0000000000..409799e315 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/env-wrapper/gyptest-wrapper.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +# Copyright (c) 2013 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies *_wrapper in environment. +""" + +from __future__ import print_function + +import os +import sys +import TestGyp + +print("This test is currently disabled: https://crbug.com/483696.") +sys.exit(0) + +test_format = ['ninja'] + +os.environ['CC_wrapper'] = 'distcc' +os.environ['LINK_wrapper'] = 'distlink' +os.environ['CC.host_wrapper'] = 'ccache' + +test = TestGyp.TestGyp(formats=test_format) + +old_env = dict(os.environ) +os.environ['GYP_CROSSCOMPILE'] = '1' +test.run_gyp('wrapper.gyp') +os.environ.clear() +os.environ.update(old_env) + +if test.format == 'ninja': + cc_expected = ('cc = ' + os.path.join('..', '..', 'distcc') + ' ' + + os.path.join('..', '..', 'clang')) + cc_host_expected = ('cc_host = ' + os.path.join('..', '..', 'ccache') + ' ' + + os.path.join('..', '..', 'clang')) + ld_expected = 'ld = ../../distlink $cc' + if sys.platform != 'win32': + ldxx_expected = 'ldxx = ../../distlink $cxx' + + if sys.platform == 'win32': + ld_expected = 'link.exe' + test.must_contain('out/Default/build.ninja', cc_expected) + test.must_contain('out/Default/build.ninja', cc_host_expected) + test.must_contain('out/Default/build.ninja', ld_expected) + if sys.platform != 'win32': + test.must_contain('out/Default/build.ninja', ldxx_expected) + +test.pass_test() diff --git a/third_party/python/gyp/test/make_global_settings/env-wrapper/wrapper.gyp b/third_party/python/gyp/test/make_global_settings/env-wrapper/wrapper.gyp new file mode 100644 index 0000000000..1698d71dd4 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/env-wrapper/wrapper.gyp @@ -0,0 +1,17 @@ +# Copyright (c) 2013 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'make_global_settings': [ + ['CC', 'clang'], + ['CC.host', 'clang'], + ], + 'targets': [ + { + 'target_name': 'test', + 'type': 'static_library', + 'sources': [ 'foo.c' ], + }, + ], +} diff --git a/third_party/python/gyp/test/make_global_settings/full-toolchain/bar.cc b/third_party/python/gyp/test/make_global_settings/full-toolchain/bar.cc new file mode 100644 index 0000000000..afb422ba1a --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/full-toolchain/bar.cc @@ -0,0 +1 @@ +#error Not a real source file diff --git a/third_party/python/gyp/test/make_global_settings/full-toolchain/foo.c b/third_party/python/gyp/test/make_global_settings/full-toolchain/foo.c new file mode 100644 index 0000000000..afb422ba1a --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/full-toolchain/foo.c @@ -0,0 +1 @@ +#error Not a real source file diff --git a/third_party/python/gyp/test/make_global_settings/full-toolchain/gyptest-make_global_settings.py b/third_party/python/gyp/test/make_global_settings/full-toolchain/gyptest-make_global_settings.py new file mode 100644 index 0000000000..542fd631c2 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/full-toolchain/gyptest-make_global_settings.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies make_global_settings works with the full toolchain. +""" + +from __future__ import print_function + +import os +import sys +import TestGyp + +if sys.platform == 'win32': + # cross compiling not supported by ninja on windows + # and make not supported on windows at all. + sys.exit(0) + +print("This test is currently disabled: https://crbug.com/483696.") +sys.exit(0) + +test = TestGyp.TestGyp(formats=['ninja']) +# Must set the test format to something with a flavor (the part after the '-') +# in order to test the desired behavior. Since we want to run a non-host +# toolchain, we have to set the flavor to something that the ninja generator +# doesn't know about, so it doesn't default to the host-specific tools (e.g., +# 'otool' on mac to generate the .TOC). +# +# Note that we can't just pass format=['ninja-some_toolchain'] to the +# constructor above, because then this test wouldn't be recognized as a ninja +# format test. +test.formats = ['ninja-my_flavor' if f == 'ninja' else f for f in test.formats] + +gyp_file = 'make_global_settings.gyp' + +test.run_gyp(gyp_file, + # Teach the .gyp file about the location of my_nm.py and + # my_readelf.py, and the python executable. + '-Dworkdir=%s' % test.workdir, + '-Dpython=%s' % sys.executable) +test.build(gyp_file, + arguments=['-v'] if test.format == 'ninja-my_flavor' else []) + +expected = ['MY_CC', 'MY_CXX'] +test.must_contain_all_lines(test.stdout(), expected) + +test.must_contain(test.built_file_path('RAN_MY_NM'), 'RAN_MY_NM') +test.must_contain(test.built_file_path('RAN_MY_READELF'), 'RAN_MY_READELF') + +test.pass_test() diff --git a/third_party/python/gyp/test/make_global_settings/full-toolchain/make_global_settings.gyp b/third_party/python/gyp/test/make_global_settings/full-toolchain/make_global_settings.gyp new file mode 100644 index 0000000000..2c3266322d --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/full-toolchain/make_global_settings.gyp @@ -0,0 +1,22 @@ +# Copyright (c) 2013 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style licence that can be +# found in the LICENSE file. + +{ + 'make_global_settings': [ + ['CC', '/bin/echo MY_CC'], + ['CXX', '/bin/echo MY_CXX'], + ['NM', '<(python) <(workdir)/my_nm.py'], + ['READELF', '<(python) <(workdir)/my_readelf.py'], + ], + 'targets': [ + { + 'target_name': 'test', + 'type': 'shared_library', + 'sources': [ + 'foo.c', + 'bar.cc', + ], + }, + ], +} diff --git a/third_party/python/gyp/test/make_global_settings/full-toolchain/my_nm.py b/third_party/python/gyp/test/make_global_settings/full-toolchain/my_nm.py new file mode 100755 index 0000000000..2c4e678110 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/full-toolchain/my_nm.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +from __future__ import print_function +import sys +print(sys.argv) +with open('RAN_MY_NM', 'w') as f: + f.write('RAN_MY_NM') diff --git a/third_party/python/gyp/test/make_global_settings/full-toolchain/my_readelf.py b/third_party/python/gyp/test/make_global_settings/full-toolchain/my_readelf.py new file mode 100755 index 0000000000..626665435e --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/full-toolchain/my_readelf.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +from __future__ import print_function +import sys +print(sys.argv) +with open('RAN_MY_READELF', 'w') as f: + f.write('RAN_MY_READELF') diff --git a/third_party/python/gyp/test/make_global_settings/ld/gyptest-make_global_settings_ld.py b/third_party/python/gyp/test/make_global_settings/ld/gyptest-make_global_settings_ld.py new file mode 100644 index 0000000000..e5f50fbb5b --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/ld/gyptest-make_global_settings_ld.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies 'LD' in make_global_settings. +""" + +import os +import sys +import TestGyp + +def resolve_path(test, path): + if path is None: + return None + elif test.format == 'make': + return '$(abspath %s)' % path + elif test.format in ['ninja', 'xcode-ninja']: + return os.path.join('..', '..', path) + else: + test.fail_test() + + +def verify_ld_target(test, ld=None, rel_path=False): + if rel_path: + ld_expected = resolve_path(test, ld) + else: + ld_expected = ld + # Resolve default values + if ld_expected is None: + if test.format == 'make': + # Make generator hasn't set the default value for LD. + # You can remove the following assertion as long as it doesn't + # break existing projects. + test.must_not_contain('Makefile', 'LD ?= ') + return + elif test.format in ['ninja', 'xcode-ninja']: + if sys.platform == 'win32': + ld_expected = 'link.exe' + else: + ld_expected = '$cc' + if test.format == 'make': + test.must_contain('Makefile', 'LD ?= %s' % ld_expected) + elif test.format in ['ninja', 'xcode-ninja']: + test.must_contain('out/Default/build.ninja', 'ld = %s' % ld_expected) + else: + test.fail_test() + + +def verify_ld_host(test, ld=None, rel_path=False): + if rel_path: + ld_expected = resolve_path(test, ld) + else: + ld_expected = ld + # Resolve default values + if ld_expected is None: + if test.format == 'make': + # Make generator hasn't set the default value for LD.host. + # You can remove the following assertion as long as it doesn't + # break existing projects. + test.must_not_contain('Makefile', 'LD.host ?= ') + return + elif test.format in ['ninja', 'xcode-ninja']: + if sys.platform == 'win32': + ld_expected = '$ld' + else: + ld_expected = '$cc_host' + if test.format == 'make': + test.must_contain('Makefile', 'LD.host ?= %s' % ld_expected) + elif test.format in ['ninja', 'xcode-ninja']: + test.must_contain('out/Default/build.ninja', 'ld_host = %s' % ld_expected) + else: + test.fail_test() + + +test_format = ['ninja'] +if sys.platform.startswith('linux') or sys.platform == 'darwin': + test_format += ['make'] + +test = TestGyp.TestGyp(formats=test_format) + +# Check default values +test.run_gyp('make_global_settings_ld.gyp') +verify_ld_target(test) + + +# Check default values with GYP_CROSSCOMPILE enabled. +with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): + test.run_gyp('make_global_settings_ld.gyp') +verify_ld_target(test) +verify_ld_host(test) + + +# Test 'LD' in 'make_global_settings'. +with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): + test.run_gyp('make_global_settings_ld.gyp', '-Dcustom_ld_target=my_ld') +verify_ld_target(test, ld='my_ld', rel_path=True) + + +# Test 'LD'/'LD.host' in 'make_global_settings'. +with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1'}): + test.run_gyp('make_global_settings_ld.gyp', + '-Dcustom_ld_target=my_ld_target1', + '-Dcustom_ld_host=my_ld_host1') +verify_ld_target(test, ld='my_ld_target1', rel_path=True) +verify_ld_host(test, ld='my_ld_host1', rel_path=True) + + +# Unlike other environment variables such as $AR/$AR_host, $CC/$CC_host, +# and $CXX/$CXX_host, neither Make generator nor Ninja generator recognizes +# $LD/$LD_host environment variables as of r1935. This may or may not be +# intentional, but here we leave a test case to verify this behavior just for +# the record. +# If you want to support $LD/$LD_host, please revise the following test case as +# well as the generator. +with TestGyp.LocalEnv({'GYP_CROSSCOMPILE': '1', + 'LD': 'my_ld_target2', + 'LD_host': 'my_ld_host2'}): + test.run_gyp('make_global_settings_ld.gyp') +if test.format == 'make': + test.must_not_contain('Makefile', 'my_ld_target2') + test.must_not_contain('Makefile', 'my_ld_host2') +elif test.format == 'ninja': + test.must_not_contain('out/Default/build.ninja', 'my_ld_target2') + test.must_not_contain('out/Default/build.ninja', 'my_ld_host2') + + +test.pass_test() diff --git a/third_party/python/gyp/test/make_global_settings/ld/make_global_settings_ld.gyp b/third_party/python/gyp/test/make_global_settings/ld/make_global_settings_ld.gyp new file mode 100644 index 0000000000..6837c77326 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/ld/make_global_settings_ld.gyp @@ -0,0 +1,29 @@ +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style licence that can be +# found in the LICENSE file. + +{ + 'variables': { + 'custom_ld_target%': '', + 'custom_ld_host%': '', + }, + 'conditions': [ + ['"<(custom_ld_target)"!=""', { + 'make_global_settings': [ + ['LD', '<(custom_ld_target)'], + ], + }], + ['"<(custom_ld_host)"!=""', { + 'make_global_settings': [ + ['LD.host', '<(custom_ld_host)'], + ], + }], + ], + 'targets': [ + { + 'target_name': 'make_global_settings_ld_test', + 'type': 'static_library', + 'sources': [ 'foo.c' ], + }, + ], +} diff --git a/third_party/python/gyp/test/make_global_settings/wrapper/gyptest-wrapper.py b/third_party/python/gyp/test/make_global_settings/wrapper/gyptest-wrapper.py new file mode 100644 index 0000000000..7ef4314b3e --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/wrapper/gyptest-wrapper.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +# Copyright (c) 2013 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies *_wrapper in make_global_settings. +""" + +from __future__ import print_function + +import os +import sys +import TestGyp + +print("This test is currently disabled: https://crbug.com/483696.") +sys.exit(0) + +test_format = ['ninja'] +if sys.platform.startswith('linux') or sys.platform == 'darwin': + test_format += ['make'] + +test = TestGyp.TestGyp(formats=test_format) + +old_env = dict(os.environ) +os.environ['GYP_CROSSCOMPILE'] = '1' +test.run_gyp('wrapper.gyp') +os.environ.clear() +os.environ.update(old_env) + +if test.format == 'make': + cc_expected = """ifneq (,$(filter $(origin CC), undefined default)) + CC = $(abspath distcc) $(abspath clang) +endif +""" + link_expected = 'LINK ?= $(abspath distlink) $(abspath clang++)' + test.must_contain('Makefile', cc_expected) + test.must_contain('Makefile', link_expected) +if test.format == 'ninja': + cc_expected = ('cc = ' + os.path.join('..', '..', 'distcc') + ' ' + + os.path.join('..', '..', 'clang')) + cc_host_expected = ('cc_host = ' + os.path.join('..', '..', 'ccache') + ' ' + + os.path.join('..', '..', 'clang')) + ld_expected = 'ld = ../../distlink $cc' + if sys.platform == 'win32': + ld_expected = 'link.exe' + test.must_contain('out/Default/build.ninja', cc_expected) + test.must_contain('out/Default/build.ninja', cc_host_expected) + test.must_contain('out/Default/build.ninja', ld_expected) + +test.pass_test() diff --git a/third_party/python/gyp/test/make_global_settings/wrapper/wrapper.gyp b/third_party/python/gyp/test/make_global_settings/wrapper/wrapper.gyp new file mode 100644 index 0000000000..3d4cd04b16 --- /dev/null +++ b/third_party/python/gyp/test/make_global_settings/wrapper/wrapper.gyp @@ -0,0 +1,21 @@ +# Copyright (c) 2013 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'make_global_settings': [ + ['CC', 'clang'], + ['CC_wrapper', 'distcc'], + ['LINK', 'clang++'], + ['LINK_wrapper', 'distlink'], + ['CC.host', 'clang'], + ['CC.host_wrapper', 'ccache'], + ], + 'targets': [ + { + 'target_name': 'test', + 'type': 'static_library', + 'sources': [ 'foo.c' ], + }, + ], +} -- cgit v1.2.3