blob: 1dbe87f6ed21b191537e71967f60b938794dd8ca [file] [log] [blame]
# This script is sourced from the top-level Android emulator
# configuration script, and relies on the following macro
# definitions:
#
# QEMU2_TOP_DIR: top-level QEMU2 source directory.
# OUT_DIR: top-level build output directory.
QEMU2_AUTOGENERATED_DIR=$OUT_DIR/build/qemu2-qapi-auto-generated
replace_with_if_different () {
cmp -s "$1" "$2" || mv "$2" "$1"
}
probe_prebuilts_dir "QEMU2 Dependencies" \
QEMU2_DEPS_PREBUILTS_DIR \
qemu-android-deps
echo "QEMU2_DEPS_PREBUILTS_DIR := $QEMU2_DEPS_PREBUILTS_DIR" >> $config_mk
python $QEMU2_TOP_DIR/scripts/qapi-types.py \
--builtins \
-o $QEMU2_AUTOGENERATED_DIR \
$QEMU2_TOP_DIR/qapi-schema.json
python $QEMU2_TOP_DIR/scripts/qapi-visit.py \
--builtins \
-o $QEMU2_AUTOGENERATED_DIR \
$QEMU2_TOP_DIR/qapi-schema.json
python $QEMU2_TOP_DIR/scripts/qapi-event.py \
-o $QEMU2_AUTOGENERATED_DIR \
$QEMU2_TOP_DIR/qapi-schema.json
python $QEMU2_TOP_DIR/scripts/qapi-introspect.py \
-o $QEMU2_AUTOGENERATED_DIR \
$QEMU2_TOP_DIR/qapi-schema.json
python $QEMU2_TOP_DIR/scripts/qapi-commands.py \
--middle \
-o $QEMU2_AUTOGENERATED_DIR \
$QEMU2_TOP_DIR/qapi-schema.json
TRACE_EVENT_FILES="\
trace-events \
util/trace-events \
crypto/trace-events \
io/trace-events \
migration/trace-events \
block/trace-events \
hw/block/trace-events \
hw/char/trace-events \
hw/intc/trace-events \
hw/net/trace-events \
hw/virtio/trace-events \
hw/audio/trace-events \
hw/misc/trace-events \
hw/usb/trace-events \
hw/scsi/trace-events \
hw/nvram/trace-events \
hw/display/trace-events \
hw/input/trace-events \
hw/timer/trace-events \
hw/dma/trace-events \
hw/sparc/trace-events \
hw/sd/trace-events \
hw/isa/trace-events \
hw/i386/trace-events \
hw/9pfs/trace-events \
hw/ppc/trace-events \
hw/pci/trace-events \
hw/s390x/trace-events \
hw/vfio/trace-events \
hw/acpi/trace-events \
hw/arm/trace-events \
hw/alpha/trace-events \
ui/trace-events \
audio/trace-events \
net/trace-events \
target-i386/trace-events \
target-sparc/trace-events \
target-s390x/trace-events \
target-ppc/trace-events \
qom/trace-events \
linux-user/trace-events \
"
TRACE_EVENTS_ALL=$QEMU2_AUTOGENERATED_DIR/trace-events-all
rm -f "$TRACE_EVENTS_ALL" && touch "$TRACE_EVENTS_ALL"
for TRACE_EVENT_FILE in $TRACE_EVENT_FILES; do
(cat "$QEMU2_TOP_DIR/$TRACE_EVENT_FILE" >> $TRACE_EVENTS_ALL)
done
mkdir -p "$QEMU2_AUTOGENERATED_DIR"/trace
python $QEMU2_TOP_DIR/scripts/tracetool.py \
--backends=nop \
--format=h \
--target-type system \
< $TRACE_EVENTS_ALL \
> $QEMU2_AUTOGENERATED_DIR/trace/generated-tracers.h
python $QEMU2_TOP_DIR/scripts/tracetool.py \
--backends=nop \
--format=c \
--target-type system \
< $TRACE_EVENTS_ALL \
> $QEMU2_AUTOGENERATED_DIR/trace/generated-tracers.c
python $QEMU2_TOP_DIR/scripts/tracetool.py \
--backends=nop \
--format=events-h \
--target-type system \
< $TRACE_EVENTS_ALL \
> $QEMU2_AUTOGENERATED_DIR/trace/generated-events.h
python $QEMU2_TOP_DIR/scripts/tracetool.py \
--backends=nop \
--format=events-c \
--target-type system \
< $TRACE_EVENTS_ALL \
> $QEMU2_AUTOGENERATED_DIR/trace/generated-events.c
python $QEMU2_TOP_DIR/scripts/tracetool.py \
--backends=nop \
--format=tcg-helper-h \
--target-type system \
< $TRACE_EVENTS_ALL \
> $QEMU2_AUTOGENERATED_DIR/trace/generated-helpers.h
python $QEMU2_TOP_DIR/scripts/tracetool.py \
--backends=nop \
--format=tcg-helper-wrapper-h \
--target-type system \
< $TRACE_EVENTS_ALL \
> $QEMU2_AUTOGENERATED_DIR/trace/generated-helpers-wrappers.h
python $QEMU2_TOP_DIR/scripts/tracetool.py \
--backends=nop \
--format=tcg-h \
--target-type system \
< $TRACE_EVENTS_ALL \
> $QEMU2_AUTOGENERATED_DIR/trace/generated-tcg-tracers.h
bash $QEMU2_TOP_DIR/scripts/hxtool -h \
< $QEMU2_TOP_DIR/qemu-options.hx \
> $QEMU2_AUTOGENERATED_DIR/qemu-options.def
replace_with_if_different \
"$QEMU2_TOP_DIR/qemu-options.def" \
$QEMU2_AUTOGENERATED_DIR/qemu-options.def
bash $QEMU2_TOP_DIR/scripts/hxtool -h \
< $QEMU2_TOP_DIR/hmp-commands.hx \
> $QEMU2_AUTOGENERATED_DIR/hmp-commands.h
bash $QEMU2_TOP_DIR/scripts/hxtool -h \
< $QEMU2_TOP_DIR/hmp-commands-info.hx \
> $QEMU2_AUTOGENERATED_DIR/hmp-commands-info.h
bash $QEMU2_TOP_DIR/scripts/hxtool -h \
< $QEMU2_TOP_DIR/qmp-commands.hx \
> $QEMU2_AUTOGENERATED_DIR/qmp-commands-old.h
bash $QEMU2_TOP_DIR/scripts/hxtool -h \
< $QEMU2_TOP_DIR/qemu-img-cmds.hx \
> $QEMU2_AUTOGENERATED_DIR/qemu-img-cmds.h
rm -f $QEMU2_AUTOGENERATED_DIR/gdbstub-xml-arm64.c
bash $QEMU2_TOP_DIR/scripts/feature_to_c.sh \
$QEMU2_AUTOGENERATED_DIR/gdbstub-xml-arm64.c \
$QEMU2_TOP_DIR/gdb-xml/aarch64-core.xml \
$QEMU2_TOP_DIR/gdb-xml/aarch64-fpu.xml \
$QEMU2_TOP_DIR/gdb-xml/arm-core.xml \
$QEMU2_TOP_DIR/gdb-xml/arm-vfp.xml \
$QEMU2_TOP_DIR/gdb-xml/arm-vfp3.xml \
$QEMU2_TOP_DIR/gdb-xml/arm-neon.xml
rm -f $QEMU2_AUTOGENERATED_DIR/gdbstub-xml-arm.c
bash $QEMU2_TOP_DIR/scripts/feature_to_c.sh \
$QEMU2_AUTOGENERATED_DIR/gdbstub-xml-arm.c \
$QEMU2_TOP_DIR/gdb-xml/arm-core.xml \
$QEMU2_TOP_DIR/gdb-xml/arm-vfp.xml \
$QEMU2_TOP_DIR/gdb-xml/arm-vfp3.xml \
$QEMU2_TOP_DIR/gdb-xml/arm-neon.xml
if [ "$OPT_MINGW" ]; then
$OUT_DIR/objs/build/toolchain/x86_64-mingw32-windres \
-o $QEMU2_AUTOGENERATED_DIR/version.o \
$QEMU2_TOP_DIR/version.rc
fi
# Generate qemu-version.h from Git history.
QEMU_VERSION_H=$QEMU2_AUTOGENERATED_DIR/qemu-version.h
QEMU_VERSION_H_TMP=$QEMU_VERSION_H.tmp
rm -f "$QEMU_VERSION_H"
if [ -d "$QEMU2_TOP_DIR/.git" ]; then
QEMU_VERSION=$(cd "$QEMU2_TOP_DIR" && git describe --match 'v*' 2>/dev/null | tr -d '\n')
else
QEMU_VERSION=$(date "+%Y-%m-%d")
fi
echo "QEMU2 : Version [$QEMU_VERSION]"
printf "#define QEMU_PKGVERSION \"(android-%s)\"\n" "$QEMU_VERSION" > $QEMU_VERSION_H_TMP
replace_with_if_different "$QEMU_VERSION_H" "$QEMU_VERSION_H_TMP"
rm -f "$QEMU_VERSION_TMP_H"
# Work-around for a QEMU2 bug:
# $QEMU2/linux-headers/linux/kvm.h includes <asm/kvm.h>
# but $QEMU2/linux-headers/asm/ doesn't exist. It is supposed
# to be a symlink to $QEMU2/linux-headers/asm-x86/
#
# The end result is that the <asm/kvm.h> from the host system
# or toolchain sysroot is being included, which ends up in a
# conflict. Work around it by creating a symlink here
rm -f $QEMU2_AUTOGENERATED_DIR/asm
ln -sf $QEMU2_TOP_DIR/linux-headers/asm-x86 $QEMU2_AUTOGENERATED_DIR/asm