michael@0: #!/usr/bin/env python michael@0: # Copyright (c) 2012 Google Inc. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: """ michael@0: Verifies that the user can override the compiler and linker using CC/CXX/LD michael@0: environment variables. michael@0: """ michael@0: michael@0: import TestGyp michael@0: import os michael@0: import copy michael@0: import sys michael@0: michael@0: here = os.path.dirname(os.path.abspath(__file__)) michael@0: michael@0: if sys.platform == 'win32': michael@0: # cross compiling not support by ninja on windows michael@0: # and make not supported on windows at all. michael@0: sys.exit(0) michael@0: michael@0: test = TestGyp.TestGyp(formats=['ninja', 'make']) michael@0: michael@0: def CheckCompiler(test, gypfile, check_for): michael@0: test.run_gyp(gypfile) michael@0: test.build(gypfile) michael@0: michael@0: # We can't test to presence of my_ld.py in the output since michael@0: # ninja will use CXX_target as the linker regardless michael@0: test.must_contain_all_lines(test.stdout(), check_for) michael@0: michael@0: oldenv = os.environ.copy() michael@0: try: michael@0: # Check that CC, CXX and LD set target compiler michael@0: os.environ['CC'] = 'python %s/my_cc.py FOO' % here michael@0: os.environ['CXX'] = 'python %s/my_cxx.py FOO' % here michael@0: os.environ['LD'] = 'python %s/my_ld.py FOO_LINK' % here michael@0: CheckCompiler(test, 'compiler.gyp', michael@0: ['my_cc.py', 'my_cxx.py', 'FOO', 'FOO_LINK']) michael@0: finally: michael@0: os.environ.clear() michael@0: os.environ.update(oldenv) michael@0: michael@0: try: michael@0: # Check that CC_host sets host compilee michael@0: os.environ['CC_host'] = 'python %s/my_cc.py HOST' % here michael@0: os.environ['CXX_host'] = 'python %s/my_cxx.py HOST' % here michael@0: os.environ['LD_host'] = 'python %s/my_ld.py HOST_LINK' % here michael@0: CheckCompiler(test, 'compiler-host.gyp', michael@0: ['my_cc.py', 'my_cxx.py', 'HOST', 'HOST_LINK']) michael@0: finally: michael@0: os.environ.clear() michael@0: os.environ.update(oldenv) michael@0: michael@0: test.pass_test()