# as a C library, which messes up exception handling support)
nodist_EXTRA_libcvc4_noinst_la_SOURCES = dummy.cpp
nodist_EXTRA_libcvc4_la_SOURCES = dummy.cpp
-libcvc4_noinst_la_SOURCES = subversion_versioninfo.cpp
-libcvc4_la_SOURCES = subversion_versioninfo.cpp
+libcvc4_noinst_la_SOURCES = git_versioninfo.cpp svn_versioninfo.cpp
+libcvc4_la_SOURCES = git_versioninfo.cpp svn_versioninfo.cpp
libcvc4_la_LIBADD = \
@builddir@/options/liboptions.la \
@builddir@/util/libutil.la \
endif
CLEANFILES = \
- subversion_versioninfo.cpp \
+ svn_versioninfo.cpp \
svninfo.tmp \
- svninfo
+ svninfo \
+ git_versioninfo.cpp \
+ gitinfo.tmp \
+ gitinfo
EXTRA_DIST = \
include/cvc4_private_library.h \
include/cvc4.h \
cvc4.i
-subversion_versioninfo.cpp: svninfo
+svn_versioninfo.cpp: svninfo
$(AM_V_GEN)( \
if test -s svninfo; then \
issvn=true; \
svninfo.tmp:
$(AM_V_GEN)(cd "$(top_srcdir)" && svn info && echo "Modifications: `test -z \"\`svn status -q\`\" && echo false || echo true`") >"$@" 2>/dev/null || true
+git_versioninfo.cpp: gitinfo
+ $(AM_V_GEN)( \
+ if test -s gitinfo; then \
+ isgit=true; \
+ branch=`head -1 gitinfo`; \
+ rev=`head -2 gitinfo | tail -1 | awk '{print$$1}'`; \
+ mods=`grep '^Modifications: ' gitinfo | awk '{print$$2}'`; \
+ else \
+ isgit=false; \
+ branch=unknown; \
+ rev=0; \
+ mods=false; \
+ fi; \
+ echo "#include \"util/configuration.h\""; \
+ echo "const bool ::CVC4::Configuration::IS_GIT_BUILD = $$isgit;"; \
+ echo "const char* const ::CVC4::Configuration::GIT_BRANCH_NAME = \"$$branch\";"; \
+ echo "const char* const ::CVC4::Configuration::GIT_COMMIT = \"$$rev\";"; \
+ echo "const bool ::CVC4::Configuration::GIT_HAS_MODIFICATIONS = $$mods;"; \
+ ) >"$@"
+# This .tmp business is to keep from having to re-compile options.cpp
+# (and then re-link the libraries) if nothing has changed.
+gitinfo: gitinfo.tmp
+ $(AM_V_GEN)diff -q gitinfo.tmp gitinfo &>/dev/null || mv gitinfo.tmp gitinfo || true
+# .PHONY ensures the .tmp version is always rebuilt (to check for any changes)
+.PHONY: gitinfo.tmp
+gitinfo.tmp:
+ $(AM_V_GEN)(cd "$(top_srcdir)" && sed 's,^ref: refs/heads/,,' .git/HEAD && git show-ref refs/heads/`sed 's,^ref: refs/heads/,,' .git/HEAD` && echo "Modifications: `test -z \"\`git status -s -uno\`\" && echo false || echo true`") >"$@" 2>/dev/null || true
+
install-data-local:
(echo include/cvc4.h; \
echo include/cvc4_public.h; \
InteractiveShell shell(*exprMgr, opts);
Message() << Configuration::getPackageName()
<< " " << Configuration::getVersionString();
- if(Configuration::isSubversionBuild()) {
+ if(Configuration::isGitBuild()) {
+ Message() << " [" << Configuration::getGitId() << "]";
+ } else if(Configuration::isSubversionBuild()) {
Message() << " [" << Configuration::getSubversionId() << "]";
}
Message() << (Configuration::isDebugBuild() ? " DEBUG" : "")
fputs(Configuration::about().c_str(), stdout);
printf("\n");
printf("version : %s\n", Configuration::getVersionString().c_str());
- if(Configuration::isSubversionBuild()) {
- printf("subversion : yes [%s r%u%s]\n",
+ if(Configuration::isGitBuild()) {
+ printf("scm : git [%s %s%s]\n",
+ Configuration::getGitBranchName(),
+ std::string(Configuration::getGitCommit()).substr(0, 8).c_str(),
+ Configuration::hasGitModifications() ?
+ " (with modifications)" : "");
+ } else if(Configuration::isSubversionBuild()) {
+ printf("scm : svn [%s r%u%s]\n",
Configuration::getSubversionBranchName(),
Configuration::getSubversionRevision(),
Configuration::hasSubversionModifications() ?
" (with modifications)" : "");
} else {
- printf("subversion : %s\n", Configuration::isSubversionBuild() ? "yes" : "no");
+ printf("scm : no\n");
}
printf("\n");
printf("library : %u.%u.%u\n",
return false;
}
+bool Configuration::isGitBuild() {
+ return IS_GIT_BUILD;
+}
+
+const char* Configuration::getGitBranchName() {
+ return GIT_BRANCH_NAME;
+}
+
+const char* Configuration::getGitCommit() {
+ return GIT_COMMIT;
+}
+
+bool Configuration::hasGitModifications() {
+ return GIT_HAS_MODIFICATIONS;
+}
+
+std::string Configuration::getGitId() {
+ if(! isGitBuild()) {
+ return "";
+ }
+
+ stringstream ss;
+ ss << "git " << getGitBranchName() << " " << string(getGitCommit()).substr(0, 8)
+ << ( ::CVC4::Configuration::hasGitModifications() ? " (with modifications)" : "" );
+ return ss.str();
+}
+
bool Configuration::isSubversionBuild() {
return IS_SUBVERSION_BUILD;
}
return SUBVERSION_HAS_MODIFICATIONS;
}
-string Configuration::getSubversionId() {
+std::string Configuration::getSubversionId() {
if(! isSubversionBuild()) {
return "";
}
static const char* const SUBVERSION_BRANCH_NAME;
static const unsigned SUBVERSION_REVISION;
static const bool SUBVERSION_HAS_MODIFICATIONS;
+ static const bool IS_GIT_BUILD;
+ static const char* const GIT_BRANCH_NAME;
+ static const char* const GIT_COMMIT;
+ static const bool GIT_HAS_MODIFICATIONS;
public:
/* Test if the given argument is a known trace tag name */
static bool isTraceTag(char const *);
+ static bool isGitBuild();
+ static const char* getGitBranchName();
+ static const char* getGitCommit();
+ static bool hasGitModifications();
+ static std::string getGitId();
+
static bool isSubversionBuild();
static const char* getSubversionBranchName();
static unsigned getSubversionRevision();
#define CVC4_ABOUT_STRING ( ::std::string("\
This is CVC4 version " CVC4_RELEASE_STRING ) + \
+ ( ::CVC4::Configuration::isGitBuild() \
+ ? ( ::std::string(" [") + ::CVC4::Configuration::getGitId() + "]" ) \
+ : \
( ::CVC4::Configuration::isSubversionBuild() \
? ( ::std::string(" [") + ::CVC4::Configuration::getSubversionId() + "]" ) \
: ::std::string("") \
- ) + "\n\
+ )) + "\n\
compiled with " + ::CVC4::Configuration::getCompiler() + "\n\
on " + ::CVC4::Configuration::getCompiledDateTime() + "\n\n\
Copyright (C) 2009, 2010, 2011, 2012\n\