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):
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)
env['SHLIBEMITTER']= shlib_emitter
env['LINK'] = 'g++'
env['AS'] = 'as'
+ env['WIN32DEFPREFIX'] = ''
+ env['WIN32DEFSUFFIX'] = '.def'
env['RC'] = 'windres'
env['RCFLAGS'] = ''
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=['.'])
""")
}
''')
+test.write('cshared.def', '''
+EXPORTS
+cshared_func
+''')
+
+
+
test.write('header/resource2.h', '''
#define RESOURCE_RC "resource.rc"
''')
# 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: