• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2
3# Copyright (c) 2012 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"""
8Verify that building an object file correctly depends on running actions in
9dependent targets, but not the targets themselves.
10"""
11
12import os
13import sys
14
15if sys.platform == 'win32':
16  print "This test is currently disabled: https://crbug.com/483696."
17  sys.exit(0)
18
19
20import TestGyp
21
22# NOTE(piman): This test will not work with other generators because:
23# - it explicitly tests the optimization, which is not implemented (yet?) on
24# other generators
25# - it relies on the exact path to output object files, which is generator
26# dependent, and actually, relies on the ability to build only that object file,
27# which I don't think is available on all generators.
28# TODO(piman): Extend to other generators when possible.
29test = TestGyp.TestGyp(formats=['ninja'])
30# xcode-ninja doesn't support building single object files by design.
31if test.format == 'xcode-ninja':
32  test.skip_test()
33
34test.run_gyp('action_dependencies.gyp', chdir='src')
35
36chdir = 'relocate/src'
37test.relocate('src', chdir)
38
39objext = '.obj' if sys.platform == 'win32' else '.o'
40
41test.build('action_dependencies.gyp',
42           os.path.join('obj', 'b.b' + objext),
43           chdir=chdir)
44
45# The 'a' actions should be run (letting b.c compile), but the a static library
46# should not be built.
47test.built_file_must_not_exist('a', type=test.STATIC_LIB, chdir=chdir)
48test.built_file_must_not_exist('b', type=test.STATIC_LIB, chdir=chdir)
49test.built_file_must_exist(os.path.join('obj', 'b.b' + objext), chdir=chdir)
50
51test.build('action_dependencies.gyp',
52           os.path.join('obj', 'c.c' + objext),
53           chdir=chdir)
54
55# 'a' and 'b' should be built, so that the 'c' action succeeds, letting c.c
56# compile
57test.built_file_must_exist('a', type=test.STATIC_LIB, chdir=chdir)
58test.built_file_must_exist('b', type=test.EXECUTABLE, chdir=chdir)
59test.built_file_must_exist(os.path.join('obj', 'c.c' + objext), chdir=chdir)
60
61
62test.pass_test()
63