| 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 sys |
| 14 import TestGyp | 14 import TestGyp |
| 15 | 15 |
| 16 env_stack = [] | 16 env_stack = [] |
| 17 | 17 |
| 18 | 18 |
| 19 def PushEnv(): | 19 def PushEnv(): |
| 20 env_copy = os.environ.copy() | 20 env_copy = os.environ.copy() |
| 21 env_stack.append(env_copy) | 21 env_stack.append(env_copy) |
| 22 | 22 |
| 23 def PopEnv(): | 23 def PopEnv(): |
| 24 os.environ.clear() | 24 os.environ.clear() |
| 25 os.environ.update(env_stack.pop()) | 25 os.environ.update(env_stack.pop()) |
| 26 | 26 |
| 27 formats = ['make'] | 27 formats = ['make', 'ninja'] |
| 28 if sys.platform.startswith('linux'): | |
| 29 # Only Linux ninja generator supports CFLAGS. | |
| 30 formats.append('ninja') | |
| 31 | 28 |
| 32 test = TestGyp.TestGyp(formats=formats) | 29 test = TestGyp.TestGyp(formats=formats) |
| 33 | 30 |
| 34 try: | 31 try: |
| 35 PushEnv() | 32 PushEnv() |
| 36 os.environ['CFLAGS'] = '' | 33 os.environ['CFLAGS'] = '' |
| 37 os.environ['GYP_CROSSCOMPILE'] = '1' | 34 os.environ['GYP_CROSSCOMPILE'] = '1' |
| 38 test.run_gyp('cflags.gyp') | 35 test.run_gyp('cflags.gyp') |
| 39 test.build('cflags.gyp') | 36 test.build('cflags.gyp') |
| 40 finally: | 37 finally: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 # We clear the environ after calling gyp. When the auto-regeneration happens, | 95 # We clear the environ after calling gyp. When the auto-regeneration happens, |
| 99 # the same define should be reused anyway. Reset to empty string first in | 96 # the same define should be reused anyway. Reset to empty string first in |
| 100 # case the platform doesn't support unsetenv. | 97 # case the platform doesn't support unsetenv. |
| 101 PopEnv() | 98 PopEnv() |
| 102 | 99 |
| 103 | 100 |
| 104 expect = """FOO defined\n""" | 101 expect = """FOO defined\n""" |
| 105 test.run_built_executable('cflags', stdout=expect) | 102 test.run_built_executable('cflags', stdout=expect) |
| 106 | 103 |
| 107 test.pass_test() | 104 test.pass_test() |
| OLD | NEW |