Skip to content

Commit

Permalink
Merge branch 'master' into handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Nov 22, 2024
2 parents 508867a + b67b006 commit ee65dbc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
23 changes: 19 additions & 4 deletions VortexEngine/VortexCLI/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SUFFIXES:

# List all make targets which are not filenames
.PHONY: all tests clean wasm
.PHONY: all tests clean wasm compute_version

# compiler tool definitions
ifdef WASM
Expand All @@ -21,7 +21,11 @@ CFLAGS=-O2 -g -Wall

# compiler defines
DEFINES=\
-D VORTEX_LIB
-D VORTEX_LIB \
-D VORTEX_VERSION_MAJOR=$(VORTEX_VERSION_MAJOR) \
-D VORTEX_VERSION_MINOR=$(VORTEX_VERSION_MINOR) \
-D VORTEX_BUILD_NUMBER=$(VORTEX_BUILD_NUMBER) \
-D VORTEX_VERSION_NUMBER=$(VORTEX_VERSION_NUMBER)

# compiler include paths
INCLUDES=\
Expand Down Expand Up @@ -107,8 +111,8 @@ wasm: FORCE
env WASM=1 $(MAKE)

# target for vortex lib
vortex: $(DEPS)
$(CC) $(CFLAGS) $^ -o $@ $(LLIBS)
vortex: compute_version $(DEPS)
$(CC) $(CFLAGS) $(DEPS) -o $@ $(LLIBS)

# catch-all make target to generate .o and .d files
%.o: %.cpp
Expand All @@ -129,6 +133,17 @@ clean:
@$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) vortex.wasm *.txt FlashStorage.flash
$(MAKE) -C ../VortexLib clean

# calculate the version number of the build
compute_version:
$(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list | grep --invert-match '[a-zA-Z]' | sort -V | tail -n1))
$(eval VORTEX_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1))
$(eval VORTEX_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f2))
$(eval VORTEX_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD))
$(eval VORTEX_VERSION_MAJOR := $(if $(VORTEX_VERSION_MAJOR),$(VORTEX_VERSION_MAJOR),0))
$(eval VORTEX_VERSION_MINOR := $(if $(VORTEX_VERSION_MINOR),$(VORTEX_VERSION_MINOR),1))
$(eval VORTEX_BUILD_NUMBER := $(if $(VORTEX_BUILD_NUMBER),$(VORTEX_BUILD_NUMBER),0))
$(eval VORTEX_VERSION_NUMBER := $(VORTEX_VERSION_MAJOR).$(VORTEX_VERSION_MINOR).$(VORTEX_BUILD_NUMBER))

# Now include our target dependency files
# the hyphen means ignore non-existent files
-include $(DFILES)
10 changes: 5 additions & 5 deletions VortexEngine/VortexLib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ TARGETS=vortex.a
endif

# Default target for 'make' command
all: compute_version $(TARGETS)
all: $(TARGETS)

# unit test target
tests: $(TESTS)
Expand All @@ -123,11 +123,11 @@ wasm: FORCE
env WASM=1 $(MAKE)

# target for vortex lib
vortex.a: $(DEPS)
$(AR) $@ $^
vortex.a: compute_version $(DEPS)
$(AR) $@ $(DEPS)

VortexLib.js: $(DEPS)
$(CC) $(LDFLAGS) $^ -o $@ $(LLIBS)
VortexLib.js: compute_version $(DEPS)
$(CC) $(LDFLAGS) $(DEPS) -o $@ $(LLIBS)

# catch-all make target to generate .o and .d files
%.o: %.cpp
Expand Down

0 comments on commit ee65dbc

Please sign in to comment.