1#!/usr/bin/env python
2
3# Copyright 2014 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 building a project hierarchy created when the --generator-output=
9and --depth= options is used to put the build configuration files in a separate
10directory tree.
11"""
12
13import TestGyp
14import os
15
16# This is a regression test for the make generator only.
17test = TestGyp.TestGyp(formats=['make'])
18
19test.writable(test.workpath('src'), False)
20
21toplevel_dir = os.path.basename(test.workpath())
22
23test.run_gyp(os.path.join(toplevel_dir, 'src', 'prog1.gyp'),
24             '-Dset_symroot=1',
25             '--generator-output=gypfiles',
26             depth=toplevel_dir,
27             chdir='..')
28
29test.writable(test.workpath('src/build'), True)
30test.writable(test.workpath('src/subdir2/build'), True)
31test.writable(test.workpath('src/subdir3/build'), True)
32
33test.build('prog1.gyp', test.ALL, chdir='gypfiles')
34
35chdir = 'gypfiles'
36
37expect = """\
38Hello from %s
39Hello from inc.h
40Hello from inc1/include1.h
41Hello from inc2/include2.h
42Hello from inc3/include3.h
43Hello from subdir2/deeper/deeper.h
44"""
45
46if test.format == 'xcode':
47  chdir = 'src'
48test.run_built_executable('prog1', chdir=chdir, stdout=expect % 'prog1.c')
49
50if test.format == 'xcode':
51  chdir = 'src/subdir2'
52test.run_built_executable('prog2', chdir=chdir, stdout=expect % 'prog2.c')
53
54if test.format == 'xcode':
55  chdir = 'src/subdir3'
56test.run_built_executable('prog3', chdir=chdir, stdout=expect % 'prog3.c')
57
58test.pass_test()
59