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 --generator-output= behavior when using actions. 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: # All the generated files should go under 'gypfiles'. The source directory michael@0: # ('actions') should be untouched. michael@0: test.writable(test.workpath('actions'), False) michael@0: test.run_gyp('actions.gyp', michael@0: '--generator-output=' + test.workpath('gypfiles'), michael@0: chdir='actions') michael@0: michael@0: test.writable(test.workpath('actions'), True) michael@0: michael@0: test.relocate('actions', 'relocate/actions') michael@0: test.relocate('gypfiles', 'relocate/gypfiles') michael@0: michael@0: test.writable(test.workpath('relocate/actions'), False) michael@0: michael@0: # Some of the action outputs use "pure" relative paths (i.e. without prefixes michael@0: # like <(INTERMEDIATE_DIR) or <(PROGRAM_DIR)). Even though we are building under michael@0: # 'gypfiles', such outputs will still be created relative to the original .gyp michael@0: # sources. Projects probably wouldn't normally do this, since it kind of defeats michael@0: # the purpose of '--generator-output', but it is supported behaviour. michael@0: test.writable(test.workpath('relocate/actions/build'), True) michael@0: test.writable(test.workpath('relocate/actions/subdir1/build'), True) michael@0: test.writable(test.workpath('relocate/actions/subdir1/actions-out'), True) michael@0: test.writable(test.workpath('relocate/actions/subdir2/build'), True) michael@0: test.writable(test.workpath('relocate/actions/subdir2/actions-out'), True) michael@0: michael@0: test.build('actions.gyp', test.ALL, chdir='relocate/gypfiles') michael@0: michael@0: expect = """\ michael@0: Hello from program.c michael@0: Hello from make-prog1.py michael@0: Hello from make-prog2.py michael@0: """ michael@0: michael@0: if test.format == 'xcode': michael@0: chdir = 'relocate/actions/subdir1' michael@0: else: michael@0: chdir = 'relocate/gypfiles' michael@0: test.run_built_executable('program', chdir=chdir, stdout=expect) michael@0: michael@0: test.must_match('relocate/actions/subdir2/actions-out/file.out', michael@0: "Hello from make-file.py\n") michael@0: michael@0: test.pass_test()