@@ -237,46 +237,6 @@ def get_flags():
237237 }
238238
239239
240- def build_def_file (target , source , env : "SConsEnvironment" ):
241- arch_aliases = {
242- "x86_32" : "i386" ,
243- "x86_64" : "i386:x86-64" ,
244- "arm32" : "arm" ,
245- "arm64" : "arm64" ,
246- }
247-
248- cmdbase = "dlltool -m " + arch_aliases [env ["arch" ]]
249- if env ["arch" ] == "x86_32" :
250- cmdbase += " -k"
251- else :
252- cmdbase += " --no-leading-underscore"
253-
254- mingw_bin_prefix = get_mingw_bin_prefix (env ["mingw_prefix" ], env ["arch" ])
255-
256- for x in range (len (source )):
257- ok = True
258- # Try prefixed executable (MinGW on Linux).
259- cmd = mingw_bin_prefix + cmdbase + " -d " + str (source [x ]) + " -l " + str (target [x ])
260- try :
261- out = subprocess .Popen (cmd , shell = True , stderr = subprocess .PIPE ).communicate ()
262- if len (out [1 ]):
263- ok = False
264- except Exception :
265- ok = False
266-
267- # Try generic executable (MSYS2).
268- if not ok :
269- cmd = cmdbase + " -d " + str (source [x ]) + " -l " + str (target [x ])
270- try :
271- out = subprocess .Popen (cmd , shell = True , stderr = subprocess .PIPE ).communicate ()
272- if len (out [1 ]):
273- return - 1
274- except Exception :
275- return - 1
276-
277- return 0
278-
279-
280240def configure_msvc (env : "SConsEnvironment" ):
281241 """Configure env to work with MSVC"""
282242
@@ -919,7 +879,35 @@ def configure_mingw(env: "SConsEnvironment"):
919879 env .Append (CPPDEFINES = ["MINGW_ENABLED" , ("MINGW_HAS_SECURE_API" , 1 )])
920880
921881 # dlltool
922- env .Append (BUILDERS = {"DEF" : env .Builder (action = build_def_file , suffix = ".a" , src_suffix = ".def" )})
882+ env ["DEF" ] = get_detected (env , "dlltool" )
883+ env ["DEFCOM" ] = "$DEF $DEFFLAGS -d $SOURCE -l $TARGET"
884+ env ["DEFCOMSTR" ] = "$CXXCOMSTR"
885+ env ["DEFPREFIX" ] = "$LIBPREFIX"
886+ env ["DEFSUFFIX" ] = ".${__env__['arch']}$LIBSUFFIX"
887+ env ["DEFSRCSUFFIX" ] = ".${__env__['arch']}.def"
888+ DEF_ALIASES = {
889+ "x86_32" : "i386" ,
890+ "x86_64" : "i386:x86-64" ,
891+ "arm32" : "arm" ,
892+ "arm64" : "arm64" ,
893+ }
894+ env .Append (DEFFLAGS = ["-m" , DEF_ALIASES [env ["arch" ]]])
895+ if env ["arch" ] == "x86_32" :
896+ env .Append (DEFFLAGS = ["-k" ])
897+ else :
898+ env .Append (DEFFLAGS = ["--no-leading-underscore" ])
899+
900+ env .Append (
901+ BUILDERS = {
902+ "DEFLIB" : env .Builder (
903+ action = env .Run ("$DEFCOM" , "$DEFCOMSTR" ),
904+ prefix = "$DEFPREFIX" ,
905+ suffix = "$DEFSUFFIX" ,
906+ src_suffix = "$DEFSRCSUFFIX" ,
907+ emitter = methods .redirect_emitter ,
908+ )
909+ }
910+ )
923911
924912
925913def configure (env : "SConsEnvironment" ):
0 commit comments