Skip to content

Commit

Permalink
add auto versioning system
Browse files Browse the repository at this point in the history
  • Loading branch information
zefie committed Oct 31, 2021
1 parent 5443300 commit 28bdca6
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 12 deletions.
7 changes: 6 additions & 1 deletion minibae/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,22 @@ OBJ_BIN := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(basename ${SRC_BIN})))
ARCH := -m32 -static
CC := gcc
CXX := g++
LD := gcc
LD := $(CC)
AR := ar
STRIP := strip

OPTI := -O2 -fPIC
CFLAGS := $(ARCH) $(OPTI) -g $(INC_PATH) -D_THREAD_SAFE -Wno-unused-value
CFLAGS += -DX_PLATFORM=X_ANSI
#CFLAGS += -D_DEBUG=1

include Makefile.versioning
CFLAGS += -D_VERSION=\""$(VERSION)"\"

CXXFLAGS := $(CFLAGS)
LDFLAGS := $(ARCH) $(OPTI) -s


LIBS = -lpthread

all: $(TARGET_LIB).a ${TARGET_LIB}.so $(TARGET_BIN)
Expand Down
6 changes: 5 additions & 1 deletion minibae/Makefile.clang
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ OBJ_BIN := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(basename ${SRC_BIN})))
ARCH := -m32 -static
CC := clang
CXX := clang++
LD := clang
LD := $(CC)
AR := ar
STRIP := strip

Expand All @@ -90,6 +90,10 @@ CLANG_SANI := -fsanitize=integer
CFLAGS := $(ARCH) $(OPTI) -g $(INC_PATH) -D_THREAD_SAFE -Wno-pragma-pack -Wno-unused-value
CFLAGS += -DX_PLATFORM=X_ANSI
#CFLAGS += -D_DEBUG=1

include Makefile.versioning
CFLAGS += -D_VERSION=\""$(VERSION)"\"

CXXFLAGS := $(CFLAGS)
LDFLAGS := $(ARCH) $(OPTI)

Expand Down
6 changes: 5 additions & 1 deletion minibae/Makefile.emcc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ OBJ_BIN := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(basename ${SRC_BIN}))
ARCH := -m32 -static
CC := emcc
CXX := emcc
LD := emcc
LD := $(CC)
AR := emar
STRIP := strip

Expand All @@ -93,6 +93,10 @@ OPTI := -O2
CFLAGS := $(ARCH) $(OPTI) -fPIC -g $(INC_PATH) -D_THREAD_SAFE -Wno-pragma-pack -Wno-unused-value
CFLAGS += -DX_PLATFORM=X_ANSI
#CFLAGS += -D_DEBUG=1

include Makefile.versioning
CFLAGS += -D_VERSION=\""$(VERSION)"\"

CXXFLAGS := $(CFLAGS)
LDFLAGS := $(ARCH) $(OPTI) -s 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[$$Browser]' -s EXPORT_ES6=1 -s EXPORTED_RUNTIME_METHODS=[FS] -s SINGLE_FILE=1

Expand Down
6 changes: 5 additions & 1 deletion minibae/Makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,18 @@ OBJ_BIN := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(basename ${SRC_BIN})))
ARCH := -m32 -static
CC := i686-w64-mingw32-gcc-win32
CXX := i686-w64-mingw32-g++-win32
LD := i686-w64-mingw32-g++-win32
LD := $(CC)
AR := i686-w64-mingw32-gcc-ar-win32
STRIP := i686-w64-mingw32-strip

OPTI := -O2
CFLAGS := $(ARCH) $(OPTI) -g $(INC_PATH) -D_THREAD_SAFE -Wno-unused-value
CFLAGS += -DX_PLATFORM=X_WIN95
#CFLAGS += -D_DEBUG=1

include Makefile.versioning
CFLAGS += -D_VERSION=\""$(VERSION)"\"

