build: VERSION fixes

- rename to VERSION to VGMSTREAM_VERSION to avoid some clashes
- improve git-less builds
This commit is contained in:
bnnm 2021-08-07 20:41:50 +02:00
parent 75bb39b843
commit 52f04eef82
24 changed files with 91 additions and 75 deletions

View File

@ -97,7 +97,7 @@ if(WIN32)
file(TO_NATIVE_PATH "${VGM_BINARY_DIR}/version.h" VERSION_H_PATH)
add_custom_command(OUTPUT ${VGM_BINARY_DIR}/version.h
COMMAND "${VGM_SOURCE_DIR}/version.bat"
ARGS ${VERSION_H_PATH} VERSION
ARGS ${VERSION_H_PATH}
DEPENDS ${VGM_SOURCE_DIR}/version.bat)
add_custom_target(version_h DEPENDS ${VGM_BINARY_DIR}/version.h)
else()

View File

@ -2,6 +2,19 @@
# vgmstream makefile
###############################
ifeq ($(VGMSTREAM_VERSION),)
# for current dir (expanded later)
VGMSTREAM_VERSION_CURR=`./version.sh`
# for subdirs (expanded later)
VGMSTREAM_VERSION_PREV=`../version.sh`
else
VGMSTREAM_VERSION_CURR=$(VGMSTREAM_VERSION)
VGMSTREAM_VERSION_PREV=$(VGMSTREAM_VERSION)
endif
export VGMSTREAM_VERSION_PREV
###############################################################################
### external defs
# currently aimed to WIN32 builds but vgmstream_cli should work for others (or use autotools instead)
@ -50,7 +63,7 @@ export RMF SHELL CC AR STRIP WINDRES DLLTOOL
###############################################################################
### build defs
DEF_CFLAGS = -ffast-math -O3 -Wall -Werror=format-security -Wlogical-op -Wdeclaration-after-statement -Wvla -Wimplicit-function-declaration -Wignored-qualifiers
DEF_CFLAGS += -ffast-math -O3 -Wall -Werror=format-security -Wlogical-op -Wdeclaration-after-statement -Wvla -Wimplicit-function-declaration -Wignored-qualifiers
VGM_DEBUG_FLAGS = 0
ifeq ($(VGM_DEBUG_FLAGS),1)
@ -167,20 +180,20 @@ buildrelease-ex: clean bin-ex
buildfullrelease: clean sourceball bin
sourceball:
rm -rf vgmstream-`./version.sh`
git checkout-index -f -a --prefix=vgmstream-`./version.sh`/
# git archive --format zip --output vgmstream-`./version.sh`.zip master
echo "#!/bin/sh" > vgmstream-`./version.sh`/version.sh
echo "echo \"`./version.sh`\"" >> vgmstream-`./version.sh`/version.sh
tar cvzf "vgmstream-`./version.sh`.tar.gz" vgmstream-`./version.sh`/*
rm -rf vgmstream-`./version.sh`
rm -rf vgmstream-$(VGMSTREAM_VERSION_CURR)
git checkout-index -f -a --prefix=vgmstream-$(VGMSTREAM_VERSION_CURR)/
# git archive --format zip --output vgmstream-$(VGMSTREAM_VERSION_CURR).zip master
echo "#!/bin/sh" > vgmstream-$(VGMSTREAM_VERSION_CURR)/version.sh
echo "echo \"$(VGMSTREAM_VERSION_CURR)\"" >> vgmstream-$(VGMSTREAM_VERSION_CURR)/version.sh
tar cvzf "vgmstream-$(VGMSTREAM_VERSION_CURR).tar.gz" vgmstream-$(VGMSTREAM_VERSION_CURR)/*
rm -rf vgmstream-$(VGMSTREAM_VERSION_CURR)
bin mingwbin: vgmstream_cli winamp xmplay
zip -FS -j "vgmstream-`./version.sh`-test.zip" $(ZIP_FILES)
zip -FS -j "vgmstream-$(VGMSTREAM_VERSION_CURR)-test.zip" $(ZIP_FILES)
#separate since vgmstream123 is kinda untested
bin-ex mingwbin-ex: vgmstream_cli winamp xmplay vgmstream123
zip -FS -j "vgmstream-`./version.sh`-test.zip" $(ZIP_FILES) $(ZIP_FILES_AO)
zip -FS -j "vgmstream-$(VGMSTREAM_VERSION_CURR)-test.zip" $(ZIP_FILES) $(ZIP_FILES_AO)
vgmstream_cli mingw_test:
$(MAKE) -C cli vgmstream_cli

View File

@ -40,7 +40,7 @@ extract_non_defines(GTK_CFLAGS_OTHER GTK_CFLAGS_OTHER)
target_compile_definitions(audacious_vgmstream PRIVATE
${AUDACIOUS_DEFINES}
${GTK_DEFINES}
VERSION="${VGMSTREAM_VERSION}")
VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
# Include compile flags for Audacious and GTK
set_target_properties(audacious_vgmstream PROPERTIES

View File

@ -6,7 +6,7 @@ inputplugindir = $(plugindir)/$(INPUT_PLUGIN_DIR)
inputplugin_LTLIBRARIES = libvgmstream.la
AM_MAKEFLAGS=-f Makefile.autotools
AM_CXXFLAGS = -DVERSION=\"VGMSTREAM_VERSION\" -Wall -std=c++11 -fpermissive -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/ext_includes/ $(AUDACIOUS_CFLAGS) $(GTK_CFLAGS)
AM_CXXFLAGS = -DVGMSTREAM_VERSION=\"VGMSTREAM_VERSION\" -Wall -std=c++11 -fpermissive -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/ext_includes/ $(AUDACIOUS_CFLAGS) $(GTK_CFLAGS)
AM_LIBS =
# sources/headers are updated automatically by ./bootstrap script (not all headers are needed though)

View File

@ -22,11 +22,11 @@ extern "C" {
#include "vfs.h"
#ifndef VERSION
#include "version.h"
#ifndef VGMSTREAM_VERSION
#include "../version.h"
#endif
#ifndef VERSION
#define VERSION "(unknown version)"
#ifndef VGMSTREAM_VERSION
#define VGMSTREAM_VERSION "(unknown-version)"
#endif
#define CFG_ID "vgmstream" // ID for storing in audacious
@ -64,7 +64,7 @@ const char *const VgmstreamPlugin::defaults[] = {
// N_(...) for i18n but not much point here
const char VgmstreamPlugin::about[] =
"vgmstream plugin " VERSION " " __DATE__ "\n"
"vgmstream plugin " VGMSTREAM_VERSION " " __DATE__ "\n"
"by hcs, FastElbja, manakoAT, bxaimc, snakemeat, soneek, kode54, bnnm and many others\n"
"\n"
"Audacious plugin:\n"

View File

@ -31,7 +31,7 @@ if(WIN32)
add_dependencies(vgmstream_cli version_h)
elseif(MINGW)
if(VGMSTREAM_VERSION)
target_compile_definitions(vgmstream_cli PRIVATE VERSION="${VGMSTREAM_VERSION}")
target_compile_definitions(vgmstream_cli PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
endif()
# Also, on MinGW when using GCC, these flags need to be included to prevent requiring MinGW's runtime DLLs from being included, which does unfortunately increase the size of the EXE
@ -45,7 +45,7 @@ if(WIN32)
install_dlls(${CMAKE_INSTALL_PREFIX}/bin)
elseif(VGMSTREAM_VERSION)
# Include the version string
target_compile_definitions(vgmstream_cli PRIVATE VERSION="${VGMSTREAM_VERSION}")
target_compile_definitions(vgmstream_cli PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
endif()
@ -74,7 +74,7 @@ if(NOT WIN32)
${AO_INCLUDE_DIR})
# Include the version string
target_compile_definitions(vgmstream123 PRIVATE VERSION="${VGMSTREAM_VERSION}")
target_compile_definitions(vgmstream123 PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")

View File

@ -37,11 +37,11 @@ export CFLAGS LDFLAGS
### targets
vgmstream_cli: libvgmstream.a $(TARGET_EXT_LIBS)
$(CC) $(CFLAGS) "-DVERSION=\"`../version.sh`\"" vgmstream_cli.c $(LDFLAGS) -o $(OUTPUT_CLI)
$(CC) $(CFLAGS) "-DVGMSTREAM_VERSION=\"$(VGMSTREAM_VERSION_PREV)\"" vgmstream_cli.c $(LDFLAGS) -o $(OUTPUT_CLI)
$(STRIP) $(OUTPUT_CLI)
vgmstream123: libvgmstream.a $(TARGET_EXT_LIBS)
$(CC) $(CFLAGS) -I$(LIBAO_INC_PATH) "-DVERSION=\"`../version.sh`\"" vgmstream123.c $(LDFLAGS) -L$(LIBAO_LIB_PATH) -lao -o $(OUTPUT_123)
$(CC) $(CFLAGS) -I$(LIBAO_INC_PATH) "-DVGMSTREAM_VERSION=\"$(VGMSTREAM_VERSION_PREV)\"" vgmstream123.c $(LDFLAGS) -L$(LIBAO_LIB_PATH) -lao -o $(OUTPUT_123)
$(STRIP) $(OUTPUT_123)
libvgmstream.a:

View File

@ -39,11 +39,11 @@
#include "../src/vgmstream.h"
#include "../src/plugins.h"
#ifndef VERSION
# include "version.h"
#ifndef VGMSTREAM_VERSION
# include "../version.h"
#endif
#ifndef VERSION
# define VERSION "(unknown version)"
#ifndef VGMSTREAM_VERSION
# define VGMSTREAM_VERSION "(unknown version)"
#endif
@ -134,7 +134,7 @@ static void usage(const char *progname) {
default_driver = info->short_name;
}
printf("vgmstream123 " VERSION ", built " __DATE__ "\n"
printf("vgmstream123 " VGMSTREAM_VERSION ", built " __DATE__ "\n"
"\n"
"Usage: %s [options] INFILE ...\n"
"Play streamed audio from video games.\n"

View File

@ -16,11 +16,11 @@
#define STDOUT_FILENO 1
#endif
#ifndef VERSION
#include "version.h"
#ifndef VGMSTREAM_VERSION
#include "../version.h"
#endif
#ifndef VERSION
#define VERSION "(unknown version)"
#ifndef VGMSTREAM_VERSION
#define VGMSTREAM_VERSION "(unknown version)"
#endif
#ifdef HAVE_JSON
@ -39,7 +39,7 @@
static size_t make_wav_header(uint8_t* buf, size_t buf_size, int32_t sample_count, int32_t sample_rate, int channels, int smpl_chunk, int32_t loop_start, int32_t loop_end);
static void usage(const char* name, int is_full) {
fprintf(stderr,"vgmstream CLI decoder " VERSION " " __DATE__ "\n"
fprintf(stderr,"vgmstream CLI decoder " VGMSTREAM_VERSION " " __DATE__ "\n"
"Usage: %s [-o <outfile.wav>] [options] <infile>\n"
"Options:\n"
" -o <outfile.wav>: name of output .wav file, default <infile>.wav\n"
@ -457,7 +457,7 @@ void print_json_version() {
json_array_append(cext_list, cext);
}
json_t* version_string = json_string(VERSION);
json_t* version_string = json_string(VGMSTREAM_VERSION);
json_t* final_object = json_object();
json_object_set(final_object, "version", version_string);
@ -913,7 +913,7 @@ fail:
#ifdef HAVE_JSON
static void print_json_info(VGMSTREAM* vgm, cli_config* cfg) {
json_t* version_string = json_string(VERSION);
json_t* version_string = json_string(VGMSTREAM_VERSION);
vgmstream_info info;
describe_vgmstream_info(vgm, &info);

View File

@ -88,10 +88,10 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -116,10 +116,10 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -63,7 +63,7 @@ if(MSVC)
add_dependencies(foo_input_vgmstream version_h)
elseif(MINGW)
if(VGMSTREAM_VERSION)
target_compile_definitions(foo_input_vgmstream PRIVATE VERSION="${VGMSTREAM_VERSION}")
target_compile_definitions(foo_input_vgmstream PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
endif()
# Also, on MinGW when using GCC, these flags need to be included to prevent requiring MinGW's runtime DLLs from being included, which does unfortunately increase the size of the DLL

View File

@ -88,10 +88,10 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -118,10 +118,10 @@
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -19,18 +19,17 @@ extern "C" {
#include "foo_vgmstream.h"
#include "foo_filetypes.h"
#ifndef VERSION
#include "version.h"
#ifndef VGMSTREAM_VERSION
#include "../version.h"
#endif
#ifndef VERSION
#ifndef VGMSTREAM_VERSION
#define PLUGIN_VERSION __DATE__
#else
#define PLUGIN_VERSION VERSION
#define PLUGIN_VERSION VGMSTREAM_VERSION
#endif
#define APP_NAME "vgmstream plugin"
#define PLUGIN_DESCRIPTION "vgmstream plugin " VERSION " " __DATE__ "\n" \
#define PLUGIN_DESCRIPTION "vgmstream plugin " VGMSTREAM_VERSION " " __DATE__ "\n" \
"by hcs, FastElbja, manakoAT, bxaimc, snakemeat, soneek, kode54, bnnm and many others\n" \
"\n" \
"foobar2000 plugin by Josh W, kode54\n" \

View File

@ -1,7 +1,7 @@
@echo off
REM creates or updates version.h
REM params: $1=filename (usually version.h), $2=VARNAME (usually VERSION)
REM params (optional): $1=filename (usually [relpath]/version.h), $2=VARNAME (usually VGMSTREAM_VERSION)
setlocal enableextensions enabledelayedexpansion
@ -10,7 +10,7 @@ set VERSION_DEFAULT=unknown
set VERSION_FILE=%1
set VERSION_NAME=%2
if "%~1" == "" set VERSION_FILE=version.h
if "%~2" == "" set VERSION_NAME=VERSION
if "%~2" == "" set VERSION_NAME=VGMSTREAM_VERSION
if not "%version%"=="" set version=!version:^:=_!

4
version.h Normal file
View File

@ -0,0 +1,4 @@
/* 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"

View File

@ -12,7 +12,7 @@ fi
# ignore git stderr "fatal:
if case $VERSION in fatal*) ;; *) false;; esac; then
echo ""
echo "unknown"
else
echo "$VERSION"
fi;

View File

@ -38,7 +38,7 @@ if(MSVC)
add_dependencies(in_vgmstream version_h)
elseif(MINGW)
if(VGMSTREAM_VERSION)
target_compile_definitions(in_vgmstream PRIVATE VERSION="${VGMSTREAM_VERSION}")
target_compile_definitions(in_vgmstream PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
endif()
# Also, on MinGW when using GCC, these flags need to be included to prevent requiring MinGW's runtime DLLs from being included, which does unfortunately increase the size of the DLL

View File

@ -38,7 +38,7 @@ SRC_SRCS = in_vgmstream.c in_streamfile.c in_config.c
### targets
in_vgmstream: libvgmstream.a $(TARGET_EXT_LIBS) resource.o
$(CC) -shared -static-libgcc $(CFLAGS) "-DVERSION=\"`../version.sh`\"" $(SRC_SRCS) resource.o $(LDFLAGS) -o $(OUTPUT_WINAMP)
$(CC) -shared -static-libgcc $(CFLAGS) "-DVGMSTREAM_VERSION=\"$(VGMSTREAM_VERSION_PREV)\"" $(SRC_SRCS) resource.o $(LDFLAGS) -o $(OUTPUT_WINAMP)
$(STRIP) $(OUTPUT_WINAMP)
resource.o: resource.rc resource.h

View File

@ -3,14 +3,14 @@
*/
#include "in_vgmstream.h"
#ifndef VERSION
#include "version.h"
#ifndef VGMSTREAM_VERSION
#include "../version.h"
#endif
#ifndef VERSION
#define VERSION "(unknown version)"
#ifndef VGMSTREAM_VERSION
#define VGMSTREAM_VERSION "(unknown version)"
#endif
#define PLUGIN_DESCRIPTION "vgmstream plugin " VERSION " " __DATE__
#define PLUGIN_DESCRIPTION "vgmstream plugin " VGMSTREAM_VERSION " " __DATE__
/* ***************************************** */

