1#!/usr/bin/env python 2 3# Copyright (c) 2013 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 *_wrapper in make_global_settings. 9""" 10 11import os 12import sys 13import TestGyp 14 15test_format = ['ninja'] 16if sys.platform in ('linux2', 'darwin'): 17 test_format += ['make'] 18 19test = TestGyp.TestGyp(formats=test_format) 20 21old_env = dict(os.environ) 22os.environ['GYP_CROSSCOMPILE'] = '1' 23test.run_gyp('wrapper.gyp') 24os.environ.clear() 25os.environ.update(old_env) 26 27if test.format == 'make': 28 cc_expected = """ifneq (,$(filter $(origin CC), undefined default)) 29 CC = $(abspath distcc) $(abspath clang) 30endif 31""" 32 link_expected = 'LINK ?= $(abspath distlink) $(abspath clang++)' 33 test.must_contain('Makefile', cc_expected) 34 test.must_contain('Makefile', link_expected) 35if test.format == 'ninja': 36 cc_expected = ('cc = ' + os.path.join('..', '..', 'distcc') + ' ' + 37 os.path.join('..', '..', 'clang')) 38 cc_host_expected = ('cc_host = ' + os.path.join('..', '..', 'ccache') + ' ' + 39 os.path.join('..', '..', 'clang')) 40 ld_expected = 'ld = ../../distlink $cxx' 41 if sys.platform == 'win32': 42 ld_expected = 'link.exe' 43 test.must_contain('out/Default/build.ninja', cc_expected) 44 test.must_contain('out/Default/build.ninja', cc_host_expected) 45 test.must_contain('out/Default/build.ninja', ld_expected) 46 47test.pass_test() 48