OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 """ |
| 6 Verifies that the user can override the compiler and linker using LD_target |
| 7 and CC_target. |
| 8 """ |
| 9 |
| 10 import TestGyp |
| 11 import os |
| 12 import copy |
| 13 |
| 14 here = os.path.dirname(os.path.abspath(__file__)) |
| 15 |
| 16 test = TestGyp.TestGyp(formats=['ninja', 'make']) |
| 17 |
| 18 def CheckCompiler(test, gypfile, check_for): |
| 19 test.run_gyp(gypfile) |
| 20 test.build(gypfile) |
| 21 |
| 22 # We can't test to presence of my_ld.py in the output since |
| 23 # ninja will use CXX_target as the linker regardless |
| 24 test.must_contain_all_lines(test.stdout(), check_for) |
| 25 |
| 26 oldenv = os.environ.copy() |
| 27 try: |
| 28 # Check that CC, CXX and LD set target compiler |
| 29 os.environ['CC'] = 'python %s/my_cc.py FOO' % here |
| 30 os.environ['CXX'] = 'python %s/my_cxx.py FOO' % here |
| 31 os.environ['LD'] = 'python %s/my_ld.py FOO' % here |
| 32 CheckCompiler(test, 'compiler.gyp', ['my_cc.py', 'my_cxx.py', 'FOO']) |
| 33 |
| 34 # Check that the old behaviour of setting CC_target still |
| 35 # overrides CC as target compiler |
| 36 os.environ['CC_target'] = 'python %s/my_cc.py BAR' % here |
| 37 os.environ['CXX_target'] = 'python %s/my_cxx.py BAR' % here |
| 38 os.environ['LD_target'] = 'python %s/my_ld.py BAR' % here |
| 39 CheckCompiler(test, 'compiler.gyp', ['my_cc.py', 'my_cxx.py', 'BAR']) |
| 40 finally: |
| 41 os.environ.clear() |
| 42 os.environ.update(oldenv) |
| 43 |
| 44 try: |
| 45 # Check that CC_host sets host compilee |
| 46 os.environ['CC_host'] = 'python %s/my_cc.py HOST' % here |
| 47 os.environ['CXX_host'] = 'python %s/my_cxx.py HOST' % here |
| 48 os.environ['LD_host'] = 'python %s/my_ld.py HOST' % here |
| 49 CheckCompiler(test, 'compiler-host.gyp', ['my_cc.py', 'my_cxx.py', 'HOST']) |
| 50 finally: |
| 51 os.environ.clear() |
| 52 os.environ.update(oldenv) |
| 53 |
| 54 test.pass_test() |
OLD | NEW |