initial import
[vuplus_webkit] / Source / ThirdParty / gyp / test / library / gyptest-static.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2009 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.
6
7 """
8 Verifies simple build of a "Hello, world!" program with static libraries,
9 including verifying that libraries are rebuilt correctly when functions
10 move between libraries.
11 """
12
13 import TestGyp
14
15 test = TestGyp.TestGyp()
16
17 test.run_gyp('library.gyp',
18              '-Dlibrary=static_library',
19              '-Dmoveable_function=lib1',
20              chdir='src')
21
22 test.relocate('src', 'relocate/src')
23
24 test.build('library.gyp', test.ALL, chdir='relocate/src')
25
26 expect = """\
27 Hello from program.c
28 Hello from lib1.c
29 Hello from lib2.c
30 Hello from lib1_moveable.c
31 """
32 test.run_built_executable('program', chdir='relocate/src', stdout=expect)
33
34
35 test.run_gyp('library.gyp',
36              '-Dlibrary=static_library',
37              '-Dmoveable_function=lib2',
38              chdir='relocate/src')
39
40 # Update program.c to force a rebuild.
41 test.sleep()
42 contents = test.read('relocate/src/program.c')
43 contents = contents.replace('Hello', 'Hello again')
44 test.write('relocate/src/program.c', contents)
45
46 test.build('library.gyp', test.ALL, chdir='relocate/src')
47
48 expect = """\
49 Hello again from program.c
50 Hello from lib1.c
51 Hello from lib2.c
52 Hello from lib2_moveable.c
53 """
54 test.run_built_executable('program', chdir='relocate/src', stdout=expect)
55
56
57 test.run_gyp('library.gyp',
58              '-Dlibrary=static_library',
59              '-Dmoveable_function=lib1',
60              chdir='relocate/src')
61
62 # Update program.c and lib2.c to force a rebuild.
63 test.sleep()
64 contents = test.read('relocate/src/program.c')
65 contents = contents.replace('again', 'again again')
66 test.write('relocate/src/program.c', contents)
67
68 # TODO(sgk):  we have to force a rebuild of lib2 so that it weeds out
69 # the "moved" module.  This should be done in gyp by adding a dependency
70 # on the generated .vcproj file itself.
71 test.touch('relocate/src/lib2.c')
72
73 test.build('library.gyp', test.ALL, chdir='relocate/src')
74
75 expect = """\
76 Hello again again from program.c
77 Hello from lib1.c
78 Hello from lib2.c
79 Hello from lib1_moveable.c
80 """
81 test.run_built_executable('program', chdir='relocate/src', stdout=expect)
82
83
84 test.pass_test()