aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2024-10-05 00:58:12 +0200
committerJavier <dev.git@javispedro.com>2024-10-05 00:59:23 +0200
commitac93b512709187b8b29dbdb1c454813b6bb255ab (patch)
tree1a5d2dc1750ed299a0058db3a0345381e6fbd692
parentc2bffa687813222bc3f8fcc3c9e4bf92672fe7fa (diff)
downloadvmusic-ac93b512709187b8b29dbdb1c454813b6bb255ab.tar.gz
vmusic-ac93b512709187b8b29dbdb1c454813b6bb255ab.zip
autogenerate version headers from VirtualBox.src contents
-rw-r--r--Makefile7
-rw-r--r--include/package-generated.h0
-rw-r--r--include/product-generated.h0
-rw-r--r--include/revision-generated.h0
-rwxr-xr-xinclude/version-generated.h16
-rwxr-xr-xscripts/generate_version_headers.sh64
6 files changed, 69 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 82a3a85..827a299 100644
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,7 @@ VBOX_DEFINES:=-DVBOX_HAVE_VISIBILITY_HIDDEN -DRT_USE_VISIBILITY_DEFAULT -DVBOX -
VBOX_CFLAGS:=-fPIC -m64 -pedantic -Wshadow -Wall -Wextra \
-Wno-missing-field-initializers -Wno-unused -Wno-trigraphs -fdiagnostics-show-option -Wno-unused-parameter -Wlogical-op -Wno-variadic-macros -Wno-long-long -Wunused-variable -Wunused-function -Wunused-label -Wunused-parameter -Wno-array-bounds -Wno-ignored-qualifiers -Wno-variadic-macros -fno-omit-frame-pointer -fno-strict-aliasing \
-fvisibility=hidden -fno-exceptions \
- -I$(VBOXSRC)/include -Iinclude
+ -I$(VBOXSRC)/include -I$(OBJDIR)
VBOX_CXXFLAGS:=$(VBOX_CFLAGS) -Wno-overloaded-virtual -fvisibility-inlines-hidden -fno-rtti
VBOX_LDFLAGS:=-fPIC -m64
VBOX_LIBS:=$(VBOXBIN)/VBoxRT.$(SO)
@@ -86,7 +86,10 @@ build: $(OUTOSDIR)/VMusicMain.$(SO) $(OUTOSDIR)/VMusicMainVM.$(SO) $(OUTOSDIR)/A
$(OUTDIR) $(OBJDIR) $(OBJOSDIR) $(OUTOSDIR): %:
mkdir -p $@
-$(OBJOSDIR)/%.o: %.cpp | $(OBJOSDIR)
+$(OUTDIR)/version-generated.h: VirtualBox.src | $(OBJDIR)
+ ./scripts/generate_version_headers.sh
+
+$(OBJOSDIR)/%.o: %.cpp $(OUTDIR)/version-generated.h | $(OBJOSDIR)
$(CXX) -c $(VBOX_CXXFLAGS) $(VBOX_DEFINES) $(VMUSIC_DEFINES) $(CXXFLAGS) -o $@ $<
$(OBJOSDIR)/%.o: %.c | $(OBJOSDIR)
diff --git a/include/package-generated.h b/include/package-generated.h
deleted file mode 100644
index e69de29..0000000
--- a/include/package-generated.h
+++ /dev/null
diff --git a/include/product-generated.h b/include/product-generated.h
deleted file mode 100644
index e69de29..0000000
--- a/include/product-generated.h
+++ /dev/null
diff --git a/include/revision-generated.h b/include/revision-generated.h
deleted file mode 100644
index e69de29..0000000
--- a/include/revision-generated.h
+++ /dev/null
diff --git a/include/version-generated.h b/include/version-generated.h
deleted file mode 100755
index 406a418..0000000
--- a/include/version-generated.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef ___version_generated_h___
-#define ___version_generated_h___
-
-// Fake information just to get the off-the-shelf headers working.
-
-#define VBOX_VERSION_MAJOR 7
-#define VBOX_VERSION_MINOR 0
-#define VBOX_VERSION_BUILD 0
-#define VBOX_VERSION_STRING_RAW "7.0.0"
-#define VBOX_VERSION_STRING "7.0.0"
-#define VBOX_API_VERSION_STRING "7_0"
-
-#define VBOX_PRIVATE_BUILD_DESC "Private fake build"
-
-#endif
-
diff --git a/scripts/generate_version_headers.sh b/scripts/generate_version_headers.sh
new file mode 100755
index 0000000..91dd6ff
--- /dev/null
+++ b/scripts/generate_version_headers.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# Generates the {version,revision,product}-generated.h header files from the VirtualBox version contained in VirtualBox.src
+# These headers are required when including any VirtualBox.src header.
+# This script itself comes mostly from export_modules.sh script in VirtualBox.
+
+PATH_ROOT=VirtualBox.src
+PATH_TMP=obj
+
+VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
+VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
+VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
+VBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
+VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
+VBOX_SVN_CONFIG_REV=`sed -e 's/^ *VBOX_SVN_REV_CONFIG_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Config.kmk`
+VBOX_SVN_VERSION_REV=`sed -e 's/^ *VBOX_SVN_REV_VERSION_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Version.kmk`
+
+if [ -n "$OVERRIDE_SVN_REV" ]; then
+ VBOX_SVN_REV=$OVERRIDE_SVN_REV
+elif [ "$VBOX_SVN_CONFIG_REV" -gt "$VBOX_SVN_VERSION_REV" ]; then
+ VBOX_SVN_REV=$VBOX_SVN_CONFIG_REV
+else
+ VBOX_SVN_REV=$VBOX_SVN_VERSION_REV
+fi
+VBOX_VENDOR=`sed -e 's/^ *VBOX_VENDOR *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
+VBOX_VENDOR_SHORT=`sed -e 's/^ *VBOX_VENDOR_SHORT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
+VBOX_PRODUCT=`sed -e 's/^ *VBOX_PRODUCT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
+VBOX_C_YEAR=`date +%Y`
+VBOX_WITH_PCI_PASSTHROUGH=`sed -e '/^ *VBOX_WITH_PCI_PASSTHROUGH *[:]\?= */!d' -e 's/ *#.*$//' -e 's/^.*= *//' $PATH_ROOT/Config.kmk`
+
+# Create auto-generated version file, needed by all modules
+echo "#ifndef ___version_generated_h___" > $PATH_TMP/version-generated.h
+echo "#define ___version_generated_h___" >> $PATH_TMP/version-generated.h
+echo "" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_STRING_RAW \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_API_VERSION_STRING \"${VBOX_VERSION_MAJOR}_${VBOX_VERSION_MINOR}\"" >> $PATH_TMP/version-generated.h
+[ -n "$EXTRA_VERSION_STRING" ] && echo "#define VBOX_EXTRA_VERSION_STRING \" ${EXTRA_VERSION_STRING}\"" >> $PATH_TMP/version-generated.h
+echo "#define VBOX_PRIVATE_BUILD_DESC \"Private build with export_modules\"" >> $PATH_TMP/version-generated.h
+echo "" >> $PATH_TMP/version-generated.h
+echo "#endif" >> $PATH_TMP/version-generated.h
+
+# Create auto-generated revision file, needed by all modules
+echo "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
+echo "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
+echo "" >> $PATH_TMP/revision-generated.h
+echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
+echo "" >> $PATH_TMP/revision-generated.h
+echo "#endif" >> $PATH_TMP/revision-generated.h
+
+# Create auto-generated product file, needed by all modules
+echo "#ifndef ___product_generated_h___" > $PATH_TMP/product-generated.h
+echo "#define ___product_generated_h___" >> $PATH_TMP/product-generated.h
+echo "" >> $PATH_TMP/product-generated.h
+echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
+echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
+echo "" >> $PATH_TMP/product-generated.h
+echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
+echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
+echo "" >> $PATH_TMP/product-generated.h
+echo "#endif" >> $PATH_TMP/product-generated.h