From 0ff3f04700ea6a7bdd43a342b6c7d6f02ccb7a8c Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 16 Aug 2021 21:24:49 +0200 Subject: [PATCH] * use git describe to create a revision.inc if a .git dir is found --- compiler/Makefile | 12 ++++++++++++ compiler/Makefile.fpc | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/compiler/Makefile b/compiler/Makefile index 82411fa81d..159c9e7d47 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -558,6 +558,7 @@ endif NOCPUDEF=1 MSGFILE=msg/error$(FPCLANG).msg SVNVERSION:=$(firstword $(wildcard $(addsuffix /svnversion$(SRCEXEEXT),$(SEARCHPATH)))) +GIT:=$(firstword $(wildcard $(addsuffix /git$(SRCEXEEXT),$(SEARCHPATH)))) PPUDUMPPROG:=$(firstword $(strip $(wildcard $(addsuffix /ppudump$(SRCEXEEXT),$(SEARCHPATH))))) ifndef PPUDUMP ifdef PPUDUMPPROG @@ -570,6 +571,15 @@ REVINC:=$(wildcard revision.inc) ifneq ($(REVINC),) override LOCALOPT+=-dREVINC ifeq ($(REVSTR),) +ifneq ($(wildcard ../.git),) +ifneq ($(GIT),) +GITDESCRIBE=$(shell $(GIT) describe --dirty) +REVSTR:=$(word 2,$(subst -, ,$(GITDESCRIBE)))-$(word 3,$(subst -, ,$(GITDESCRIBE))) +ifneq ($(word 4,$(subst -, ,$(GITDESCRIBE))),) +REVSTR:=$(REVSTR)-$(word 4,$(subst -, ,$(GITDESCRIBE))) +endif +export REVSTR +else ifneq ($(SVNVERSION),) REVSTR:=$(subst r,,$(subst r1:,,r$(subst exported,,$(shell $(SVNVERSION) -c .)))) export REVSTR @@ -581,6 +591,8 @@ endif endif endif endif +endif +endif override LOCALOPT+=-d$(CPC_TARGET) -dGDB ifdef LLVM ifeq ($(findstring $(PPC_TARGET),x86_64 aarch64 arm),) diff --git a/compiler/Makefile.fpc b/compiler/Makefile.fpc index 319e2e6690..7eed422085 100644 --- a/compiler/Makefile.fpc +++ b/compiler/Makefile.fpc @@ -292,6 +292,7 @@ MSGFILE=msg/error$(FPCLANG).msg SVNVERSION:=$(firstword $(wildcard $(addsuffix /svnversion$(SRCEXEEXT),$(SEARCHPATH)))) +GIT:=$(firstword $(wildcard $(addsuffix /git$(SRCEXEEXT),$(SEARCHPATH)))) PPUDUMPPROG:=$(firstword $(strip $(wildcard $(addsuffix /ppudump$(SRCEXEEXT),$(SEARCHPATH))))) ifndef PPUDUMP ifdef PPUDUMPPROG @@ -310,6 +311,15 @@ override LOCALOPT+=-dREVINC # Automatically update revision.inc if # svnversion executable is available ifeq ($(REVSTR),) +ifneq ($(wildcard ../.git),) +ifneq ($(GIT),) +GITDESCRIBE=$(shell $(GIT) describe --dirty) +REVSTR:=$(word 2,$(subst -, ,$(GITDESCRIBE)))-$(word 3,$(subst -, ,$(GITDESCRIBE))) +ifneq ($(word 4,$(subst -, ,$(GITDESCRIBE))),) +REVSTR:=$(REVSTR)-$(word 4,$(subst -, ,$(GITDESCRIBE))) +endif +export REVSTR +else ifneq ($(SVNVERSION),) REVSTR:=$(subst r,,$(subst r1:,,r$(subst exported,,$(shell $(SVNVERSION) -c .)))) export REVSTR @@ -321,6 +331,8 @@ endif endif endif endif +endif +endif # set correct defines (-d$(CPU_TARGET) is automatically added in makefile.fpc) override LOCALOPT+=-d$(CPC_TARGET) -dGDB