View File

@ -89,10 +89,10 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -119,10 +119,10 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -22,7 +22,7 @@ if(MSVC)
add_dependencies(xmp-vgmstream version_h)
elseif(MINGW)
if(VGMSTREAM_VERSION)
target_compile_definitions(xmp-vgmstream PRIVATE VERSION="${VGMSTREAM_VERSION}")
target_compile_definitions(xmp-vgmstream PRIVATE VGMSTREAM_VERSION="${VGMSTREAM_VERSION}")
endif()
# Also, on MinGW when using GCC, these flags need to be included to prevent requiring MinGW's runtime DLLs from being included, which does unfortunately increase the size of the DLL

View File

@ -36,7 +36,7 @@ export CFLAGS LDFLAGS
### targets
xmp_vgmstream: libvgmstream.a $(TARGET_EXT_LIBS)
$(CC) -shared -static-libgcc $(CFLAGS) "-DVERSION=\"`../version.sh`\"" xmp_vgmstream.c $(LDFLAGS) -o $(OUTPUT_XMPLAY) xmpin.def
$(CC) -shared -static-libgcc $(CFLAGS) "-DVGMSTREAM_VERSION=\"$(VGMSTREAM_VERSION_PREV)\"" xmp_vgmstream.c $(LDFLAGS) -o $(OUTPUT_XMPLAY) xmpin.def
$(STRIP) $(OUTPUT_XMPLAY)
libvgmstream.a:

