(Makefiles) Improve version_git.o regeneration

Only rebuild the git version object when the git hash changes.
This commit is contained in:
Hugo Hromic 2020-07-19 22:05:20 +01:00
parent e7ea698d58
commit ca8e465cae
2 changed files with 8 additions and 9 deletions

View File

@ -215,13 +215,6 @@ $(OBJDIR)/%.o: %.m
@$(if $(Q), $(shell echo echo OBJC $<),) @$(if $(Q), $(shell echo echo OBJC $<),)
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $< $(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) $(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),) @$(if $(Q), $(shell echo echo AS $<),)
@ -233,7 +226,6 @@ $(OBJDIR)/%.o: %.rc $(HEADERS)
$(Q)$(WINDRES) -o $@ $< $(Q)$(WINDRES) -o $@ $<
install: $(TARGET) install: $(TARGET)
rm -f $(OBJDIR)/version_git.o
mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_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 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 OBJ += frontend/drivers/platform_ctr.o
endif endif
# Git # Git Version
GIT_VERSION := $(shell git rev-parse --short HEAD 2>/dev/null) GIT_VERSION := $(shell git rev-parse --short HEAD 2>/dev/null)
ifneq ($(GIT_VERSION),) 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) DEFINES += -DHAVE_GIT_VERSION -DGIT_VERSION=$(GIT_VERSION)
OBJ += version_git.o OBJ += version_git.o
endif endif