1a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org#!/usr/bin/env python
2a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
3a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org# Copyright (c) 2013 Google Inc. All rights reserved.
4a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org# Use of this source code is governed by a BSD-style license that can be
5a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org# found in the LICENSE file.
6a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
7a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org"""
8a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgVerifies *_wrapper in environment.
9a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org"""
10a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
11a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgimport os
12a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgimport sys
13a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgimport TestGyp
14a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
15a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgtest_format = ['ninja']
16a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
17a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgos.environ['CC_wrapper'] = 'distcc'
18a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgos.environ['LINK_wrapper'] = 'distlink'
19a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgos.environ['CC.host_wrapper'] = 'ccache'
20a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
21a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgtest = TestGyp.TestGyp(formats=test_format)
22a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
23ad617c17daad58cf225fc030081a2d663552b096thakis@chromium.orgold_env = dict(os.environ)
24ad617c17daad58cf225fc030081a2d663552b096thakis@chromium.orgos.environ['GYP_CROSSCOMPILE'] = '1'
25a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgtest.run_gyp('wrapper.gyp')
26ad617c17daad58cf225fc030081a2d663552b096thakis@chromium.orgos.environ.clear()
27ad617c17daad58cf225fc030081a2d663552b096thakis@chromium.orgos.environ.update(old_env)
28a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
29a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgif test.format == 'ninja':
30a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org  cc_expected = ('cc = ' + os.path.join('..', '..', 'distcc') + ' ' +
31a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org                 os.path.join('..', '..', 'clang'))
32a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org  cc_host_expected = ('cc_host = ' + os.path.join('..', '..', 'ccache') + ' ' +
33a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org                      os.path.join('..', '..', 'clang'))
3444c1a6c35b0c9762c1066afff961068be4808423thakis@chromium.org  ld_expected = 'ld = ../../distlink $cc'
3544c1a6c35b0c9762c1066afff961068be4808423thakis@chromium.org  if sys.platform != 'win32':
3644c1a6c35b0c9762c1066afff961068be4808423thakis@chromium.org    ldxx_expected = 'ldxx = ../../distlink $cxx'
3744c1a6c35b0c9762c1066afff961068be4808423thakis@chromium.org
38a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org  if sys.platform == 'win32':
39a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org     ld_expected = 'link.exe'
40a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org  test.must_contain('out/Default/build.ninja', cc_expected)
41a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org  test.must_contain('out/Default/build.ninja', cc_host_expected)
42a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org  test.must_contain('out/Default/build.ninja', ld_expected)
4344c1a6c35b0c9762c1066afff961068be4808423thakis@chromium.org  if sys.platform != 'win32':
4444c1a6c35b0c9762c1066afff961068be4808423thakis@chromium.org    test.must_contain('out/Default/build.ninja', ldxx_expected)
45a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.org
46a550dd22b6c28bb1a16fe9d406030a0f755ad79dscottmg@chromium.orgtest.pass_test()
47