media/webrtc/trunk/tools/gyp/test/compiler-override/gyptest-compiler-global-settings.py

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rwxr-xr-x

Integrate suggestion from review to improve consistency with existing code.

     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 make_global_settings can be used to override the
     7 compiler settings.
     8 """
    10 import TestGyp
    11 import os
    12 import copy
    13 import sys
    14 from string import Template
    17 if sys.platform == 'win32':
    18   # cross compiling not support by ninja on windows
    19   # and make not supported on windows at all.
    20   sys.exit(0)
    22 test = TestGyp.TestGyp(formats=['ninja', 'make'])
    24 gypfile = 'compiler-global-settings.gyp'
    26 replacements = { 'PYTHON': '/usr/bin/python', 'PWD': os.getcwd()}
    28 # Process the .in gyp file to produce the final gyp file
    29 # since we need to include absolute paths in the make_global_settings
    30 # section.
    31 replacements['TOOLSET'] = 'target'
    32 s = Template(open(gypfile + '.in').read())
    33 output = open(gypfile, 'w')
    34 output.write(s.substitute(replacements))
    35 output.close()
    37 test.run_gyp(gypfile)
    38 test.build(gypfile)
    39 test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'FOO'])
    41 # Same again but with the host toolset.
    42 replacements['TOOLSET'] = 'host'
    43 s = Template(open(gypfile + '.in').read())
    44 output = open(gypfile, 'w')
    45 output.write(s.substitute(replacements))
    46 output.close()
    48 test.run_gyp(gypfile)
    49 test.build(gypfile)
    50 test.must_contain_all_lines(test.stdout(), ['my_cc.py', 'my_cxx.py', 'BAR'])
    52 test.pass_test()

mercurial