summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-07-12 18:23:01 -0700
committerJulian Blake Kongslie2022-07-12 18:23:01 -0700
commitd876f6f12b7719a5f477a6ccabb943a32be05755 (patch)
tree3b1a00ae3fc4ef6e5922a4b6d1cddb6ed20cf737
parentStack storage for uarch stages. (diff)
downloadissim-main.tar.xz
Include diff and diffstat from git.HEADmain
Diffstat (limited to '')
-rw-r--r--Makefile17
-rw-r--r--git-tag.h2
-rw-r--r--main.cpp4
-rwxr-xr-xtools/mkgit.rb28
4 files changed, 35 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 6a9baab..cb8b824 100644
--- a/Makefile
+++ b/Makefile
@@ -14,19 +14,6 @@ CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${PKG_FLAGS} ${OPTIMIZE} ${
14 14
15.DEFAULT_GOAL := all 15.DEFAULT_GOAL := all
16 16
17VERSION := $(shell git describe --always --dirty --long --tags 2> /dev/null)
18ifndef VERSION
19VERSION := unknown
20endif
21$(info Version ${VERSION})
22
23define GITTAGCPP =
24#include "git-tag.h"
25
26const char *GIT_TAG = "$(subst ",\",${VERSION})";
27endef
28export GITTAGCPP
29
30ifneq ($(shell which ${IWYU}),) 17ifneq ($(shell which ${IWYU}),)
31iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error -Xiwyu --mapping_file=tools/iwyu.imp -Xiwyu --no_fwd_decls ${CXXFLAGS} $(1) 18iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error -Xiwyu --mapping_file=tools/iwyu.imp -Xiwyu --no_fwd_decls ${CXXFLAGS} $(1)
32else 19else
@@ -97,8 +84,6 @@ endif
97MAINOBJS := $(patsubst %.cpp,build/%.o,$(wildcard *.cpp)) 84MAINOBJS := $(patsubst %.cpp,build/%.o,$(wildcard *.cpp))
98MAINOBJS += build/git-tag.o 85MAINOBJS += build/git-tag.o
99 86
100$(info )
101
102all: ${IWYU_CPPS} issim issim-static 87all: ${IWYU_CPPS} issim issim-static
103 88
104issim: build/issim-dynamic 89issim: build/issim-dynamic
@@ -123,7 +108,7 @@ clean:
123 108
124build/git-tag.cpp: 109build/git-tag.cpp:
125 @mkdir -p $(dir $@) 110 @mkdir -p $(dir $@)
126 @echo "$$GITTAGCPP" > $@ 111 @tools/mkgit.rb > $@
127.PHONY: build/git-tag.cpp 112.PHONY: build/git-tag.cpp
128 113
129build/%.o: %.cpp 114build/%.o: %.cpp
diff --git a/git-tag.h b/git-tag.h
index 0f36b73..0e742a5 100644
--- a/git-tag.h
+++ b/git-tag.h
@@ -1,3 +1,5 @@
1#pragma once 1#pragma once
2 2
3extern const char *GIT_TAG; 3extern const char *GIT_TAG;
4extern const char *GIT_DIFF;
5extern const char *GIT_STAT;
diff --git a/main.cpp b/main.cpp
index 7142eed..ffc6cad 100644
--- a/main.cpp
+++ b/main.cpp
@@ -13,6 +13,10 @@
13int main(int argc, const char *argv[]) 13int main(int argc, const char *argv[])
14{ 14{
15 std::cout << "Version " << GIT_TAG << "\n"; 15 std::cout << "Version " << GIT_TAG << "\n";
16 if (GIT_STAT)
17 std::cout << GIT_STAT << "\n";
18 if (GIT_DIFF)
19 std::cout << GIT_DIFF << "\n";
16 20
17 fib::Fib<3> fib; 21 fib::Fib<3> fib;
18 22
diff --git a/tools/mkgit.rb b/tools/mkgit.rb
new file mode 100755
index 0000000..2a6ef4c
--- /dev/null
+++ b/tools/mkgit.rb
@@ -0,0 +1,28 @@
1#!/usr/bin/ruby -w
2
3$stdout.write(<<END)
4#include "git-tag.h"
5
6END
7
8IO.popen(["git", "describe", "--always", "--dirty", "--long", "--tags"], "r") do | io |
9 $stdout.write("const char *GIT_TAG = #{io.read.strip.dump};\n")
10end
11
12IO.popen(["git", "diff"]) do | io |
13 diff = io.read
14 if diff.strip == ""
15 $stdout.write("const char *GIT_DIFF = nullptr;\n")
16 else
17 $stdout.write("const char *GIT_DIFF = #{diff.dump};\n")
18 end
19end
20
21IO.popen(["git", "diff", "--stat"]) do | io |
22 stat = io.read
23 if stat.strip == ""
24 $stdout.write("const char *GIT_STAT = nullptr;\n")
25 else
26 $stdout.write("const char *GIT_STAT = #{stat.dump};\n")
27 end
28end