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 make_global_settings can be used to override the michael@0: compiler settings. michael@0: """ michael@0: michael@0: import TestGyp michael@0: import os michael@0: import copy michael@0: import sys michael@0: from string import Template michael@0: 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: gypfile = 'compiler-global-settings.gyp' michael@0: michael@0: replacements = { 'PYTHON': '/usr/bin/python', 'PWD': os.getcwd()} michael@0: michael@0: # Process the .in gyp file to produce the final gyp file michael@0: # since we need to include absolute paths in the make_global_settings michael@0: # section. michael@0: replacements['TOOLSET'] = 'target' michael@0: s = Template(open(gypfile + '.in').read()) michael@0: output = open(gypfile, 'w') michael@0: output.write(s.substitute(replacements)) michael@0: output.close() michael@0: michael@0: test.run_gyp(gypfile) michael@0: test.build(gypfile) michael@0: test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'FOO']) michael@0: michael@0: # Same again but with the host toolset. michael@0: replacements['TOOLSET'] = 'host' michael@0: s = Template(open(gypfile + '.in').read()) michael@0: output = open(gypfile, 'w') michael@0: output.write(s.substitute(replacements)) michael@0: output.close() michael@0: michael@0: test.run_gyp(gypfile) michael@0: test.build(gypfile) michael@0: test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'BAR']) michael@0: michael@0: test.pass_test()