Permalink
Browse files

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.
  • Loading branch information...
1 parent 05563ab commit 2a06c72113fb4a7032621387751d5c9c945936ae @zanchey zanchey committed Jun 24, 2013
Showing with 26 additions and 9 deletions.
  1. +14 −2 Makefile.in
  2. +6 −1 build_tools/make_tarball.sh
  3. +1 −1 env.cpp
  4. +1 −1 fish.cpp
  5. +1 −1 fish_indent.cpp
  6. +1 −1 fish_pager.cpp
  7. +1 −1 fishd.cpp
  8. +1 −1 mimedb.cpp
View
@@ -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,15 +324,15 @@ 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
#
# Source code documentation. Also includes user documentation.
#
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
@@ -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
View
@@ -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);
View
@@ -350,7 +350,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *out_c
fwprintf(stderr,
_(L"%s, version %s\n"),
PACKAGE_NAME,
- PACKAGE_VERSION);
+ FISH_BUILD_VERSION);
exit_without_destructors(0);
}
View
@@ -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);
}
View
@@ -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);
}
View
@@ -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 '?':
View
@@ -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 '?':

0 comments on commit 2a06c72

Please sign in to comment.