From 6e2d5a993fa93497ea08b1141e7177cb5a8ba3af Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Wed, 19 May 2021 00:12:22 -0700 Subject: [PATCH] build: Generate xemu version header --- .gitignore | 1 - meson.build | 35 ++++++++++++++++++----------------- scripts/xemu-version.sh | 25 +++++++++++++++++++++---- version.rc | 15 ++++----------- xemu-version.c | 6 ++++++ 5 files changed, 49 insertions(+), 33 deletions(-) create mode 100644 xemu-version.c diff --git a/.gitignore b/.gitignore index 399f7794dc..1dc75dccc0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,4 @@ GTAGS build.log /dist -/xemu-version.c /xemu.ini diff --git a/meson.build b/meson.build index 4ad45c7d30..ddf6d711eb 100644 --- a/meson.build +++ b/meson.build @@ -149,6 +149,20 @@ if sparse.found() '-Wno-non-pointer-null']) endif +########################################### +# xemu Version +########################################### + +xemu_version_cmd = [find_program('scripts/xemu-version.sh'), + meson.current_source_dir()] +xemu_version = custom_target('xemu-version-macro.h', + output: 'xemu-version-macro.h', + command: xemu_version_cmd, + capture: true, + build_by_default: true, + build_always_stale: true) + + ########################################### # Target-specific checks and dependencies # ########################################### @@ -178,7 +192,8 @@ if targetos == 'windows' win = import('windows') version_res = win.compile_resources('version.rc', depend_files: files('pc-bios/qemu-nsis.ico'), - include_directories: include_directories('.')) + include_directories: include_directories('.'), + depends: xemu_version) elif targetos == 'darwin' coref = dependency('appleframeworks', modules: 'CoreFoundation') iokit = dependency('appleframeworks', modules: 'IOKit') @@ -1712,16 +1727,8 @@ qemu_version = custom_target('qemu-version.h', build_by_default: true, build_always_stale: true) -xemu_version_cmd = [find_program('scripts/xemu-version.sh'), - meson.current_source_dir()] -xemu_version = custom_target('xemu-version.c', - output: 'xemu-version.c', - command: xemu_version_cmd, - capture: true, - build_by_default: true, - build_always_stale: true) - genh += qemu_version +genh += xemu_version hxdep = [] hx_headers = [ @@ -1946,13 +1953,7 @@ if have_block softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')]) endif -specific_ss.add(files('xemu-xbe.c')) - -libxemuver = static_library('xemuver', sources: xemu_version, - name_suffix: 'fa', - build_by_default: false) -xemuver = declare_dependency(link_whole: libxemuver) -common_ss.add(xemuver) +specific_ss.add(files('xemu-xbe.c', 'xemu-version.c')) common_ss.add(files('cpus-common.c')) diff --git a/scripts/xemu-version.sh b/scripts/xemu-version.sh index b1e79addcf..23f14a5f11 100755 --- a/scripts/xemu-version.sh +++ b/scripts/xemu-version.sh @@ -26,9 +26,26 @@ XEMU_VERSION=$( \ cat XEMU_VERSION; \ fi) +get_version_field() { + echo ${XEMU_VERSION}-0 | cut -d- -f$1 +} + +get_version_dot () { + echo $(get_version_field 1) | cut -d. -f$1 +} + +XEMU_VERSION_MAJOR=$(get_version_dot 1) +XEMU_VERSION_MINOR=$(get_version_dot 2) +XEMU_VERSION_MICRO=$(get_version_dot 3) +XEMU_VERSION_PATCH=$(get_version_field 2) + cat < -#if 0 #include "config-host.h" -#endif - -/* FIXME: Automate */ -#define QEMU_VERSION "0.5.1" -#define QEMU_VERSION_MAJOR 0 -#define QEMU_VERSION_MINOR 5 -#define QEMU_VERSION_MICRO 1 +#include "xemu-version-macro.h" VS_VERSION_INFO VERSIONINFO -FILEVERSION QEMU_VERSION_MAJOR,QEMU_VERSION_MINOR,QEMU_VERSION_MICRO,0 -PRODUCTVERSION QEMU_VERSION_MAJOR,QEMU_VERSION_MINOR,QEMU_VERSION_MICRO,0 +FILEVERSION XEMU_VERSION_MAJOR,XEMU_VERSION_MINOR,XEMU_VERSION_MICRO,XEMU_VERSION_PATCH +PRODUCTVERSION XEMU_VERSION_MAJOR,XEMU_VERSION_MINOR,XEMU_VERSION_MICRO,XEMU_VERSION_PATCH FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_APP @@ -23,7 +16,7 @@ FILESUBTYPE VFT2_UNKNOWN { VALUE "CompanyName", "https://xemu.app" VALUE "FileDescription", "xemu: Original Xbox Emulator" - VALUE "FileVersion", QEMU_VERSION + VALUE "FileVersion", XEMU_VERSION VALUE "LegalCopyright", "Copyright various authors. Released under the GNU General Public License." VALUE "LegalTrademarks", "QEMU is a trademark of Fabrice Bellard." VALUE "ProductName", "xemu" diff --git a/xemu-version.c b/xemu-version.c new file mode 100644 index 0000000000..523d955760 --- /dev/null +++ b/xemu-version.c @@ -0,0 +1,6 @@ +#include "xemu-version-macro.h" + +const char *xemu_version = XEMU_VERSION; +const char *xemu_branch = XEMU_BRANCH;; +const char *xemu_commit = XEMU_COMMIT; +const char *xemu_date = XEMU_DATE;