summaryrefslogtreecommitdiffstats
path: root/SOURCES/dll2a
diff options
context:
space:
mode:
authorJoerg Koenig <jck@techsat.com>2017-06-07 10:38:31 (GMT)
committerJoerg Koenig <jck@techsat.com>2017-06-07 10:38:31 (GMT)
commitfd7662807a338cbaea2cbcd1879779093ca0a246 (patch)
treeca04a84115df348fae46e8e5c7a1761f114cb47f /SOURCES/dll2a
parent5627770d5021bd1d8fb31161811b4444b6b90781 (diff)
downloadgcc-compiler-suite-fd7662807a338cbaea2cbcd1879779093ca0a246.zip
gcc-compiler-suite-fd7662807a338cbaea2cbcd1879779093ca0a246.tar.gz
gcc-compiler-suite-fd7662807a338cbaea2cbcd1879779093ca0a246.tar.bz2
Updated dll2a script; added option to spiefiy output directory for generated lib (.a)refs/changes/65/1765/1
Change-Id: Icf6a2986f7b61f7a01e6ff6ff925a851b2a450f7
Diffstat (limited to 'SOURCES/dll2a')
-rwxr-xr-xSOURCES/dll2a41
1 files changed, 33 insertions, 8 deletions
diff --git a/SOURCES/dll2a b/SOURCES/dll2a
index 03079c3..851ed10 100755
--- a/SOURCES/dll2a
+++ b/SOURCES/dll2a
@@ -3,11 +3,29 @@ import sys
import os, os.path
import commands
import tempfile
+from optparse import OptionParser
+
+usage = "usage: %prog [options] arg"
+op = OptionParser(usage)
+op.add_option('-l', '--libdir', dest="libdir")
+opts, args = op.parse_args()
+
+if len(args) != 1:
+ sys.exit("dll2a: Invalid argument(s)")
+
+if not os.path.isfile(args[0]):
+ sys.exit("dll2a: File %r doen't exists" % args[0])
+
+if not opts.libdir == None and not os.path.isdir(opts.libdir):
+ sys.exit("dll2a: Output directoy %r doesn't exists" % opts.libdir)
+
+if opts.libdir == None:
+ opts.libdir = os.path.dirname(args[0])
appdir = os.path.abspath(os.path.dirname(__file__))
basename = os.path.basename(__file__)
-dllfile = sys.argv[1]
+dllfile = args[0]
_t = basename.split("-dll2a")
if not _t[0].strip() == "":
@@ -19,19 +37,26 @@ gendef_bin = os.path.join(appdir, "%sgendef"%prefix)
dlltool_bin = os.path.join(appdir, "%sdlltool"%prefix)
ranlib_bin = os.path.join(appdir, "%sranlib"%prefix)
-ret, out = commands.getstatusoutput('''%s %s''' % (gendef_bin, dllfile))
+dlldir = os.path.dirname(dllfile)
+basedllname = os.path.basename(dllfile)[:-4]
+
+deffile = basedllname+".def"
+deffile = os.path.join(opts.libdir, deffile)
+
+libfile = "lib"+basedllname+".a"
+libfile = os.path.join(opts.libdir, libfile)
+
+cmd = '''%s - %s > %s''' % (gendef_bin, dllfile, deffile)
+ret, out = commands.getstatusoutput(cmd)
-deffile = dllfile.lower().replace(".DLL", ".dll")
-deffile = deffile.lower().replace(".dll", ".def")
-libfile = deffile.lower().replace(".def", ".a")
-libfile = "lib%s"%libfile
if os.path.isfile(deffile):
ret, out = commands.getstatusoutput('''%s -d %s -l %s''' % (dlltool_bin, deffile, libfile))
if os.path.isfile(libfile):
ret, out = commands.getstatusoutput('''%s %s''' % (ranlib_bin, libfile))
-print "dll2a: %s -> %s "%(dllfile,libfile)
-print "dll2a: DLL import library %s generated" % libfile
+os.remove(deffile)
+
+print "dll2a: %s: DLL import library %s generated" % (dllfile, libfile)
sys.exit(0)