fix version generation

This commit is contained in:
Antonio SJ Musumeci 2018-03-09 20:48:36 -05:00
parent 6418b00ac3
commit 9830e29945
4 changed files with 24 additions and 21 deletions

View File

@ -84,7 +84,7 @@ help:
@echo "usage: make"
@echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
$(TARGET): src/version.hpp obj/obj-stamp libfuse/lib/.libs/libfuse.a $(OBJ)
$(TARGET): version obj/obj-stamp libfuse/lib/.libs/libfuse.a $(OBJ)
cd libfuse && make
$(CXX) $(CFLAGS) $(OBJ) -o $@ libfuse/lib/.libs/libfuse.a -ldl $(LDFLAGS)
@ -102,15 +102,7 @@ ifeq ($(GIT_REPO),1)
endif
version:
ifeq ($(GIT_REPO),1)
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
@echo "$(VERSION)" > VERSION
endif
src/version.hpp: version
$(eval VERSION := $(shell cat VERSION))
@echo "#pragma once" > src/version.hpp
@echo "static const char MERGERFS_VERSION[] = \"$(VERSION)\";" >> src/version.hpp
tools/update-version
obj/obj-stamp:
$(MKDIR) -p obj
@ -229,6 +221,6 @@ endif
libfuse/lib/.libs/libfuse.a: libfuse_Makefile
cd libfuse && $(MAKE)
.PHONY: all clean install help
.PHONY: all clean install help version
-include $(DEPS)

View File

@ -148,6 +148,8 @@ void
_getxattr_controlfile_version(string &attrvalue)
{
attrvalue = MERGERFS_VERSION;
if(attrvalue.empty())
attrvalue = "unknown_possible_problem_with_build";
}
static

View File

@ -305,15 +305,6 @@ usage(void)
<< std::endl;
}
static
void
version(void)
{
std::cout << "mergerfs version: "
<< MERGERFS_VERSION
<< std::endl;
}
static
int
option_processor(void *data,
@ -344,7 +335,9 @@ option_processor(void *data,
break;
case MERGERFS_OPT_VERSION:
version();
std::cout << "mergerfs version: "
<< (MERGERFS_VERSION[0] ? MERGERFS_VERSION : "unknown")
<< std::endl;
fuse_opt_add_arg(outargs,"--version");
break;

16
tools/update-version Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
GIT=$(which git)
if [ "${GIT}" = "" ]; then
exit 0
fi
VERSION=$(git describe --always --tags --dirty)
echo -n "${VERSION}" > VERSION
grep -q \"${VERSION}\" src/version.hpp
RV=$?
if [ $RV -ne 0 ]; then
echo "#pragma once" > src/version.hpp
echo "static const char MERGERFS_VERSION[] = \"${VERSION}\";" >> src/version.hpp
fi