|
OLD | NEW |
---|---|
(Empty) | |
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 Checks that C-only targets aren't linked against libstdc++. | |
9 """ | |
10 | |
11 import TestGyp | |
12 | |
13 import re | |
14 import subprocess | |
15 import sys | |
16 | |
17 # set |match| to ignore build stderr output. | |
18 test = TestGyp.TestGyp(match = lambda a, b: True) | |
19 if sys.platform != 'win32' and test.format not in ('make', 'android'): | |
20 # TODO: This doesn't pass with make. | |
21 # TODO: Does a test like this make sense with Windows? Android? | |
Nico
2013/09/10 21:11:45
Does msvs automatically link a c++ runtime if ther
scottmg
2013/09/10 21:31:33
I'm actually not sure how it decides to depend on
| |
22 | |
23 CHDIR = 'src' | |
24 test.run_gyp('test.gyp', chdir=CHDIR) | |
25 test.build('test.gyp', 'no_cpp', chdir=CHDIR) | |
26 | |
27 def LinksLibStdCpp(p): | |
scottmg
2013/09/10 21:09:15
nit; p -> path
Nico
2013/09/10 21:11:45
Done.
| |
28 p = test.built_file_path(p, chdir=CHDIR) | |
29 if sys.platform == 'darwin': | |
30 proc = subprocess.Popen(['otool', '-L', p], stdout=subprocess.PIPE) | |
31 else: | |
32 proc = subprocess.Popen(['ldd', p], stdout=subprocess.PIPE) | |
33 o = proc.communicate()[0] | |
scottmg
2013/09/10 21:09:15
nit; o -> out or output
Nico
2013/09/10 21:11:45
Done.
| |
34 assert not proc.returncode | |
35 return 'libstdc++' in o or 'libc++' in o | |
36 | |
37 if LinksLibStdCpp('no_cpp'): | |
38 test.fail_test() | |
39 | |
40 build_error_code = { | |
41 'xcode': [1, 65], # 1 for xcode 3, 65 for xcode 4 (see `man sysexits`) | |
42 'make': 2, | |
43 'ninja': 1, | |
44 }[test.format] | |
45 | |
46 test.build('test.gyp', 'no_cpp_dep_on_cc_lib', chdir=CHDIR, | |
47 status=build_error_code) | |
48 | |
49 test.pass_test() | |
OLD | NEW |