View File

@ -77,10 +77,10 @@
<ModuleDefinitionFile>xmpin.def</ModuleDefinitionFile>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -107,10 +107,10 @@
<ModuleDefinitionFile>xmpin.def</ModuleDefinitionFile>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>
<Command>"$(ProjectDir)..\version.bat"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Generating version.h</Message>
<Message>Generating version</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -16,11 +16,11 @@
#include "../src/plugins.h"
#ifndef VERSION
#include "version.h"
#ifndef VGMSTREAM_VERSION
#include "../version.h"
#endif
#ifndef VERSION
#define VERSION "(unknown version)"
#ifndef VGMSTREAM_VERSION
#define VGMSTREAM_VERSION "(unknown version)"
#endif
/* ************************************* */
@ -435,7 +435,7 @@ static void build_extension_list() {
/* info for the "about" button in plugin options */
void WINAPI xmplay_About(HWND win) {
MessageBox(win,
"vgmstream plugin " VERSION " " __DATE__ "\n"
"vgmstream plugin " VGMSTREAM_VERSION " " __DATE__ "\n"
"by hcs, FastElbja, manakoAT, bxaimc, snakemeat, soneek, kode54, bnnm and many others\n"
"\n"
"XMPlay plugin by unknownfile, PSXGamerPro1, kode54\n"