aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Milanović <mmicko@gmail.com>2022-05-25 11:33:11 +0200
committerGitHub <noreply@github.com>2022-05-25 11:33:11 +0200
commit904e2efe11926c81ccce0f643a903f9a71474ecd (patch)
treefd5c7802d19695997fd40f05ff534c053ac1937e
parentcffec1f95f0ac4bad1deb24bf7f921bd93145a16 (diff)
parent222e7a2da345f01980d9261c40c5d50eced4f9ab (diff)
downloadyosys-904e2efe11926c81ccce0f643a903f9a71474ecd.tar.gz
yosys-904e2efe11926c81ccce0f643a903f9a71474ecd.tar.bz2
yosys-904e2efe11926c81ccce0f643a903f9a71474ecd.zip
Merge pull request #3138 from DanielG/fix-git-rev
Make GIT_REV logic work in release tarballs
-rw-r--r--.gitattributes1
-rw-r--r--.gitcommit1
-rw-r--r--Makefile11
3 files changed, 13 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
index f85ae06c9..5e568606e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
*.v linguist-language=Verilog
+/.gitcommit export-subst
diff --git a/.gitcommit b/.gitcommit
new file mode 100644
index 000000000..46b7856fb
--- /dev/null
+++ b/.gitcommit
@@ -0,0 +1 @@
+$Format:%h$
diff --git a/Makefile b/Makefile
index 34aeb9dc4..d081161be 100644
--- a/Makefile
+++ b/Makefile
@@ -130,7 +130,18 @@ LDLIBS += -lrt
endif
YOSYS_VER := 0.17+41
+
+# Note: We arrange for .gitcommit to contain the (short) commit hash in
+# tarballs generated with git-archive(1) using .gitattributes. The git repo
+# will have this file in its unexpanded form tough, in which case we fall
+# back to calling git directly.
+TARBALL_GIT_REV := $(shell cat $(YOSYS_SRC)/.gitcommit)
+ifeq ($(TARBALL_GIT_REV),$$Format:%h$$)
GIT_REV := $(shell git ls-remote $(YOSYS_SRC) HEAD -q | $(AWK) 'BEGIN {R = "UNKNOWN"}; ($$2 == "HEAD") {R = substr($$1, 1, 9); exit} END {print R}')
+else
+GIT_REV := $(TARBALL_GIT_REV)
+endif
+
OBJS = kernel/version_$(GIT_REV).o
bumpversion: