Skip to content

Commit

Permalink
Generate version numbers dynamically
Browse files Browse the repository at this point in the history
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
zanchey committed Aug 11, 2013
1 parent 05563ab commit 2a06c72
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 9 deletions.
16 changes: 14 additions & 2 deletions Makefile.in
Expand Up @@ -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
Expand Down Expand Up @@ -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 - ;


#
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion build_tools/make_tarball.sh
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion env.cpp
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion fish.cpp
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion fish_indent.cpp
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion fish_pager.cpp
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion fishd.cpp
Expand Up @@ -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 '?':
Expand Down
2 changes: 1 addition & 1 deletion mimedb.cpp
Expand Up @@ -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 '?':
Expand Down

0 comments on commit 2a06c72

Please sign in to comment.