From 1b261b1ba750bc9a2c3b865ed3c046981dc02513 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 9 Jan 2017 23:23:05 -0500 Subject: [PATCH] build: move BEES_VERSION to a separate C file to avoid unnecessary building Every git commit was causing bees.cc and bees-hash.cc to be rebuilt, which was expensive and unnecessary. Signed-off-by: Zygo Blaxell --- src/.gitignore | 2 +- src/Makefile | 8 +++++--- src/bees-hash.cc | 1 - src/bees.cc | 1 - src/bees.h | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index dfe700b..4cb8e66 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1 +1 @@ -bees-version.h +bees-version.[ch] diff --git a/src/Makefile b/src/Makefile index 4f7cb20..b1290c8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,8 +11,8 @@ LIBS = -lcrucible -lpthread LDFLAGS = -L../lib -Wl,-rpath=$(shell realpath ../lib) depends.mk: Makefile *.cc - echo "#define BEES_VERSION \"$(shell git describe --always --dirty || echo UNKNOWN)\"" > bees-version.new.h - mv -f bees-version.new.h bees-version.h + echo "const char *BEES_VERSION = \"$(shell git describe --always --dirty || echo UNKNOWN)\";" > bees-version.new.c + mv -f bees-version.new.c bees-version.c for x in *.cc; do $(CXX) $(CXXFLAGS) -M "$$x"; done > depends.mk.new mv -fv depends.mk.new depends.mk @@ -33,9 +33,11 @@ BEES_OBJS = \ bees-roots.o \ bees-thread.o \ bees-types.o \ + bees-version.o \ ../bin/bees: $(BEES_OBJS) $(CXX) $(CXXFLAGS) -o "$@" $(BEES_OBJS) $(LDFLAGS) $(LIBS) clean: - -rm -fv *.o bees-version.h + -rm -fv bees-version.h + -rm -fv *.o bees-version.c diff --git a/src/bees-hash.cc b/src/bees-hash.cc index e41fa3b..ec1f35b 100644 --- a/src/bees-hash.cc +++ b/src/bees-hash.cc @@ -1,4 +1,3 @@ -#include "bees-version.h" #include "bees.h" #include "crucible/crc64.h" diff --git a/src/bees.cc b/src/bees.cc index 9213f5b..519a3ac 100644 --- a/src/bees.cc +++ b/src/bees.cc @@ -1,4 +1,3 @@ -#include "bees-version.h" #include "bees.h" #include "crucible/limits.h" diff --git a/src/bees.h b/src/bees.h index d685634..506f10d 100644 --- a/src/bees.h +++ b/src/bees.h @@ -819,6 +819,7 @@ public: }; // And now, a giant pile of extern declarations +extern const char *BEES_VERSION; string pretty(double d); extern RateLimiter bees_info_rate_limit; void bees_sync(int fd);