[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/3] nsis.py: create dlldir automatically
From: |
Gerd Hoffmann |
Subject: |
[PATCH v2 1/3] nsis.py: create dlldir automatically |
Date: |
Mon, 26 Jul 2021 17:52:33 +0200 |
Use objdump do figure which dlls are needed. Copy them to a temporary
dlldir and pass that directory to makensis.
This patch removes the need to manually copy dlls to $srcdir/dll/w{32,64}
to get functional windows installers via "make installer".
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
scripts/nsis.py | 27 +++++++++++++++++++++++----
meson.build | 1 +
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/scripts/nsis.py b/scripts/nsis.py
index 5135a0583167..5a3cc7c09628 100644
--- a/scripts/nsis.py
+++ b/scripts/nsis.py
@@ -7,6 +7,7 @@
import argparse
import glob
import os
+import sys
import shutil
import subprocess
import tempfile
@@ -19,16 +20,35 @@ def signcode(path):
subprocess.run([cmd, path])
+def copydlls(binary, srcdir, dstdir):
+ cmdline = [ "objdump", "-p", binary ]
+ result = subprocess.run(cmdline, stdout = subprocess.PIPE,
+ universal_newlines = True)
+ if result.returncode != 0:
+ sys.exit(result.returncode)
+ for line in result.stdout.split('\n'):
+ if line.find('DLL Name') != -1:
+ dll = line.split()[2]
+ src = os.path.join(srcdir, dll)
+ dst = os.path.join(dstdir, dll)
+ if os.path.isfile(src) and not os.path.isfile(dst):
+ print("nsis.py: copy " + src)
+ shutil.copyfile(src, dst)
+ copydlls(src, srcdir, dstdir)
+
+
def main():
parser = argparse.ArgumentParser(description="QEMU NSIS build helper.")
parser.add_argument("outfile")
parser.add_argument("prefix")
parser.add_argument("srcdir")
parser.add_argument("cpu")
+ parser.add_argument("dllsrc")
parser.add_argument("nsisargs", nargs="*")
args = parser.parse_args()
destdir = tempfile.mkdtemp()
+ dlldir = tempfile.mkdtemp()
try:
subprocess.run(["make", "install", "DESTDIR=" + destdir + os.path.sep])
with open(
@@ -52,6 +72,7 @@ def main():
for exe in glob.glob(os.path.join(destdir + args.prefix, "*.exe")):
signcode(exe)
+ copydlls(exe, args.dllsrc, dlldir)
makensis = [
"makensis",
@@ -59,19 +80,17 @@ def main():
"-NOCD",
"-DSRCDIR=" + args.srcdir,
"-DBINDIR=" + destdir + args.prefix,
+ "-DDLLDIR=" + dlldir,
]
- dlldir = "w32"
if args.cpu == "x86_64":
- dlldir = "w64"
makensis += ["-DW64"]
- if os.path.exists(os.path.join(args.srcdir, "dll")):
- makensis += ["-DDLLDIR={0}/dll/{1}".format(args.srcdir, dlldir)]
makensis += ["-DOUTFILE=" + args.outfile] + args.nsisargs
subprocess.run(makensis)
signcode(args.outfile)
finally:
shutil.rmtree(destdir)
+ shutil.rmtree(dlldir)
if __name__ == "__main__":
diff --git a/meson.build b/meson.build
index f2e148eaf98e..4a2d54fbae3f 100644
--- a/meson.build
+++ b/meson.build
@@ -2790,6 +2790,7 @@ if host_machine.system() == 'windows'
get_option('prefix'),
meson.current_source_dir(),
host_machine.cpu(),
+ config_host['QEMU_GA_MSI_MINGW_DLL_PATH'],
'--',
'-DDISPLAYVERSION=' + meson.project_version(),
]
--
2.31.1