mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-11-23 04:19:50 +00:00
Support building from source code archive (#85)
Save git describe output on `git archive` and fall back to saved output for version number if building outside of a git repo.
This commit is contained in:
parent
d757d8645a
commit
bf6a5a643f
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Save version on export to support building outside of git repo
|
||||
version.txt export-subst
|
11
Makefile
11
Makefile
@ -19,8 +19,12 @@ $(SKELATOOL64):
|
||||
|
||||
@$(MAKE) -C skelatool64
|
||||
|
||||
# Use tag name if a tag exists, otherwise use commit hash
|
||||
GAME_VERSION := $(shell git describe --tags --exact-match HEAD 2>/dev/null || git rev-parse --short HEAD)
|
||||
# Use tag name if the current commit is tagged, otherwise use commit hash
|
||||
# If not in a git repo, fall back to exported version
|
||||
GAME_VERSION := $(shell \
|
||||
(git describe --tags HEAD 2>/dev/null || cat version.txt) | \
|
||||
awk -F '-' '{print (NF >= 3 ? substr($$3, 2) : $$1)}' \
|
||||
)
|
||||
|
||||
OPTIMIZER := -Os
|
||||
LCDEFS := -DDEBUG -DGAME_VERSION=\"$(GAME_VERSION)\" -g -Werror -Wall
|
||||
@ -142,7 +146,8 @@ buildgame: $(BASE_TARGET_NAME).z64
|
||||
.PHONY: gameversion
|
||||
build/version.txt: gameversion
|
||||
ifneq ($(shell cat build/version.txt 2>/dev/null), $(GAME_VERSION))
|
||||
echo -n $(GAME_VERSION) > build/version.txt
|
||||
@mkdir -p $(@D)
|
||||
@echo -n $(GAME_VERSION) > $@
|
||||
endif
|
||||
|
||||
include $(COMMONRULES)
|
||||
|
1
version.txt
Normal file
1
version.txt
Normal file
@ -0,0 +1 @@
|
||||
$Format:%(describe:tags)$
|
Loading…
Reference in New Issue
Block a user