From 29747f48916b74fe9e48e30d05b4a3787c6c94c5 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Fri, 8 Feb 2019 21:21:11 -0800 Subject: [PATCH] Allow modules to specify defines The modules.yaml now has an optional defines: list per module that adds preprocessor definitions to the build scripts. Also added a --debug flag to qemu.sh to run QEMU's debugger host. --- generate_build.py | 1 + qemu.sh | 8 +++++++- scripts/templates/module.base.j2 | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/generate_build.py b/generate_build.py index 4569156..a935db4 100755 --- a/generate_build.py +++ b/generate_build.py @@ -33,6 +33,7 @@ class Module: self.target = kwargs.get("target", None) self.deps = kwargs.get("deps", tuple()) self.includes = kwargs.get("includes", tuple()) + self.defines = kwargs.get("defines", tuple()) self.depmods = [] sources = [join(root, f) for f in kwargs.get("source", tuple())] diff --git a/qemu.sh b/qemu.sh index ed4a41e..32a92a6 100755 --- a/qemu.sh +++ b/qemu.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +debug="" +if [[ $1 = "--debug" ]]; then + debug="-s" + shift +fi + build=${1:-"$(dirname $0)/build"} kvm="" @@ -19,4 +25,4 @@ exec qemu-system-x86_64 \ -M q35 \ -no-reboot \ -nographic \ - $kvm + $kvm $debug diff --git a/scripts/templates/module.base.j2 b/scripts/templates/module.base.j2 index 5d8574b..c01ef1e 100644 --- a/scripts/templates/module.base.j2 +++ b/scripts/templates/module.base.j2 @@ -10,6 +10,9 @@ ccflags = $ccflags $ {%- for inc in module.includes %} -I${srcroot}/{{ inc }} $ {%- endfor %} + {%- for define in module.defines %} + -D{{ define }} $ + {%- endfor %} {% endblock %} {% for source in module.sources %}