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""" 8Verifies simple build of a "Hello, world!" program with static libraries, 9including verifying that libraries are rebuilt correctly when functions 10move between libraries. 11""" 12 13import TestGyp 14 15test = TestGyp.TestGyp() 16 17test.run_gyp('library.gyp', 18 '-Dlibrary=static_library', 19 '-Dmoveable_function=lib1', 20 chdir='src') 21 22test.relocate('src', 'relocate/src') 23 24test.build('library.gyp', test.ALL, chdir='relocate/src') 25 26expect = """\ 27Hello from program.c 28Hello from lib1.c 29Hello from lib2.c 30Hello from lib1_moveable.c 31""" 32test.run_built_executable('program', chdir='relocate/src', stdout=expect) 33 34 35test.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. 41test.sleep() 42contents = test.read('relocate/src/program.c') 43contents = contents.replace('Hello', 'Hello again') 44test.write('relocate/src/program.c', contents) 45 46test.build('library.gyp', test.ALL, chdir='relocate/src') 47 48expect = """\ 49Hello again from program.c 50Hello from lib1.c 51Hello from lib2.c 52Hello from lib2_moveable.c 53""" 54test.run_built_executable('program', chdir='relocate/src', stdout=expect) 55 56 57test.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. 63test.sleep() 64contents = test.read('relocate/src/program.c') 65contents = contents.replace('again', 'again again') 66test.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. 71test.touch('relocate/src/lib2.c') 72 73test.build('library.gyp', test.ALL, chdir='relocate/src') 74 75expect = """\ 76Hello again again from program.c 77Hello from lib1.c 78Hello from lib2.c 79Hello from lib1_moveable.c 80""" 81test.run_built_executable('program', chdir='relocate/src', stdout=expect) 82 83 84test.pass_test() 85