From 0b14f9a4460a056f2d72a323e10b1e6e32437d76 Mon Sep 17 00:00:00 2001 From: bnnm Date: Tue, 10 Aug 2021 23:51:48 +0200 Subject: [PATCH] builds: modify how version.h is used to fix issues - version.h is now static (should increase on new releases) - if compiler flag is passed, will try to use version_auto.h (autogen) (auto only on compiler flag to avoid include'ing a non-existant file) - avoid clobbered version.h as may force recompiles --- .gitignore | 2 +- CMakeLists.txt | 4 ++-- Makefile.autotools.am | 2 +- cli/vgmstream_cli.vcxproj | 4 ++-- fb2k/foo_input_vgmstream.vcxproj | 4 ++-- src/libvgmstream.vcxproj | 4 ++-- version-get.sh | 2 +- version-make.bat | 40 ++++++++++++++++++++------------ version-make.sh | 6 ++--- version.h | 18 ++++++++++++-- winamp/in_vgmstream.vcxproj | 4 ++-- xmplay/xmp-vgmstream.vcxproj | 4 ++-- 12 files changed, 59 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index dde46b3b..568b68e2 100644 --- a/.gitignore +++ b/.gitignore @@ -44,7 +44,7 @@ Release /xmplay/Release /xmplay/*.dll /dependencies -/version.h +/version_auto.h /msvc-build.config.ps1 /**/vgmstream-win.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index 698fda5f..47262bdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,10 +88,10 @@ if(MSVC) else() set(VGM_VERSION_GENERATOR version-make.sh) endif() -add_custom_command(OUTPUT ${VGM_SOURCE_DIR}/version.h +add_custom_command(OUTPUT ${VGM_SOURCE_DIR}/version_auto.h COMMAND "${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR}" DEPENDS ${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR}) -add_custom_target(version_h ALL DEPENDS ${VGM_SOURCE_DIR}/version.h) +add_custom_target(version_h ALL DEPENDS ${VGM_SOURCE_DIR}/version_auto.h) # FFmpeg detection if(USE_FFMPEG) diff --git a/Makefile.autotools.am b/Makefile.autotools.am index 41a72740..d34f600f 100644 --- a/Makefile.autotools.am +++ b/Makefile.autotools.am @@ -9,4 +9,4 @@ if HAVE_AUDACIOUS SUBDIRS += audacious endif -EXTRA_DIST = version.h +EXTRA_DIST = version_auto.h diff --git a/cli/vgmstream_cli.vcxproj b/cli/vgmstream_cli.vcxproj index cc5c6a4f..d1045157 100644 --- a/cli/vgmstream_cli.vcxproj +++ b/cli/vgmstream_cli.vcxproj @@ -72,7 +72,7 @@ Disabled ..;../ext_libs/Getopt;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;HAVE_JSON;_DEBUG;_WINDOWS;_CONSOLE;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;HAVE_JSON;_DEBUG;_WINDOWS;_CONSOLE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -97,7 +97,7 @@ ..;../ext_libs/Getopt;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;HAVE_JSON;NDEBUG;_WINDOWS;_CONSOLE;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;HAVE_JSON;NDEBUG;_WINDOWS;_CONSOLE;%(PreprocessorDefinitions) MultiThreaded diff --git a/fb2k/foo_input_vgmstream.vcxproj b/fb2k/foo_input_vgmstream.vcxproj index 066c8d69..9d25ff51 100644 --- a/fb2k/foo_input_vgmstream.vcxproj +++ b/fb2k/foo_input_vgmstream.vcxproj @@ -71,7 +71,7 @@ Disabled ..;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/WTL/Include;$(DependenciesDir)/foobar/foobar2000/SDK;$(DependenciesDir)/foobar/foobar2000/shared;$(DependenciesDir)/foobar/foobar2000;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -97,7 +97,7 @@ ..;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/WTL/Include;$(DependenciesDir)/foobar/foobar2000/SDK;$(DependenciesDir)/foobar/foobar2000/shared;$(DependenciesDir)/foobar/foobar2000;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) MultiThreaded diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 17546f2c..e13dd4ac 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -59,7 +59,7 @@ Disabled ../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -72,7 +72,7 @@ ../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - _WIN32_WINNT=0x501;WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;USE_ALLOCA;NDEBUG;_LIB;%(PreprocessorDefinitions) + _WIN32_WINNT=0x501;WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;USE_ALLOCA;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded diff --git a/version-get.sh b/version-get.sh index b22b07a4..7fbea41a 100644 --- a/version-get.sh +++ b/version-get.sh @@ -1,6 +1,6 @@ #!/bin/sh -# echo current git version (doesn't make version.h) +# echo current git version (doesn't make version_auto.h) # test if git exists if ! command -v git > /dev/null diff --git a/version-make.bat b/version-make.bat index 8e98334f..b891b69e 100644 --- a/version-make.bat +++ b/version-make.bat @@ -1,37 +1,47 @@ @echo off setlocal enableextensions enabledelayedexpansion -REM creates or updates version.h -REM params: $1=filename (usually version.h), $2=VARNAME (usually VGMSTREAM_VERSION) +REM creates or updates version_auto.h +REM params: $1=filename (usually version_auto.h), $2=VARNAME (usually VGMSTREAM_VERSION) REM defaults set VERSION_DEFAULT=unknown set VERSION_FILE=%1 set VERSION_NAME=%2 -if "%~1" == "" set VERSION_FILE=version.h +if "%~1" == "" set VERSION_FILE=version_auto.h if "%~2" == "" set VERSION_NAME=VGMSTREAM_VERSION -if not "%version%"=="" set version=!version:^:=_! +if not "%VERSION%"=="" set VERSION=!VERSION:^:=_! cd /d "%~dp0" -REM try get version from Git, leave original version.h untouched if not possible -for /f %%v in ('git describe --always') do set version=%%v - -if not "%version%"=="" set version=!version:^:=_! -if not "%version%"=="" goto :got_version - -echo Git version not found, can't autogenerate version.h +REM try get version from Git (dynamic) +:get_version_git +for /f %%v in ('git describe --always') do set VERSION=%%v +if not "%VERSION%"=="" set VERSION=!VERSION:^:=_! +if "%VERSION%"=="" goto :get_version_h +if %VERSION%==%VERSION_DEFAULT% goto :get_version_h +set LINE=#define %VERSION_NAME% "%VERSION%" /* autogenerated */ +echo %LINE% > %VERSION_FILE% goto :exit -REM overwrite version.h -:got_version -if %version%==%VERSION_DEFAULT% goto :exit +REM try to get version from version.h (static) +:get_version_h +echo Git version not found, can't autogenerate version_auto.h +set LINE=#define %VERSION_NAME% "%VERSION_DEFAULT%" /* autogenerated */ +if exist "version.h" ( + for /F "tokens=*" %%v in (version.h) do ( + set TOKEN=%%v + REM set COMP=#define %VERSION_NAME% #todo + if /i "!TOKEN:~0,25!"=="#define VGMSTREAM_VERSION" set LINE=%%v + ) +) -echo #define %VERSION_NAME% "%version%" /* autogenerated */ > %VERSION_FILE% +echo %LINE% > %VERSION_FILE% +goto :exit REM done diff --git a/version-make.sh b/version-make.sh index 107a838f..4ed96d02 100644 --- a/version-make.sh +++ b/version-make.sh @@ -1,8 +1,8 @@ #!/bin/sh -# make current git version (overwrites version.h) +# make current git version (overwrites version_auto.h) VERSION_NAME=VGMSTREAM_VERSION -VERSION_FILE=version.h +VERSION_FILE=version_auto.h # test if git exists @@ -17,5 +17,5 @@ fi if [[ $VERSION != fatal* ]] && [ ! -z "$VERSION" ] ; then echo "#define $VERSION_NAME \"$VERSION\" /* autogenerated */" > $VERSION_FILE else - echo "Git version not found, can't autogenerate version.h" + echo "Git version not found, can't autogenerate version_auto.h" fi; diff --git a/version.h b/version.h index 2301a4bf..332aef33 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,18 @@ +#ifndef _VGMSTREAM_H_ +#define _VGMSTREAM_H_ +/* autogenerated version passed by param */ +//todo detect if VGMSTREAM_VERSION is "" (may happen on script error) +#ifndef VGMSTREAM_VERSION +/* autogenerated version on file */ +#ifdef VGMSTREAM_VERSION_AUTO +#include "version_auto.h" +#else /* Static/fallback version. * Version is autogenerated from Git (passed via compiler args, or updated with scripts), but this file is - * for Git-less builds (not installed or downloaded master) and builds that don't do the above should still work. */ -#define VGMSTREAM_VERSION "unknown" + * for Git-less builds (not installed or downloaded master) and builds that don't do the above should still work + * (compiling a well-behaved src shouldn't depend on calling arbitrary scripts). */ +#define VGMSTREAM_VERSION "r1050" +#endif +#endif + +#endif diff --git a/winamp/in_vgmstream.vcxproj b/winamp/in_vgmstream.vcxproj index f2446e6d..1fece220 100644 --- a/winamp/in_vgmstream.vcxproj +++ b/winamp/in_vgmstream.vcxproj @@ -71,7 +71,7 @@ Disabled ..;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;VGM_WINAMP_UNICODE;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;VGM_WINAMP_UNICODE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -98,7 +98,7 @@ ..;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;VGM_WINAMP_UNICODE;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;VGM_WINAMP_UNICODE;%(PreprocessorDefinitions) MultiThreaded diff --git a/xmplay/xmp-vgmstream.vcxproj b/xmplay/xmp-vgmstream.vcxproj index a4d144ce..edaa2890 100644 --- a/xmplay/xmp-vgmstream.vcxproj +++ b/xmplay/xmp-vgmstream.vcxproj @@ -62,7 +62,7 @@ Disabled ..;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) + WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level3 @@ -86,7 +86,7 @@ ..;../ext_includes;../ext_includes/ffmpeg;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - _WIN32_WINNT=0x501;WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) + _WIN32_WINNT=0x501;WIN32;VGMSTREAM_VERSION_AUTO;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_ATRAC9;VGM_USE_CELT;VGM_USE_SPEEX;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) MultiThreaded Level3 ProgramDatabase