3 # Copyright (c) 2012 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
8 Verifies the use of the environment during regeneration when the gyp file
9 changes, specifically via build of an executable with C preprocessor
10 definition specified by CFLAGS.
12 In this test, gyp and build both run in same local environment.
17 # CPPFLAGS works in ninja but not make; CFLAGS works in both
18 FORMATS = ('make', 'ninja')
20 test = TestGyp.TestGyp(formats=FORMATS)
22 # First set CFLAGS to blank in case the platform doesn't support unsetenv.
23 with TestGyp.LocalEnv({'CFLAGS': '',
24 'GYP_CROSSCOMPILE': '1'}):
25 test.run_gyp('cflags.gyp')
26 test.build('cflags.gyp')
28 expect = """FOO not defined\n"""
29 test.run_built_executable('cflags', stdout=expect)
30 test.run_built_executable('cflags_host', stdout=expect)
34 with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1',
35 'GYP_CROSSCOMPILE': '1'}):
36 test.run_gyp('cflags.gyp')
37 test.build('cflags.gyp')
39 expect = """FOO defined\n"""
40 test.run_built_executable('cflags', stdout=expect)
42 # Environment variables shouldn't influence the flags for the host.
43 expect = """FOO not defined\n"""
44 test.run_built_executable('cflags_host', stdout=expect)
48 with TestGyp.LocalEnv({'CFLAGS': ''}):
49 test.run_gyp('cflags.gyp')
50 test.build('cflags.gyp')
52 expect = """FOO not defined\n"""
53 test.run_built_executable('cflags', stdout=expect)
57 with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1'}):
58 test.run_gyp('cflags.gyp')
59 test.build('cflags.gyp')
61 expect = """FOO defined\n"""
62 test.run_built_executable('cflags', stdout=expect)