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 build of an executable with C++ define specified by a gyp define, and
9 the use of the environment during regeneration when the gyp file changes.
20 env_copy = os.environ.copy()
21 env_stack.append(env_copy)
25 os.environ.update(env_stack.pop())
27 formats = ['make', 'ninja']
29 test = TestGyp.TestGyp(formats=formats)
33 os.environ['CFLAGS'] = ''
34 os.environ['GYP_CROSSCOMPILE'] = '1'
35 test.run_gyp('cflags.gyp')
36 test.build('cflags.gyp')
38 # We clear the environ after calling gyp. When the auto-regeneration happens,
39 # the same define should be reused anyway. Reset to empty string first in
40 # case the platform doesn't support unsetenv.
44 expect = """FOO not defined\n"""
45 test.run_built_executable('cflags', stdout=expect)
46 test.run_built_executable('cflags_host', stdout=expect)
52 os.environ['CFLAGS'] = '-DFOO=1'
53 os.environ['GYP_CROSSCOMPILE'] = '1'
54 test.run_gyp('cflags.gyp')
55 test.build('cflags.gyp')
57 # We clear the environ after calling gyp. When the auto-regeneration happens,
58 # the same define should be reused anyway. Reset to empty string first in
59 # case the platform doesn't support unsetenv.
63 expect = """FOO defined\n"""
64 test.run_built_executable('cflags', stdout=expect)
66 # Environment variables shouldn't influence the flags for the host.
67 expect = """FOO not defined\n"""
68 test.run_built_executable('cflags_host', stdout=expect)
74 os.environ['CFLAGS'] = ''
75 test.run_gyp('cflags.gyp')
76 test.build('cflags.gyp')
78 # We clear the environ after calling gyp. When the auto-regeneration happens,
79 # the same define should be reused anyway. Reset to empty string first in
80 # case the platform doesn't support unsetenv.
84 expect = """FOO not defined\n"""
85 test.run_built_executable('cflags', stdout=expect)
91 os.environ['CFLAGS'] = '-DFOO=1'
92 test.run_gyp('cflags.gyp')
93 test.build('cflags.gyp')
95 # We clear the environ after calling gyp. When the auto-regeneration happens,
96 # the same define should be reused anyway. Reset to empty string first in
97 # case the platform doesn't support unsetenv.
101 expect = """FOO defined\n"""
102 test.run_built_executable('cflags', stdout=expect)