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 14import TestGyp 15 16# NOTE(piman): This test will not work with other generators because: 17# - it explicitly tests the optimization, which is not implemented (yet?) on 18# other generators 19# - it relies on the exact path to output object files, which is generator 20# dependent, and actually, relies on the ability to build only that object file, 21# which I don't think is available on all generators. 22# TODO(piman): Extend to other generators when possible. 23test = TestGyp.TestGyp(formats=['ninja']) 24 25test.run_gyp('action_dependencies.gyp', chdir='src') 26 27chdir = 'relocate/src' 28test.relocate('src', chdir) 29 30objext = '.obj' if sys.platform == 'win32' else '.o' 31 32test.build('action_dependencies.gyp', 33 os.path.join('obj', 'b.b' + objext), 34 chdir=chdir) 35 36# The 'a' actions should be run (letting b.c compile), but the a static library 37# should not be built. 38test.built_file_must_not_exist('a', type=test.STATIC_LIB, chdir=chdir) 39test.built_file_must_not_exist('b', type=test.STATIC_LIB, chdir=chdir) 40test.built_file_must_exist(os.path.join('obj', 'b.b' + objext), chdir=chdir) 41 42test.build('action_dependencies.gyp', 43 os.path.join('obj', 'c.c' + objext), 44 chdir=chdir) 45 46# 'a' and 'b' should be built, so that the 'c' action succeeds, letting c.c 47# compile 48test.built_file_must_exist('a', type=test.STATIC_LIB, chdir=chdir) 49test.built_file_must_exist('b', type=test.EXECUTABLE, chdir=chdir) 50test.built_file_must_exist(os.path.join('obj', 'c.c' + objext), chdir=chdir) 51 52 53test.pass_test() 54