Skip to content

Commit

Permalink
Add symbol export file support to MSVC.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Jan 8, 2019
1 parent 7c8ed14 commit 7cd4745
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
3 changes: 3 additions & 0 deletions mesonbuild/compilers/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,9 @@ def gen_vs_module_defs_args(self, defsfile):
# so if a module defs file is specified, we use that to export symbols
return ['/DEF:' + defsfile]

def get_symbol_export_file_args(self, path):
return ['/DEF:' + path]

def gen_pch_args(self, header, source, pchname):
objname = os.path.splitext(pchname)[0] + '.obj'
return objname, ['/Yc' + header, '/Fp' + pchname, '/Fo' + objname]
Expand Down
2 changes: 2 additions & 0 deletions test cases/common/211 version file/bob.sym
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EXPORTS
bobMcBob
2 changes: 2 additions & 0 deletions test cases/common/211 version file/bob.sym.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EXPORTS
@in@
31 changes: 21 additions & 10 deletions test cases/common/211 version file/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
project('linker script', 'c')

cc = meson.get_compiler('c')

# Static map file
mapfile = 'bob.map'
if cc.get_id() == 'msvc'
suffix = '.sym'
else
suffix = '.map'
endif

mapfile = 'bob' + suffix

l = shared_library('bob', 'bob.c', symbol_export_file: mapfile)
e = executable('prog', 'prog.c', link_with : l)
Expand All @@ -11,30 +19,33 @@ test('core', e)
conf = configuration_data()
conf.set('in', 'bobMcBob')
m = configure_file(
input : 'bob.map.in',
output : 'bob-conf.map',
input : 'bob' + suffix + '.in',
output : 'bob-conf' + suffix,
configuration : conf,
)

l = shared_library('bob-conf', 'bob.c', symbol_export_file: m)
e = executable('prog-conf', 'prog.c', link_with : l)
test('core', e)

# custom_target
python = find_program('python3')
## custom_target
python = find_program('python3', required : false)
if not python.found()
python = find_program('python')
endif
m = custom_target(
'bob-ct.map',
'bob-ct' + suffix,
command : [python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'],
input : ['copy.py', 'bob.map'],
output : 'bob-ct.map',
input : ['copy.py', 'bob' + suffix],
output : 'bob-ct' + suffix,
)

l = shared_library('bob-ct', ['bob.c', m], symbol_export_file: m)
e = executable('prog-ct', 'prog.c', link_with : l)
test('core', e)

# File
mapfile = files('bob.map')
mapfile = files('bob' + suffix)

l = shared_library('bob-files', 'bob.c', symbol_export_file: mapfile)
e = executable('prog-files', 'prog.c', link_with : l)
Expand All @@ -43,7 +54,7 @@ test('core', e)
subdir('sub')

# With map file in subdir
mapfile = files('sub/foo.map')
mapfile = files('sub/foo' + suffix)

l = shared_library('bar', 'bob.c', symbol_export_file: mapfile)
e = executable('prog-bar', 'prog.c', link_with : l)
Expand Down
2 changes: 2 additions & 0 deletions test cases/common/211 version file/sub/foo.sym
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
EXPORTS
bobMcBob
5 changes: 2 additions & 3 deletions test cases/common/211 version file/sub/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mapfile = 'foo.map'
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
mapfile = 'foo' + suffix

l = shared_library('foo', '../bob.c', link_args : vflag, link_depends : mapfile)
l = shared_library('foo', '../bob.c', symbol_export_file: mapfile)
e = executable('prog-foo', '../prog.c', link_with : l)
test('core', e)

0 comments on commit 7cd4745

Please sign in to comment.