summaryrefslogtreecommitdiffstats
path: root/third_party/python/gyp/test/win/gyptest-link-deffile.py
blob: 94df874f857e1f4dee88492f956704b770131e7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python

# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Make sure a .def file is handled in the link.
"""

import TestGyp

import sys

if sys.platform == 'win32':
  test = TestGyp.TestGyp(formats=['msvs', 'ninja'])

  CHDIR = 'linker-flags'

  # Multiple .def files doesn't make any sense, should fail at generate time.
  test.run_gyp('deffile-multiple.gyp', chdir=CHDIR, stderr=None, status=1)

  test.run_gyp('deffile.gyp', chdir=CHDIR)
  test.build('deffile.gyp', test.ALL, chdir=CHDIR)

  def HasExport(binary, export):
    full_path = test.built_file_path(binary, chdir=CHDIR)
    output = test.run_dumpbin('/exports', full_path)
    return export in output

  # Make sure we only have the export when the .def file is in use.

  if HasExport('test_deffile_dll_notexported.dll', 'AnExportedFunction'):
    test.fail_test()
  if not HasExport('test_deffile_dll_ok.dll', 'AnExportedFunction'):
    test.fail_test()

  if HasExport('test_deffile_exe_notexported.exe', 'AnExportedFunction'):
    test.fail_test()
  if not HasExport('test_deffile_exe_ok.exe', 'AnExportedFunction'):
    test.fail_test()

  test.pass_test()