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 Make sure function-level linking setting is extracted properly. |
| 9 """ |
| 10 |
| 11 import TestGyp |
| 12 |
| 13 import subprocess |
| 14 import sys |
| 15 |
| 16 if sys.platform == 'win32': |
| 17 test = TestGyp.TestGyp(formats=['ninja', 'msvs']) |
| 18 |
| 19 CHDIR = 'compiler_flags' |
| 20 test.run_gyp('function-level-linking.gyp', chdir=CHDIR) |
| 21 test.build('function-level-linking.gyp', test.ALL, chdir=CHDIR) |
| 22 |
| 23 def CheckForSectionString(binary, string): |
| 24 proc = subprocess.Popen(['dumpbin', '/headers', binary], |
| 25 stdout=subprocess.PIPE) |
| 26 output = proc.communicate()[0] |
| 27 assert not proc.returncode |
| 28 if string not in output: |
| 29 print 'Did not find "%s" in %s' % (string, binary) |
| 30 test.fail_test() |
| 31 |
| 32 def ObjName(proj, obj): |
| 33 if test.format == 'ninja': |
| 34 sep = '.' |
| 35 else: |
| 36 sep = '\\' |
| 37 return 'obj\\%s%s%s' % (proj, sep, obj) |
| 38 |
| 39 look_for = '''COMDAT; sym= "int __cdecl stripped_function''' |
| 40 CheckForSectionString( |
| 41 test.built_file_path(ObjName('test_fll_on', 'function_level_linking.obj'), |
| 42 chdir=CHDIR), |
| 43 look_for) |
| 44 |
| 45 if test.format == 'ninja': |
| 46 ninja_file = test.built_file_path('obj/test_fll_off.ninja', chdir=CHDIR) |
| 47 test.must_contain(ninja_file, 'cflags = /Gy-') |
| 48 |
| 49 ninja_file = test.built_file_path('obj/test_fll_on.ninja', chdir=CHDIR) |
| 50 test.must_contain(ninja_file, 'cflags = /Gy') |
| 51 test.must_not_contain(ninja_file, '/Gy-') |
| 52 |
| 53 test.pass_test() |
OLD | NEW |