OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2011 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 Verify that building an object file correctly depends on running actions in | 8 Verify that building an object file correctly depends on running actions in |
9 dependent targets, but not the targets themselves. | 9 dependent targets, but not the targets themselves. |
10 """ | 10 """ |
11 | 11 |
| 12 import os |
| 13 import sys |
12 import TestGyp | 14 import TestGyp |
13 | 15 |
14 # NOTE(piman): This test will not work with other generators because: | 16 # NOTE(piman): This test will not work with other generators because: |
15 # - it explicitly tests the optimization, which is not implemented (yet?) on | 17 # - it explicitly tests the optimization, which is not implemented (yet?) on |
16 # other generators | 18 # other generators |
17 # - it relies on the exact path to output object files, which is generator | 19 # - it relies on the exact path to output object files, which is generator |
18 # dependent, and actually, relies on the ability to build only that object file, | 20 # dependent, and actually, relies on the ability to build only that object file, |
19 # which I don't think is available on all generators. | 21 # which I don't think is available on all generators. |
20 # TODO(piman): Extend to other generators when possible. | 22 # TODO(piman): Extend to other generators when possible. |
21 test = TestGyp.TestGyp(formats=['ninja']) | 23 test = TestGyp.TestGyp(formats=['ninja']) |
22 | 24 |
23 test.run_gyp('action_dependencies.gyp', chdir='src') | 25 test.run_gyp('action_dependencies.gyp', chdir='src') |
24 | 26 |
25 chdir = 'relocate/src' | 27 chdir = 'relocate/src' |
26 test.relocate('src', chdir) | 28 test.relocate('src', chdir) |
27 | 29 |
28 test.build('action_dependencies.gyp', 'obj/b.b.o', chdir=chdir) | 30 objext = '.obj' if sys.platform == 'win32' else '.o' |
| 31 |
| 32 test.build('action_dependencies.gyp', |
| 33 os.path.join('obj', 'b.b' + objext), |
| 34 chdir=chdir) |
29 | 35 |
30 # The 'a' actions should be run (letting b.c compile), but the a static library | 36 # The 'a' actions should be run (letting b.c compile), but the a static library |
31 # should not be built. | 37 # should not be built. |
32 test.built_file_must_not_exist('a', type=test.STATIC_LIB, chdir=chdir) | 38 test.built_file_must_not_exist('a', type=test.STATIC_LIB, chdir=chdir) |
33 test.built_file_must_not_exist('b', type=test.STATIC_LIB, chdir=chdir) | 39 test.built_file_must_not_exist('b', type=test.STATIC_LIB, chdir=chdir) |
34 test.built_file_must_exist('obj/b.b.o', chdir=chdir) | 40 test.built_file_must_exist(os.path.join('obj', 'b.b' + objext), chdir=chdir) |
35 | 41 |
36 test.build('action_dependencies.gyp', 'obj/c.c.o', chdir=chdir) | 42 test.build('action_dependencies.gyp', |
| 43 os.path.join('obj', 'c.c' + objext), |
| 44 chdir=chdir) |
37 | 45 |
38 # 'a' and 'b' should be built, so that the 'c' action succeeds, letting c.c | 46 # 'a' and 'b' should be built, so that the 'c' action succeeds, letting c.c |
39 # compile | 47 # compile |
40 test.built_file_must_exist('a', type=test.STATIC_LIB, chdir=chdir) | 48 test.built_file_must_exist('a', type=test.STATIC_LIB, chdir=chdir) |
41 test.built_file_must_exist('b', type=test.EXECUTABLE, chdir=chdir) | 49 test.built_file_must_exist('b', type=test.EXECUTABLE, chdir=chdir) |
42 test.built_file_must_exist('obj/c.c.o', chdir=chdir) | 50 test.built_file_must_exist(os.path.join('obj', 'c.c' + objext), chdir=chdir) |
43 | 51 |
44 | 52 |
45 test.pass_test() | 53 test.pass_test() |
OLD | NEW |