Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | # Copyright (c) 2012 Google Inc. All rights reserved. |
michael@0 | 3 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | # found in the LICENSE file. |
michael@0 | 5 | """ |
michael@0 | 6 | Verifies that the user can override the compiler and linker using CC/CXX/LD |
michael@0 | 7 | environment variables. |
michael@0 | 8 | """ |
michael@0 | 9 | |
michael@0 | 10 | import TestGyp |
michael@0 | 11 | import os |
michael@0 | 12 | import copy |
michael@0 | 13 | import sys |
michael@0 | 14 | |
michael@0 | 15 | here = os.path.dirname(os.path.abspath(__file__)) |
michael@0 | 16 | |
michael@0 | 17 | if sys.platform == 'win32': |
michael@0 | 18 | # cross compiling not support by ninja on windows |
michael@0 | 19 | # and make not supported on windows at all. |
michael@0 | 20 | sys.exit(0) |
michael@0 | 21 | |
michael@0 | 22 | test = TestGyp.TestGyp(formats=['ninja', 'make']) |
michael@0 | 23 | |
michael@0 | 24 | def CheckCompiler(test, gypfile, check_for): |
michael@0 | 25 | test.run_gyp(gypfile) |
michael@0 | 26 | test.build(gypfile) |
michael@0 | 27 | |
michael@0 | 28 | # We can't test to presence of my_ld.py in the output since |
michael@0 | 29 | # ninja will use CXX_target as the linker regardless |
michael@0 | 30 | test.must_contain_all_lines(test.stdout(), check_for) |
michael@0 | 31 | |
michael@0 | 32 | oldenv = os.environ.copy() |
michael@0 | 33 | try: |
michael@0 | 34 | # Check that CC, CXX and LD set target compiler |
michael@0 | 35 | os.environ['CC'] = 'python %s/my_cc.py FOO' % here |
michael@0 | 36 | os.environ['CXX'] = 'python %s/my_cxx.py FOO' % here |
michael@0 | 37 | os.environ['LD'] = 'python %s/my_ld.py FOO_LINK' % here |
michael@0 | 38 | CheckCompiler(test, 'compiler.gyp', |
michael@0 | 39 | ['my_cc.py', 'my_cxx.py', 'FOO', 'FOO_LINK']) |
michael@0 | 40 | finally: |
michael@0 | 41 | os.environ.clear() |
michael@0 | 42 | os.environ.update(oldenv) |
michael@0 | 43 | |
michael@0 | 44 | try: |
michael@0 | 45 | # Check that CC_host sets host compilee |
michael@0 | 46 | os.environ['CC_host'] = 'python %s/my_cc.py HOST' % here |
michael@0 | 47 | os.environ['CXX_host'] = 'python %s/my_cxx.py HOST' % here |
michael@0 | 48 | os.environ['LD_host'] = 'python %s/my_ld.py HOST_LINK' % here |
michael@0 | 49 | CheckCompiler(test, 'compiler-host.gyp', |
michael@0 | 50 | ['my_cc.py', 'my_cxx.py', 'HOST', 'HOST_LINK']) |
michael@0 | 51 | finally: |
michael@0 | 52 | os.environ.clear() |
michael@0 | 53 | os.environ.update(oldenv) |
michael@0 | 54 | |
michael@0 | 55 | test.pass_test() |