CXXFLAGS := $(CFLAGS)
LDFLAGS := $(ARCH) $(OPTI) -s

Expand Down
14 changes: 14 additions & 0 deletions minibae/Makefile.versioning
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d")
VERSION := $(TAG:v%=%)
ifneq ($(COMMIT), $(TAG_COMMIT))
VERSION := git-$(COMMIT)-$(DATE)
endif
ifeq ($(VERSION),)
VERSION := git-$(COMMIT)-$(DATE)
endif
ifneq ($(shell git status --porcelain),)
VERSION := $(VERSION)-dirty
endif
88 changes: 88 additions & 0 deletions minibae/src/BAE_Source/Common/MiniBAE.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,94 @@

#define TRACKING 0



const char* BAE_GetVersion()
{
size_t maxStrSize = 64;
char *versionString = (char *)malloc(sizeof (char) * maxStrSize);
#ifdef _VERSION
snprintf(versionString, maxStrSize, "version %s", _VERSION);
#else
snprintf(versionString, maxStrSize, "unknown version built %s", __DATE__);
#endif
return versionString;
}

const char* BAE_GetCompileInfo() {
size_t maxStrSize = 128;
char *versionString = (char *)malloc(sizeof (char) * maxStrSize);
#ifdef __clang_major_
#ifdef __cplusplus
snprintf(versionString, maxStrSize, "clang++ v%d.%d", __clang_major__, __clang_minor__);
#else
snprintf(versionString, maxStrSize, "clang v%d.%d", __clang_major__, __clang_minor__);
#endif
#elif __MINGW32__
#ifdef __cplusplus
snprintf(versionString, maxStrSize, "mingw32 v%d.%d (g++ v%d.%d)", __MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION, __GNUC__, __GNUC_MINOR__);
#else
snprintf(versionString, maxStrSize, "mingw32 v%d.%d (gcc v%d.%d)", __MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION, __GNUC__, __GNUC_MINOR__);
#endif
#elif __GNUC__
#ifdef __cplusplus
snprintf(versionString, maxStrSize, "g++ v%d.%d", __GNUC__, __GNUC_MINOR__);
#else
snprintf(versionString, maxStrSize, "gcc v%d.%d", __GNUC__, __GNUC_MINOR__);
#endif
#else
snprintf(versionString, maxStrSize, "UNKNOWN");
#endif
return versionString;
}

const char *BAE_GetCurrentCPUArchitecture() { //Get current architecture, detectx nearly every architecture. Coded by Freak
#if defined(__x86_64__) || defined(_M_X64)
return "x86_64";
#elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
return "x86_32";
#elif defined(__ARM_ARCH_2__)
return "ARM2";
#elif defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__)
return "ARM3";
#elif defined(__ARM_ARCH_4T__) || defined(__TARGET_ARM_4T)
return "ARM4T";
#elif defined(__ARM_ARCH_5_) || defined(__ARM_ARCH_5E_)
return "ARM5"
#elif defined(__ARM_ARCH_6T2_) || defined(__ARM_ARCH_6T2_)
return "ARM6T2";
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
return "ARM6";
#elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
return "ARM7";
#elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
return "ARM7A";
#elif defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
return "ARM7R";
#elif defined(__ARM_ARCH_7M__)
return "ARM7M";
#elif defined(__ARM_ARCH_7S__)
return "ARM7S";
#elif defined(__aarch64__) || defined(_M_ARM64)
return "ARM64";
#elif defined(mips) || defined(__mips__) || defined(__mips)
return "MIPS";
#elif defined(__sh__)
return "SUPERH";
#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC)
return "POWERPC";
#elif defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
return "POWERPC64";
#elif defined(__sparc__) || defined(__sparc)
return "SPARC";
#elif defined(__m68k__)
return "M68K";
#else
return "UNKNOWN";
#endif
}


// Private types/structs
// ----------------------------------------------------------------------------

