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-global-settings.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 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 make_global_settings can be used to override the 1.10 +compiler settings. 1.11 +""" 1.12 + 1.13 +import TestGyp 1.14 +import os 1.15 +import copy 1.16 +import sys 1.17 +from string import Template 1.18 + 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 +gypfile = 'compiler-global-settings.gyp' 1.28 + 1.29 +replacements = { 'PYTHON': '/usr/bin/python', 'PWD': os.getcwd()} 1.30 + 1.31 +# Process the .in gyp file to produce the final gyp file 1.32 +# since we need to include absolute paths in the make_global_settings 1.33 +# section. 1.34 +replacements['TOOLSET'] = 'target' 1.35 +s = Template(open(gypfile + '.in').read()) 1.36 +output = open(gypfile, 'w') 1.37 +output.write(s.substitute(replacements)) 1.38 +output.close() 1.39 + 1.40 +test.run_gyp(gypfile) 1.41 +test.build(gypfile) 1.42 +test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'FOO']) 1.43 + 1.44 +# Same again but with the host toolset. 1.45 +replacements['TOOLSET'] = 'host' 1.46 +s = Template(open(gypfile + '.in').read()) 1.47 +output = open(gypfile, 'w') 1.48 +output.write(s.substitute(replacements)) 1.49 +output.close() 1.50 + 1.51 +test.run_gyp(gypfile) 1.52 +test.build(gypfile) 1.53 +test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'BAR']) 1.54 + 1.55 +test.pass_test()