summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine/SCons/Tool/mingw.py16
-rw-r--r--test/mingw.py14
2 files changed, 29 insertions, 1 deletions
diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py
index 7221cd6..d0f1eaf 100644
--- a/src/engine/SCons/Tool/mingw.py
+++ b/src/engine/SCons/Tool/mingw.py
@@ -57,6 +57,9 @@ def shlib_generator(target, source, env, for_signature):
implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
if implib: cmd.append('-Wl,--out-implib,'+str(implib))
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ if def_target: cmd.append('-Wl,--output-def,'+str(def_target))
+
return [cmd]
def shlib_emitter(target, source, env):
@@ -73,6 +76,17 @@ def shlib_emitter(target, source, env):
target.append(env.ReplaceIxes(dll,
'SHLIBPREFIX', 'SHLIBSUFFIX',
'LIBPREFIX', 'LIBSUFFIX'))
+
+ # Append a def file target if there isn't already a def file target
+ # or a def file source. There is no option to disable def file
+ # target emitting, because I can't figure out why someone would ever
+ # want to turn it off.
+ def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ if not def_source and not def_target:
+ target.append(env.ReplaceIxes(dll,
+ 'SHLIBPREFIX', 'SHLIBSUFFIX',
+ 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX'))
return (target, source)
@@ -112,6 +126,8 @@ def generate(env, platform):
env['SHLIBEMITTER']= shlib_emitter
env['LINK'] = 'g++'
env['AS'] = 'as'
+ env['WIN32DEFPREFIX'] = ''
+ env['WIN32DEFSUFFIX'] = '.def'
env['RC'] = 'windres'
env['RCFLAGS'] = ''
diff --git a/test/mingw.py b/test/mingw.py
index 5d6e2c1..1ea4704 100644
--- a/test/mingw.py
+++ b/test/mingw.py
@@ -64,7 +64,7 @@ env=Environment(tools=['mingw'])
assert env['CC'] == 'gcc'
env.StaticLibrary('static', 'static.cpp')
env.SharedLibrary('shared', 'shared.cpp')
-env.SharedLibrary('cshared', 'cshared.c')
+env.SharedLibrary('cshared', ['cshared.c', 'cshared.def'])
env.Program('test', ['test.cpp', env.RES('resource.rc', CPPPATH=['header'])], LIBS=['static', 'shared', 'cshared'], LIBPATH=['.'])
""")
@@ -133,6 +133,13 @@ void cshared_func(void)
}
''')
+test.write('cshared.def', '''
+EXPORTS
+cshared_func
+''')
+
+
+
test.write('header/resource2.h', '''
#define RESOURCE_RC "resource.rc"
''')
@@ -141,6 +148,11 @@ test.write('header/resource2.h', '''
# we'd like for this test to pass once this bug is fixed, so match anything at all
# that comes out of stderr:
test.run(arguments='test.exe', stderr='.*')
+# ensure the source def for cshared.def got used, and there wasn't a target def for chshared.dll:
+test.fail_test(string.find(test.stdout(), 'cshared.def') == -1)
+test.fail_test(string.find(test.stdout(), '-Wl,--output-def,cshared.def') != -1)
+# ensure the target def got generated for the shared.dll:
+test.fail_test(not os.path.exists(test.workpath('shared.def')))
test.run(program=test.workpath('test.exe'), stdout='test.cpp\nshared.cpp\nstatic.cpp\ncshared.c\n2001 resource.rc\n')
# ensure that modifying the header causes the resource to be rebuilt: