From fd7662807a338cbaea2cbcd1879779093ca0a246 Mon Sep 17 00:00:00 2001 From: Joerg Koenig Date: Wed, 7 Jun 2017 12:38:31 +0200 Subject: Updated dll2a script; added option to spiefiy output directory for generated lib (.a) Change-Id: Icf6a2986f7b61f7a01e6ff6ff925a851b2a450f7 --- SOURCES/dll2a | 41 +++++++++++++++++++++++++++++++++-------- 1 file 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) -- cgit v0.12