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