michael@0: #!/usr/bin/env python michael@0: michael@0: # Copyright (c) 2012 Google Inc. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: """ michael@0: Verifies that a project hierarchy created with the --generator-output= michael@0: option can be built even when it's relocated to a different path. michael@0: """ michael@0: michael@0: import TestGyp michael@0: michael@0: # Ninja and Android don't support --generator-output. michael@0: test = TestGyp.TestGyp(formats=['!ninja', '!android']) michael@0: michael@0: test.writable(test.workpath('src'), False) michael@0: michael@0: test.run_gyp('prog1.gyp', michael@0: '-Dset_symroot=1', michael@0: '--generator-output=' + test.workpath('gypfiles'), michael@0: chdir='src') michael@0: michael@0: test.writable(test.workpath('src'), True) michael@0: michael@0: test.relocate('src', 'relocate/src') michael@0: test.relocate('gypfiles', 'relocate/gypfiles') michael@0: michael@0: test.writable(test.workpath('relocate/src'), False) michael@0: michael@0: test.writable(test.workpath('relocate/src/build'), True) michael@0: test.writable(test.workpath('relocate/src/subdir2/build'), True) michael@0: test.writable(test.workpath('relocate/src/subdir3/build'), True) michael@0: michael@0: test.build('prog1.gyp', test.ALL, chdir='relocate/gypfiles') michael@0: michael@0: chdir = 'relocate/gypfiles' michael@0: michael@0: expect = """\ michael@0: Hello from %s michael@0: Hello from inc.h michael@0: Hello from inc1/include1.h michael@0: Hello from inc2/include2.h michael@0: Hello from inc3/include3.h michael@0: Hello from subdir2/deeper/deeper.h michael@0: """ michael@0: michael@0: if test.format == 'xcode': michael@0: chdir = 'relocate/src' michael@0: test.run_built_executable('prog1', chdir=chdir, stdout=expect % 'prog1.c') michael@0: michael@0: if test.format == 'xcode': michael@0: chdir = 'relocate/src/subdir2' michael@0: test.run_built_executable('prog2', chdir=chdir, stdout=expect % 'prog2.c') michael@0: michael@0: if test.format == 'xcode': michael@0: chdir = 'relocate/src/subdir3' michael@0: test.run_built_executable('prog3', chdir=chdir, stdout=expect % 'prog3.c') michael@0: michael@0: test.pass_test()