Expand Down
5 changes: 5 additions & 0 deletions minibae/src/BAE_Source/Common/MiniBAE.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
extern "C" {
#endif


const char * BAE_GetCurrentCPUArchitecture();
const char * BAE_GetVersion();
const char * BAE_GetCompileInfo();

// types
typedef enum
{
Expand Down
22 changes: 14 additions & 8 deletions minibae/src/playbae/playbae.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ BAE_UNSIGNED_FIXED calculateVolume(BAE_UNSIGNED_FIXED volume, BAE_BOOL multiply)


static BAEResult MuteCommaSeperatedChannels(BAESong theSong, char* channelsToMute) {
BAEResult err = 0;
BAEResult err = BAE_NO_ERROR;
char *token = strtok(channelsToMute, ",");
int tokenInt = 0;
while (token != NULL && err == 0)
Expand All @@ -227,7 +227,7 @@ static BAEResult MuteCommaSeperatedChannels(BAESong theSong, char* channelsToMut
}


static void * displayCurrentPosition(unsigned long currentPosition) {
static void displayCurrentPosition(unsigned long currentPosition) {
int m, s, ms = 0;
positionDisplayMultiplierCounter = positionDisplayMultiplierCounter + 1;
if (positionDisplayMultiplierCounter == positionDisplayMultiplier) {
Expand Down Expand Up @@ -555,8 +555,8 @@ static BAEResult PlayRMF(BAEMixer theMixer, char *fileName, BAE_UNSIGNED_FIXED v
return(err);
}

int playFile(BAEMixer theMixer, char *parmFile, BAE_UNSIGNED_FIXED volume, unsigned int timeLimit, unsigned int loopCount, BAEReverbType reverbType, char *midiMuteChannels) {
int err = 0;
BAEResult playFile(BAEMixer theMixer, char *parmFile, BAE_UNSIGNED_FIXED volume, unsigned int timeLimit, unsigned int loopCount, BAEReverbType reverbType, char *midiMuteChannels) {
BAEResult err = BAE_NO_ERROR;
char fileHeader[5]; // 4 char + 1 null byte
long filePtr;
filePtr = BAE_FileOpenForRead(parmFile);
Expand All @@ -576,10 +576,10 @@ int playFile(BAEMixer theMixer, char *parmFile, BAE_UNSIGNED_FIXED volume, unsig
playbae_printf("Playing WAVE %s\n", parmFile);
err = PlayPCM(theMixer, parmFile, BAE_AIFF_TYPE, volume, timeLimit);
} else {
err = 10069;
err = (BAEResult)10069;
}
} else {
err = filePtr;
err = (BAEResult)filePtr;
}
return err;
}
Expand All @@ -599,11 +599,13 @@ int main(int argc, char *argv[])
int maxVoices = BAE_MAX_VOICES;
BAEBankToken bank;
int doneCommand = 0;
short reverbType = 8; // early reflections
BAEReverbType reverbType = BAE_REVERB_TYPE_8; // early reflections
char parmFile[1024];
char midiMuteChannels[512];
const char *libMiniBAECPUArch;
const char *libMiniBAEVersion;
const char *libMiniBAECompInfo;
BAERate rate = BAE_RATE_44K;

memset(parmFile, '\0', 1024);
memset(midiMuteChannels, '\0', 512);

Expand All @@ -621,6 +623,10 @@ int main(int argc, char *argv[])
}

if (!silentMode) {
libMiniBAEVersion = BAE_GetVersion();
libMiniBAECompInfo = BAE_GetCompileInfo();
libMiniBAECPUArch = BAE_GetCurrentCPUArchitecture();
playbae_printf("playbae %s built with %s, libminiBAE %s\n", libMiniBAECPUArch, libMiniBAECompInfo, libMiniBAEVersion);
playbae_printf(copyrightInfo);
}

Expand Down

0 comments on commit 28bdca6

Please sign in to comment.