aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-07-11 22:20:51 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-07-11 22:20:51 +0100
commitd1987c8114921eb30859854de664f879b5626da7 (patch)
treefc52e32918b955c996e73018e31f26caf119cc92 /scripts
parent86108e23d798bcd3fce35ad271b198f8a8611746 (diff)
parent411ad8dd80077e98ed465775b044caf1a9482f6c (diff)
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging
* More SVM fixes (Lara) * Module annotation database (Gerd) * Memory leak fixes (myself) * Build fixes (myself) * --with-devices-* support (Alex) # gpg: Signature made Fri 09 Jul 2021 17:23:52 BST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini-gitlab/tags/for-upstream: (48 commits) meson: Use input/output for entitlements target configure: allow the selection of alternate config in the build configs: rename default-configs to configs and reorganise hw/arm: move CONFIG_V7M out of default-devices hw/arm: add dependency on OR_IRQ for XLNX_VERSAL meson: Introduce target-specific Kconfig meson: switch function tests from compilation to linking vl: fix leak of qdict_crumple return value target/i386: fix exceptions for MOV to DR target/i386: Added DR6 and DR7 consistency checks target/i386: Added MSRPM and IOPM size check monitor/tcg: move tcg hmp commands to accel/tcg, register them dynamically usb: build usb-host as module monitor/usb: register 'info usbhost' dynamically usb: drop usb_host_dev_is_scsi_storage hook monitor: allow register hmp commands accel: build tcg modular accel: add tcg module annotations accel: build qtest modular accel: add qtest module annotations ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/entitlement.sh10
-rwxr-xr-xscripts/modinfo-collect.py67
-rwxr-xr-xscripts/modinfo-generate.py97
3 files changed, 169 insertions, 5 deletions
diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh
index d2a7079ce3..e2c956a3ac 100755
--- a/scripts/entitlement.sh
+++ b/scripts/entitlement.sh
@@ -8,10 +8,10 @@ if [ "$1" = --install ]; then
in_place=false
fi
-SRC="$1"
-DST="$2"
-ENTITLEMENT="$3"
-ICON="$4"
+DST="$1"
+SRC="$2"
+ICON="$3"
+ENTITLEMENT="$4"
if $in_place; then
trap 'rm "$DST.tmp"' exit
@@ -21,7 +21,7 @@ else
cd "$MESON_INSTALL_DESTDIR_PREFIX"
fi
-if test "$ENTITLEMENT" != '/dev/null'; then
+if test -n "$ENTITLEMENT"; then
codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC"
fi
diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py
new file mode 100755
index 0000000000..4acb188c3e
--- /dev/null
+++ b/scripts/modinfo-collect.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import json
+import shlex
+import subprocess
+
+def find_command(src, target, compile_commands):
+ for command in compile_commands:
+ if command['file'] != src:
+ continue
+ if target != '' and command['command'].find(target) == -1:
+ continue
+ return command['command']
+ return 'false'
+
+def process_command(src, command):
+ skip = False
+ arg = False
+ out = []
+ for item in shlex.split(command):
+ if arg:
+ out.append(x)
+ arg = False
+ continue
+ if skip:
+ skip = False
+ continue
+ if item == '-MF' or item == '-MQ' or item == '-o':
+ skip = True
+ continue
+ if item == '-c':
+ skip = True
+ continue
+ out.append(item)
+ out.append('-DQEMU_MODINFO')
+ out.append('-E')
+ out.append(src)
+ return out
+
+def main(args):
+ target = ''
+ if args[0] == '--target':
+ args.pop(0)
+ target = args.pop(0)
+ print("MODINFO_DEBUG target %s" % target)
+ arch = target[:-8] # cut '-softmmu'
+ print("MODINFO_START arch \"%s\" MODINFO_END" % arch)
+ with open('compile_commands.json') as f:
+ compile_commands = json.load(f)
+ for src in args:
+ print("MODINFO_DEBUG src %s" % src)
+ command = find_command(src, target, compile_commands)
+ cmdline = process_command(src, command)
+ print("MODINFO_DEBUG cmd", cmdline)
+ 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('MODINFO') != -1:
+ print(line)
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py
new file mode 100755
index 0000000000..f559eed007
--- /dev/null
+++ b/scripts/modinfo-generate.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+
+def print_array(name, values):
+ if len(values) == 0:
+ return
+ list = ", ".join(values)
+ print(" .%s = ((const char*[]){ %s, NULL })," % (name, list))
+
+def parse_line(line):
+ kind = ""
+ data = ""
+ get_kind = False
+ get_data = False
+ for item in line.split():
+ if item == "MODINFO_START":
+ get_kind = True
+ continue
+ if item.startswith("MODINFO_END"):
+ get_data = False
+ continue
+ if get_kind:
+ kind = item
+ get_kind = False
+ get_data = True
+ continue
+ if get_data:
+ data += " " + item
+ continue
+ return (kind, data)
+
+def generate(name, lines):
+ arch = ""
+ objs = []
+ deps = []
+ opts = []
+ for line in lines:
+ if line.find("MODINFO_START") != -1:
+ (kind, data) = parse_line(line)
+ if kind == 'obj':
+ objs.append(data)
+ elif kind == 'dep':
+ deps.append(data)
+ elif kind == 'opts':
+ opts.append(data)
+ elif kind == 'arch':
+ arch = data;
+ else:
+ print("unknown:", kind)
+ exit(1)
+
+ print(" .name = \"%s\"," % name)
+ if arch != "":
+ print(" .arch = %s," % arch)
+ print_array("objs", objs)
+ print_array("deps", deps)
+ print_array("opts", opts)
+ print("},{");
+ return deps
+
+def print_pre():
+ print("/* generated by scripts/modinfo-generate.py */")
+ print("#include \"qemu/osdep.h\"")
+ print("#include \"qemu/module.h\"")
+ print("const QemuModinfo qemu_modinfo[] = {{")
+
+def print_post():
+ print(" /* end of list */")
+ print("}};")
+
+def main(args):
+ deps = {}
+ print_pre()
+ for modinfo in args:
+ with open(modinfo) as f:
+ lines = f.readlines()
+ print(" /* %s */" % modinfo)
+ (basename, ext) = os.path.splitext(modinfo)
+ deps[basename] = generate(basename, lines)
+ print_post()
+
+ flattened_deps = {flat.strip('" ') for dep in deps.values() for flat in dep}
+ error = False
+ for dep in flattened_deps:
+ if dep not in deps.keys():
+ print("Dependency {} cannot be satisfied".format(dep),
+ file=sys.stderr)
+ error = True
+
+ if error:
+ exit(1)
+
+if __name__ == "__main__":
+ main(sys.argv[1:])