From 2a06c72113fb4a7032621387751d5c9c945936ae Mon Sep 17 00:00:00 2001 From: "David Adam (zanchey)" Date: Mon, 24 Jun 2013 18:12:09 +0800 Subject: [PATCH] Generate version numbers dynamically This commit hooks the Makefile up to generate a FISH_BUILD_VERSION symbol and kills off PACKAGE_VERSION in .cpp files. It also modifies the tarball generation script to add the necessary version file for releases. --- Makefile.in | 16 ++++++++++++++-- build_tools/make_tarball.sh | 7 ++++++- env.cpp | 2 +- fish.cpp | 2 +- fish_indent.cpp | 2 +- fish_pager.cpp | 2 +- fishd.cpp | 2 +- mimedb.cpp | 2 +- 8 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 9db4aa47d..7cbd159d3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -282,6 +282,17 @@ all: $(PROGRAMS) $(user_doc) share/man $(TRANSLATIONS) @echo Use \'$(MAKE) install\' to install fish. .PHONY: all +# +# Pull version information +# + +FISH-BUILD-VERSION-FILE: FORCE + @./build_tools/git_version_gen.sh +-include FISH-BUILD-VERSION-FILE +CPPFLAGS += -DFISH_BUILD_VERSION=\"$(FISH_BUILD_VERSION)\" +.PHONY: FORCE +env.o fish.o fish_indent.o fish_pager.o fishd.o mimedb.o: FISH-BUILD-VERSION-FILE + # # These dependencies make sure that autoconf and configure are run @@ -313,7 +324,7 @@ prof: all # intermediate *.hdr and doc.h files if needed user_doc: $(HDR_FILES_SRC) Doxyfile.user user_doc.head.html $(HELP_SRC) doc.h $(HDR_FILES) - (cat Doxyfile.user ; echo PROJECT_NUMBER=@PACKAGE_VERSION@) | doxygen - && touch user_doc + (cat Doxyfile.user ; echo PROJECT_NUMBER=$(FISH_BUILD_VERSION)) | doxygen - && touch user_doc # @@ -321,7 +332,7 @@ user_doc: $(HDR_FILES_SRC) Doxyfile.user user_doc.head.html $(HELP_SRC) doc.h $( # doc: *.h *.cpp doc.h Doxyfile - (cat Doxyfile ; echo PROJECT_NUMBER=@PACKAGE_VERSION@) | doxygen - ; + (cat Doxyfile ; echo PROJECT_NUMBER=$(FISH_BUILD_VERSION)) | doxygen - ; # @@ -849,6 +860,7 @@ clean: rm -f $(PROGRAMS) fish_tests key_reader rm -f command_list.txt toc.txt rm -f doc_src/index.hdr doc_src/commands.hdr + rm -f FISH-BUILD-VERSION-FILE rm -f fish-@PACKAGE_VERSION@.tar rm -f fish-@PACKAGE_VERSION@.tar.gz rm -f fish-@PACKAGE_VERSION@.tar.bz2 diff --git a/build_tools/make_tarball.sh b/build_tools/make_tarball.sh index b74fc9c4e..183ea2a14 100755 --- a/build_tools/make_tarball.sh +++ b/build_tools/make_tarball.sh @@ -19,8 +19,11 @@ wd="$PWD" # The name of the prefix, which is the directory that you get when you untar prefix="fish" +# Get the version from git-describe +VERSION=`git describe --tags --dirty 2>/dev/null` + # The path where we will output the tar file -path=~/fish_built/fish-2.0.tar +path=~/fish_built/fish-$VERSION.tar # Clean up stuff we've written before rm -f "$path" "$path".gz @@ -31,11 +34,13 @@ git archive --format=tar --prefix="$prefix"/ master > "$path" # tarball out the documentation make user_doc make share/man +echo $VERSION > version cd /tmp rm -f "$prefix" ln -s "$wd" "$prefix" gnutar --append --file="$path" "$prefix"/user_doc/html gnutar --append --file="$path" "$prefix"/share/man +gnutar --append --file="$path" "$prefix"/version rm -f "$prefix" # gzip it diff --git a/env.cpp b/env.cpp index ddb5d2c4e..a99f18121 100644 --- a/env.cpp +++ b/env.cpp @@ -667,7 +667,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */) /* Set up the version variables */ - wcstring version = str2wcstring(PACKAGE_VERSION); + wcstring version = str2wcstring(FISH_BUILD_VERSION); env_set(L"version", version.c_str(), ENV_GLOBAL); env_set(L"FISH_VERSION", version.c_str(), ENV_GLOBAL); diff --git a/fish.cpp b/fish.cpp index 8001f3764..fda24360c 100644 --- a/fish.cpp +++ b/fish.cpp @@ -350,7 +350,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector *out_c fwprintf(stderr, _(L"%s, version %s\n"), PACKAGE_NAME, - PACKAGE_VERSION); + FISH_BUILD_VERSION); exit_without_destructors(0); } diff --git a/fish_indent.cpp b/fish_indent.cpp index db48679b4..3b54d008d 100644 --- a/fish_indent.cpp +++ b/fish_indent.cpp @@ -344,7 +344,7 @@ int main(int argc, char **argv) fwprintf(stderr, _(L"%ls, version %s\n"), program_name, - PACKAGE_VERSION); + FISH_BUILD_VERSION); exit(0); } diff --git a/fish_pager.cpp b/fish_pager.cpp index 2e1a4bbaa..848eb0fc0 100644 --- a/fish_pager.cpp +++ b/fish_pager.cpp @@ -1289,7 +1289,7 @@ int main(int argc, char **argv) case 'v': { - debug(0, L"%ls, version %s\n", program_name, PACKAGE_VERSION); + debug(0, L"%ls, version %s\n", program_name, FISH_BUILD_VERSION); exit(0); } diff --git a/fishd.cpp b/fishd.cpp index 638e17622..e5edc3da5 100644 --- a/fishd.cpp +++ b/fishd.cpp @@ -922,7 +922,7 @@ int main(int argc, char ** argv) exit(0); case 'v': - debug(0, L"%ls, version %s\n", program_name, PACKAGE_VERSION); + debug(0, L"%ls, version %s\n", program_name, FISH_BUILD_VERSION); exit(0); case '?': diff --git a/mimedb.cpp b/mimedb.cpp index 9b66bb0a2..fdf5da12d 100644 --- a/mimedb.cpp +++ b/mimedb.cpp @@ -1332,7 +1332,7 @@ int main(int argc, char *argv[]) exit(0); case 'v': - printf(_("%s, version %s\n"), MIMEDB, PACKAGE_VERSION); + printf(_("%s, version %s\n"), MIMEDB, FISH_BUILD_VERSION); exit(0); case '?':