Skip to content

Commit

Permalink
Put the current git commit's short hash in generated programs.
Browse files Browse the repository at this point in the history
We previously put the SVN revision in generated programs.  Now that
the sources are in git, insert the current commit's short hash instead.

Note that I changed `configure.ac' so that we won't get warnings
about using `:=' assignments in Automake files.  I'm not crazy about
this change; better ways to get the current hash at build time would
be appreciated.
(cherry picked from commit 2365217)
  • Loading branch information
eeide committed May 20, 2011
1 parent 645afd1 commit 2ba0a0d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions configure
Expand Up @@ -1970,6 +1970,7 @@ test -n "$target_alias" &&
NONENONEs,x,x, &&
program_prefix=${target_alias}-
# `-Wno-portability': avoid warnings about using `:=' in `Makefile.am' files.
am__api_version='1.11'
# Find a good install program. We prefer a C program (faster),
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Expand Up @@ -38,7 +38,8 @@ dnl AM_CONFIG_HEADER(config.h)

AC_CANONICAL_TARGET

AM_INIT_AUTOMAKE
# `-Wno-portability': avoid warnings about using `:=' in `Makefile.am' files.
AM_INIT_AUTOMAKE([-Wall -Wno-portability])

# Avoid configure-time warnings about `--datarootdir' being ignored.
# This can perhaps be removed in a few years after Autoconf 2.60.
Expand Down
5 changes: 3 additions & 2 deletions runtime/Makefile.am
Expand Up @@ -39,7 +39,8 @@ lib_LIBRARIES = libcsmith.a
libcsmith_a_SOURCES = \
volatile_runtime.c

SVN_FLAG = -DSVN_VERSION=\"`svnversion -n .`\"
GIT_HASH := $(shell git show -s --format=%h . 2>/dev/null || echo exported)
GIT_FLAG = -DGIT_VERSION=\"$(GIT_HASH)\"

## ENE: The idea of stuffing the target CPU name (a string) into a CPP symbol
## is kind of awful. What we should do instead is use the name to modify the
Expand All @@ -48,7 +49,7 @@ SVN_FLAG = -DSVN_VERSION=\"`svnversion -n .`\"

libcsmith_a_CPPFLAGS = \
-DTARGET_CPU_$(target_cpu)=1 \
$(SVN_FLAG)
$(GIT_FLAG)

libcsmith_a_includedir = \
$(includedir)/$(PACKAGE)-$(VERSION)
Expand Down
5 changes: 3 additions & 2 deletions runtime/Makefile.in
Expand Up @@ -204,10 +204,11 @@ lib_LIBRARIES = libcsmith.a
libcsmith_a_SOURCES = \
volatile_runtime.c

SVN_FLAG = -DSVN_VERSION=\"`svnversion -n .`\"
GIT_HASH := $(shell git show -s --format=%h . 2>/dev/null || echo exported)
GIT_FLAG = -DGIT_VERSION=\"$(GIT_HASH)\"
libcsmith_a_CPPFLAGS = \
-DTARGET_CPU_$(target_cpu)=1 \
$(SVN_FLAG)
$(GIT_FLAG)

libcsmith_a_includedir = \
$(includedir)/$(PACKAGE)-$(VERSION)
Expand Down
5 changes: 3 additions & 2 deletions src/Makefile.am
Expand Up @@ -191,7 +191,8 @@ EXTRA_DIST = \
csmith.vcproj \
csmith.vcxproj

SVN_FLAG = -DSVN_VERSION=\"`svnversion -n .`\"
GIT_HASH := $(shell git show -s --format=%h . 2>/dev/null || echo exported)
GIT_FLAG = -DGIT_VERSION=\"$(GIT_HASH)\"

## ENE: The idea of stuffing the target CPU name (a string) into a CPP symbol
## is kind of awful. What we should do instead is use the name to modify the
Expand All @@ -200,7 +201,7 @@ SVN_FLAG = -DSVN_VERSION=\"`svnversion -n .`\"

csmith_CPPFLAGS = \
-DTARGET_CPU_$(target_cpu)=1 \
$(SVN_FLAG) \
$(GIT_FLAG) \
$(BOOST_CPPFLAGS)

csmith_LDFLAGS = $(BOOST_LDFLAGS)
Expand Down
5 changes: 3 additions & 2 deletions src/Makefile.in
Expand Up @@ -384,10 +384,11 @@ EXTRA_DIST = \
csmith.vcproj \
csmith.vcxproj

SVN_FLAG = -DSVN_VERSION=\"`svnversion -n .`\"
GIT_HASH := $(shell git show -s --format=%h . 2>/dev/null || echo exported)
GIT_FLAG = -DGIT_VERSION=\"$(GIT_HASH)\"
csmith_CPPFLAGS = \
-DTARGET_CPU_$(target_cpu)=1 \
$(SVN_FLAG) \
$(GIT_FLAG) \
$(BOOST_CPPFLAGS)

csmith_LDFLAGS = $(BOOST_LDFLAGS)
Expand Down
6 changes: 3 additions & 3 deletions src/OutputMgr.cpp
Expand Up @@ -362,9 +362,9 @@ OutputMgr::OutputHeader(int argc, char *argv[], unsigned long seed)
out << " * This is a RANDOMLY GENERATED PROGRAM." << endl;
out << " *" << endl;
out << " * Generator: " << PACKAGE_STRING << endl;
#ifdef SVN_VERSION
out << " * svn version: " << SVN_VERSION << endl;
#endif
#ifdef GIT_VERSION
out << " * Git version: " << GIT_VERSION << endl;
#endif
out << " * Options: ";
if (argc <= 1) {
out << " (none)";
Expand Down
5 changes: 2 additions & 3 deletions src/RandomProgramGenerator.cpp
Expand Up @@ -107,10 +107,9 @@ static void
print_version(void)
{
cout << PACKAGE_STRING << endl;
#ifdef SVN_VERSION
cout << "svn version: " << SVN_VERSION << endl;
#ifdef GIT_VERSION
cout << "Git version: " << GIT_VERSION << endl;
#endif
// XXX print svn rev!
// XXX print copyright, contact info, etc.?
}

Expand Down

0 comments on commit 2ba0a0d

Please sign in to comment.