OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Verifies build of an executable with C++ define specified by a gyp define, and | 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. | 9 the use of the environment during regeneration when the gyp file changes. |
10 """ | 10 """ |
11 | 11 |
12 import os | 12 import os |
| 13 import sys |
13 import TestGyp | 14 import TestGyp |
14 | 15 |
15 env_stack = [] | 16 env_stack = [] |
16 | 17 |
17 | 18 |
18 def PushEnv(): | 19 def PushEnv(): |
19 env_copy = os.environ.copy() | 20 env_copy = os.environ.copy() |
20 env_stack.append(env_copy) | 21 env_stack.append(env_copy) |
21 | 22 |
22 def PopEnv(): | 23 def PopEnv(): |
23 os.eniron=env_stack.pop() | 24 os.eniron=env_stack.pop() |
24 | 25 |
25 # Regenerating build files when a gyp file changes is currently only supported | 26 formats = ['make'] |
26 # by the make generator. | 27 if sys.platform.startswith('linux'): |
27 test = TestGyp.TestGyp(formats=['make']) | 28 # Only Linux ninja generator supports CFLAGS. |
| 29 formats.append('ninja') |
| 30 |
| 31 test = TestGyp.TestGyp(formats=formats) |
28 | 32 |
29 try: | 33 try: |
30 PushEnv() | 34 PushEnv() |
31 os.environ['CFLAGS'] = '-O0' | 35 os.environ['CFLAGS'] = '-O0' |
32 test.run_gyp('cflags.gyp') | 36 test.run_gyp('cflags.gyp') |
33 finally: | 37 finally: |
34 # We clear the environ after calling gyp. When the auto-regeneration happens, | 38 # We clear the environ after calling gyp. When the auto-regeneration happens, |
35 # the same define should be reused anyway. Reset to empty string first in | 39 # the same define should be reused anyway. Reset to empty string first in |
36 # case the platform doesn't support unsetenv. | 40 # case the platform doesn't support unsetenv. |
37 PopEnv() | 41 PopEnv() |
(...skipping 18 matching lines...) Expand all Loading... |
56 PopEnv() | 60 PopEnv() |
57 | 61 |
58 test.build('cflags.gyp') | 62 test.build('cflags.gyp') |
59 | 63 |
60 expect = """\ | 64 expect = """\ |
61 Using an optimization flag | 65 Using an optimization flag |
62 """ | 66 """ |
63 test.run_built_executable('cflags', stdout=expect) | 67 test.run_built_executable('cflags', stdout=expect) |
64 | 68 |
65 test.pass_test() | 69 test.pass_test() |
OLD | NEW |