From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
"Willian Rampazzo" <willianr@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Cleber Rosa" <crosa@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [PATCH v2 1/3] nsis.py: create dlldir automatically
Date: Mon, 26 Jul 2021 17:52:33 +0200 [thread overview]
Message-ID: <20210726155235.2249878-2-kraxel@redhat.com> (raw)
In-Reply-To: <20210726155235.2249878-1-kraxel@redhat.com>
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
next prev parent reply other threads:[~2021-07-26 15:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 15:52 [PATCH v2 0/3] build windows installers in ci Gerd Hoffmann
2021-07-26 15:52 ` Gerd Hoffmann [this message]
2021-07-26 15:52 ` [PATCH v2 2/3] ci: build & store guest agent msi Gerd Hoffmann
2021-07-26 15:52 ` [PATCH v2 3/3] qemu-ga/msi: fix w32 libgcc name Gerd Hoffmann
2021-07-26 16:34 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210726155235.2249878-2-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=michael.roth@amd.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
--cc=wainersm@redhat.com \
--cc=willianr@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).