include svn revision in version properties

This commit is contained in:
Doug MacEachern 2008-08-10 18:59:53 +00:00
parent 6e94034741
commit 34333d64e8
7 changed files with 58 additions and 4 deletions

View File

@ -111,11 +111,12 @@
<echo>cp ${version.file.srcdir}/${version.file}.in -> ${version.tofile}</echo>
<copy file="${version.file.srcdir}/${version.file}.in"
tofile="${version.tofile}"/>
tofile="${version.tofile}" overwrite="true"/>
<replace file="${version.tofile}">
<replacefilter token="@@BUILD_DATE@@" value="${BUILD_DATE}"/>
<replacefilter token="@@VERSION_STRING@@" value="${sigar.version}"/>
<replacefilter token="@@SCM_REVISION@@" value="${sigar.scmrev}"/>
<replacefilter token="@@ARCHNAME@@" value="${jni.libarch}"/>
<replacefilter token="@@ARCHLIB@@" value="${jni.libname.full}"/>
<replacefilter token="@@BINNAME@@" value="${jni.project.archname}"/>
@ -127,11 +128,36 @@
</replace>
</target>
<target name="sigar-version">
<target name="check-svn">
<condition property="svn.available">
<and>
<available file=".svn" type="dir"/>
<available file="svn" type="file">
<filepath>
<pathelement path="${env.PATH}"/>
</filepath>
</available>
</and>
</condition>
</target>
<target name="scm-revision" if="svn.available">
<exec executable="svnversion" dir="."
outputproperty="sigar.scmrev"
failifexecutionfails="false">
<arg value="."/>
</exec>
<echo message="SIGAR svn revision #${sigar.scmrev}"/>
</target>
<target name="sigar-version" depends="check-svn,scm-revision">
<tstamp>
<format property="BUILD_DATE" pattern="MM/dd/yyyy hh:mm aa"/>
</tstamp>
<!-- in the case of release source builds -->
<property name="sigar.scmrev" value="exported"/>
<antcall target="version-file">
<param name="version.file"
value="src/org/hyperic/sigar/SigarVersion.java"/>

View File

@ -276,6 +276,13 @@ JNIEXPORT jstring SIGAR_JNIx(getNativeBuildDate)
return JENV->NewStringUTF(env, version->build_date);
}
JNIEXPORT jstring SIGAR_JNIx(getNativeScmRevision)
(JNIEnv *env, jclass cls)
{
sigar_version_t *version = sigar_version_get();
return JENV->NewStringUTF(env, version->scm_revision);
}
JNIEXPORT void SIGAR_JNIx(open)
(JNIEnv *env, jobject obj)
{

View File

@ -55,6 +55,17 @@ public class Sigar implements SigarProxy {
*/
public static final String NATIVE_VERSION_STRING;
/**
* The scm (svn) revision from which sigar.jar was built.
*/
public static final String SCM_REVISION =
SigarVersion.SCM_REVISION;
/**
* The scm (svn) revision from which the sigar native binary was built.
*/
public static final String NATIVE_SCM_REVISION;
/**
* The date on which sigar.jar was built.
*/
@ -85,11 +96,13 @@ public class Sigar implements SigarProxy {
static {
String nativeVersion = "unknown";
String nativeBuildDate = "unknown";
String nativeScmRevision = "unknown";
try {
loadLibrary();
nativeVersion = getNativeVersion();
nativeBuildDate = getNativeBuildDate();
nativeScmRevision = getNativeScmRevision();
checkVersion(nativeVersion);
} catch (SigarException e) {
loadError = e.getMessage();
@ -104,6 +117,7 @@ public class Sigar implements SigarProxy {
NATIVE_VERSION_STRING = nativeVersion;
NATIVE_BUILD_DATE = nativeBuildDate;
NATIVE_SCM_REVISION = nativeScmRevision;
}
private static void checkVersion(String nativeVersionString)
@ -175,6 +189,7 @@ public class Sigar implements SigarProxy {
private static native String getNativeVersion();
private static native String getNativeBuildDate();
private static native String getNativeScmRevision();
/**
* Allocate and initialize the native Sigar object.

View File

@ -4,5 +4,7 @@ class SigarVersion {
static final String BUILD_DATE = "@@BUILD_DATE@@";
static final String SCM_REVISION = "@@SCM_REVISION@@";
static final String VERSION_STRING = "@@VERSION_STRING@@";
}

View File

@ -62,13 +62,15 @@ public class Version extends SigarCommandBase {
String build =
"java=" + Sigar.BUILD_DATE +
", native=" + Sigar.NATIVE_BUILD_DATE;
String scm =
"java=" + Sigar.SCM_REVISION +
", native=" + Sigar.NATIVE_SCM_REVISION;
String archlib =
SigarLoader.getNativeLibraryName();
os.println("Sigar version......." + version);
os.println("Build date.........." + build);
os.println("SVN rev............." + scm);
String host = getHostName();
String fqdn;
Sigar sigar = new Sigar();

View File

@ -852,6 +852,7 @@ SIGAR_DECLARE(int) sigar_proc_port_get(sigar_t *sigar,
typedef struct {
const char *build_date;
const char *scm_revision;
const char *version;
const char *archname;
const char *archlib;

View File

@ -2,6 +2,7 @@
static sigar_version_t sigar_version = {
"@@BUILD_DATE@@",
"@@SCM_REVISION@@",
"@@VERSION_STRING@@",
"@@ARCHNAME@@",
"@@ARCHLIB@@",