5
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.
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.
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'
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'}):
35
25
test.run_gyp('cflags.gyp')
36
26
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
28
expect = """FOO not defined\n"""
45
29
test.run_built_executable('cflags', stdout=expect)
52
os.environ['CFLAGS'] = '-DFOO=1'
53
os.environ['GYP_CROSSCOMPILE'] = '1'
34
with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1',
35
'GYP_CROSSCOMPILE': '1'}):
54
36
test.run_gyp('cflags.gyp')
55
37
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
39
expect = """FOO defined\n"""
64
40
test.run_built_executable('cflags', stdout=expect)
74
os.environ['CFLAGS'] = ''
48
with TestGyp.LocalEnv({'CFLAGS': ''}):
75
49
test.run_gyp('cflags.gyp')
76
50
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
52
expect = """FOO not defined\n"""
85
53
test.run_built_executable('cflags', stdout=expect)
91
os.environ['CFLAGS'] = '-DFOO=1'
57
with TestGyp.LocalEnv({'CFLAGS': '-DFOO=1'}):
92
58
test.run_gyp('cflags.gyp')
93
59
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
61
expect = """FOO defined\n"""
102
62
test.run_built_executable('cflags', stdout=expect)