From cacd371bee57f00fd9eddac70570401495a7157f Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Sun, 25 Oct 2009 10:14:30 -0700 Subject: makefile: allow build.h to be generated based on git-merge-base Signed-off-by: Steven Noonan --- crawl-ref/source/makefile | 6 +++++- crawl-ref/source/util/gen_ver.pl | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/makefile b/crawl-ref/source/makefile index 1b36d16eb4..da620bbf7c 100644 --- a/crawl-ref/source/makefile +++ b/crawl-ref/source/makefile @@ -142,6 +142,10 @@ ifdef NEED_STATIC LDFLAGS += -static endif +ifdef USE_MERGE_BASE +MERGE_BASE := $(shell git merge-base HEAD $(USE_MERGE_BASE)) +endif + # Permissions to set on the game executable. MCHMOD := 2755 @@ -605,7 +609,7 @@ compflag.h: $(QUIET_GEN)util/gen-cflg.pl compflag.h "$(CFLAGS)" "$(CFLAGS_L)" "$(LDFLAGS)" build.h: - $(QUIET_GEN)util/gen_ver.pl $@ + $(QUIET_GEN)util/gen_ver.pl $@ $(MERGE_BASE) version.cc: build.h compflag.h diff --git a/crawl-ref/source/util/gen_ver.pl b/crawl-ref/source/util/gen_ver.pl index a82486380f..4902be79a9 100755 --- a/crawl-ref/source/util/gen_ver.pl +++ b/crawl-ref/source/util/gen_ver.pl @@ -11,6 +11,11 @@ my $cwd = cwd; my $in_git = 1; my $scriptpath = dirname($0); my $outfile = $ARGV[0]; +my $mergebase = $ARGV[1]; + +if (!$mergebase) { + $mergebase = ""; +} my $releasever; @@ -22,7 +27,7 @@ mkdir dirname($outfile); my $verstring = ""; -$verstring = `git describe --tags --long 2> /dev/null || git describe --tags 2> /dev/null`; +$verstring = `git describe --tags --long $mergebase 2> /dev/null || git describe --tags $mergebase 2> /dev/null`; if (!$verstring) { print STDERR "WARNING: Couldn't get revision information from Git. Using $scriptpath/release_ver.\n"; @@ -80,7 +85,7 @@ if ( !$build ) { # Old versions of git omit the commits-since-tag number, # so we can try 'git rev-list' to get this instead. if ( $commit == 0 && $in_git ) { - $commit = `git rev-list $tag.. | wc -l` + $commit = `git rev-list $tag..$mergebase | wc -l` } if ( $commit == 0 ) { -- cgit v1.2.3-54-g00ecf