target/arm: Provide and use H8 and H1_8 macros
[qemu/ar7.git] / scripts / nsis.py
blob5135a0583167ea8a386a97f160e5350611e48d7c
1 #!/usr/bin/env python3
3 # Copyright (C) 2020 Red Hat, Inc.
5 # SPDX-License-Identifier: GPL-2.0-or-later
7 import argparse
8 import glob
9 import os
10 import shutil
11 import subprocess
12 import tempfile
15 def signcode(path):
16 cmd = os.environ.get("SIGNCODE")
17 if not cmd:
18 return
19 subprocess.run([cmd, path])
22 def main():
23 parser = argparse.ArgumentParser(description="QEMU NSIS build helper.")
24 parser.add_argument("outfile")
25 parser.add_argument("prefix")
26 parser.add_argument("srcdir")
27 parser.add_argument("cpu")
28 parser.add_argument("nsisargs", nargs="*")
29 args = parser.parse_args()
31 destdir = tempfile.mkdtemp()
32 try:
33 subprocess.run(["make", "install", "DESTDIR=" + destdir + os.path.sep])
34 with open(
35 os.path.join(destdir + args.prefix, "system-emulations.nsh"), "w"
36 ) as nsh:
37 for exe in glob.glob(
38 os.path.join(destdir + args.prefix, "qemu-system-*.exe")
40 exe = os.path.basename(exe)
41 arch = exe[12:-4]
42 nsh.write(
43 """
44 Section "{0}" Section_{0}
45 SetOutPath "$INSTDIR"
46 File "${{BINDIR}}\\{1}"
47 SectionEnd
48 """.format(
49 arch, exe
53 for exe in glob.glob(os.path.join(destdir + args.prefix, "*.exe")):
54 signcode(exe)
56 makensis = [
57 "makensis",
58 "-V2",
59 "-NOCD",
60 "-DSRCDIR=" + args.srcdir,
61 "-DBINDIR=" + destdir + args.prefix,
63 dlldir = "w32"
64 if args.cpu == "x86_64":
65 dlldir = "w64"
66 makensis += ["-DW64"]
67 if os.path.exists(os.path.join(args.srcdir, "dll")):
68 makensis += ["-DDLLDIR={0}/dll/{1}".format(args.srcdir, dlldir)]
70 makensis += ["-DOUTFILE=" + args.outfile] + args.nsisargs
71 subprocess.run(makensis)
72 signcode(args.outfile)
73 finally:
74 shutil.rmtree(destdir)
77 if __name__ == "__main__":
78 main()