Home | History | Annotate | Download | only in action_dependencies
      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 """
      8 Verify that building an object file correctly depends on running actions in
      9 dependent targets, but not the targets themselves.
     10 """
     11 
     12 import os
     13 import sys
     14 import 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.
     23 test = TestGyp.TestGyp(formats=['ninja'])
     24 
     25 test.run_gyp('action_dependencies.gyp', chdir='src')
     26 
     27 chdir = 'relocate/src'
     28 test.relocate('src', chdir)
     29 
     30 objext = '.obj' if sys.platform == 'win32' else '.o'
     31 
     32 test.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.
     38 test.built_file_must_not_exist('a', type=test.STATIC_LIB, chdir=chdir)
     39 test.built_file_must_not_exist('b', type=test.STATIC_LIB, chdir=chdir)
     40 test.built_file_must_exist(os.path.join('obj', 'b.b' + objext), chdir=chdir)
     41 
     42 test.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
     48 test.built_file_must_exist('a', type=test.STATIC_LIB, chdir=chdir)
     49 test.built_file_must_exist('b', type=test.EXECUTABLE, chdir=chdir)
     50 test.built_file_must_exist(os.path.join('obj', 'c.c' + objext), chdir=chdir)
     51 
     52 
     53 test.pass_test()
     54