Merge pull request #11045 from hhromic/imprv-version-git

(Makefiles) Improve version_git.o regeneration
This commit is contained in:
Autechre 2020-07-20 00:25:48 +02:00 committed by GitHub
commit bda956e7a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -215,13 +215,6 @@ $(OBJDIR)/%.o: %.m
@$(if $(Q), $(shell echo echo OBJC $<),)
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
.FORCE:
$(OBJDIR)/version_git.o: version_git.c .FORCE
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),)
@ -233,7 +226,6 @@ $(OBJDIR)/%.o: %.rc $(HEADERS)
$(Q)$(WINDRES) -o $@ $<
install: $(TARGET)
rm -f $(OBJDIR)/version_git.o
mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/applications 2>/dev/null || /bin/true

View File

@ -157,10 +157,17 @@ ifeq ($(TARGET), retroarch_3ds)
OBJ += frontend/drivers/platform_ctr.o
endif
# Git
# Git Version
GIT_VERSION := $(shell git rev-parse --short HEAD 2>/dev/null)
ifneq ($(GIT_VERSION),)
LAST_GIT_VERSION := $(shell cat "$(OBJDIR)"/last-git-version 2>/dev/null)
ifneq ($(GIT_VERSION), $(LAST_GIT_VERSION))
$(shell \
mkdir -p "$(OBJDIR)"; \
echo "$(GIT_VERSION)" > "$(OBJDIR)"/last-git-version; \
touch version_git.c)
endif
DEFINES += -DHAVE_GIT_VERSION -DGIT_VERSION=$(GIT_VERSION)
OBJ += version_git.o
endif