1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/trunk/tools/gyp/test/compiler-override/gyptest-compiler-env.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +#!/usr/bin/env python 1.5 +# Copyright (c) 2012 Google Inc. All rights reserved. 1.6 +# Use of this source code is governed by a BSD-style license that can be 1.7 +# found in the LICENSE file. 1.8 +""" 1.9 +Verifies that the user can override the compiler and linker using CC/CXX/LD 1.10 +environment variables. 1.11 +""" 1.12 + 1.13 +import TestGyp 1.14 +import os 1.15 +import copy 1.16 +import sys 1.17 + 1.18 +here = os.path.dirname(os.path.abspath(__file__)) 1.19 + 1.20 +if sys.platform == 'win32': 1.21 + # cross compiling not support by ninja on windows 1.22 + # and make not supported on windows at all. 1.23 + sys.exit(0) 1.24 + 1.25 +test = TestGyp.TestGyp(formats=['ninja', 'make']) 1.26 + 1.27 +def CheckCompiler(test, gypfile, check_for): 1.28 + test.run_gyp(gypfile) 1.29 + test.build(gypfile) 1.30 + 1.31 + # We can't test to presence of my_ld.py in the output since 1.32 + # ninja will use CXX_target as the linker regardless 1.33 + test.must_contain_all_lines(test.stdout(), check_for) 1.34 + 1.35 +oldenv = os.environ.copy() 1.36 +try: 1.37 + # Check that CC, CXX and LD set target compiler 1.38 + os.environ['CC'] = 'python %s/my_cc.py FOO' % here 1.39 + os.environ['CXX'] = 'python %s/my_cxx.py FOO' % here 1.40 + os.environ['LD'] = 'python %s/my_ld.py FOO_LINK' % here 1.41 + CheckCompiler(test, 'compiler.gyp', 1.42 + ['my_cc.py', 'my_cxx.py', 'FOO', 'FOO_LINK']) 1.43 +finally: 1.44 + os.environ.clear() 1.45 + os.environ.update(oldenv) 1.46 + 1.47 +try: 1.48 + # Check that CC_host sets host compilee 1.49 + os.environ['CC_host'] = 'python %s/my_cc.py HOST' % here 1.50 + os.environ['CXX_host'] = 'python %s/my_cxx.py HOST' % here 1.51 + os.environ['LD_host'] = 'python %s/my_ld.py HOST_LINK' % here 1.52 + CheckCompiler(test, 'compiler-host.gyp', 1.53 + ['my_cc.py', 'my_cxx.py', 'HOST', 'HOST_LINK']) 1.54 +finally: 1.55 + os.environ.clear() 1.56 + os.environ.update(oldenv) 1.57 + 1.58 +test.pass_test()