diff options
| author | Julian Blake Kongslie | 2022-07-12 18:23:01 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-07-12 18:23:01 -0700 |
| commit | d876f6f12b7719a5f477a6ccabb943a32be05755 (patch) | |
| tree | 3b1a00ae3fc4ef6e5922a4b6d1cddb6ed20cf737 | |
| parent | Stack storage for uarch stages. (diff) | |
| download | issim-main.tar.xz | |
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 17 | ||||
| -rw-r--r-- | git-tag.h | 2 | ||||
| -rw-r--r-- | main.cpp | 4 | ||||
| -rwxr-xr-x | tools/mkgit.rb | 28 |
4 files changed, 35 insertions, 16 deletions
| @@ -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 | ||
| 17 | VERSION := $(shell git describe --always --dirty --long --tags 2> /dev/null) | ||
| 18 | ifndef VERSION | ||
| 19 | VERSION := unknown | ||
| 20 | endif | ||
| 21 | $(info Version ${VERSION}) | ||
| 22 | |||
| 23 | define GITTAGCPP = | ||
| 24 | #include "git-tag.h" | ||
| 25 | |||
| 26 | const char *GIT_TAG = "$(subst ",\",${VERSION})"; | ||
| 27 | endef | ||
| 28 | export GITTAGCPP | ||
| 29 | |||
| 30 | ifneq ($(shell which ${IWYU}),) | 17 | ifneq ($(shell which ${IWYU}),) |
| 31 | iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error -Xiwyu --mapping_file=tools/iwyu.imp -Xiwyu --no_fwd_decls ${CXXFLAGS} $(1) | 18 | iwyu = ${CHRONIC} ${IWYU} -Xiwyu --error -Xiwyu --mapping_file=tools/iwyu.imp -Xiwyu --no_fwd_decls ${CXXFLAGS} $(1) |
| 32 | else | 19 | else |
| @@ -97,8 +84,6 @@ endif | |||
| 97 | MAINOBJS := $(patsubst %.cpp,build/%.o,$(wildcard *.cpp)) | 84 | MAINOBJS := $(patsubst %.cpp,build/%.o,$(wildcard *.cpp)) |
| 98 | MAINOBJS += build/git-tag.o | 85 | MAINOBJS += build/git-tag.o |
| 99 | 86 | ||
| 100 | $(info ) | ||
| 101 | |||
| 102 | all: ${IWYU_CPPS} issim issim-static | 87 | all: ${IWYU_CPPS} issim issim-static |
| 103 | 88 | ||
| 104 | issim: build/issim-dynamic | 89 | issim: build/issim-dynamic |
| @@ -123,7 +108,7 @@ clean: | |||
| 123 | 108 | ||
| 124 | build/git-tag.cpp: | 109 | build/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 | ||
| 129 | build/%.o: %.cpp | 114 | build/%.o: %.cpp |
| @@ -1,3 +1,5 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | extern const char *GIT_TAG; | 3 | extern const char *GIT_TAG; |
| 4 | extern const char *GIT_DIFF; | ||
| 5 | extern const char *GIT_STAT; | ||
| @@ -13,6 +13,10 @@ | |||
| 13 | int main(int argc, const char *argv[]) | 13 | int 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 | |||
| 6 | END | ||
| 7 | |||
| 8 | IO.popen(["git", "describe", "--always", "--dirty", "--long", "--tags"], "r") do | io | | ||
| 9 | $stdout.write("const char *GIT_TAG = #{io.read.strip.dump};\n") | ||
| 10 | end | ||
| 11 | |||
| 12 | IO.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 | ||
| 19 | end | ||
| 20 | |||
| 21 | IO.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 | ||
| 28 | end | ||
