sigar/bindings/java/build.xml

534 lines
17 KiB
XML
Raw Normal View History

2004-06-22 06:37:04 +08:00
<!DOCTYPE project [
<!ENTITY jni-build SYSTEM "hyperic_jni/jni-build.xml">
]>
<project name="Sigar" default="build" basedir=".">
2009-04-05 10:29:15 +08:00
<property file="../../version.properties"/>
2005-08-28 15:03:49 +08:00
<property name="sigar.version"
value="${version.major}.${version.minor}.${version.maint}"/>
2004-07-24 01:36:17 +08:00
2004-06-22 06:37:04 +08:00
<property file="${user.home}/.sigar-build.properties"/>
<property name="project.name" value="sigar"/>
<property name="jni.define.name" value="SIGAR"/>
<property name="sigar-bin" location="sigar-bin"/>
2004-09-19 01:46:28 +08:00
<property name="sigar-bin-dir" location="${sigar-bin}"/>
<property name="jni.git" location="../../.git"/>
2004-06-22 06:37:04 +08:00
<property name="jni.bin" location="${sigar-bin}"/>
<property name="jni.source.dir" location="../.."/>
<property name="jni.src.java" value="hyperic_jni/src"/>
2007-12-13 13:47:56 +08:00
<property name="jni.info.plist" location="build/src/Info.plist"/>
2008-05-12 13:28:07 +08:00
<property name="jni.info.res" location="build/src/sigar.res"/>
2004-06-22 06:37:04 +08:00
<property name="jni.libprefix" value=""/> <!-- drop "java" prefix -->
<property name="cpptasks.jar"
location="hyperic_jni/lib/cpptasks.jar"/>
2008-01-26 09:09:25 +08:00
<condition property="file.version" value="-${sigar.version}">
<isset property="file.versioned"/>
</condition>
<condition property="file.version" value="">
<not>
<isset property="versioned"/>
</not>
</condition>
<property name="jni.libversion" value="${file.version}"/>
<property name="sigar.jar" value="sigar${file.version}.jar"/>
2004-06-22 06:37:04 +08:00
&jni-build;
<property name="src" location="src"/>
<property name="build" location="build"/>
2004-07-15 08:06:31 +08:00
<property name="build.javadoc" value="${build}/javadoc"/>
2006-07-18 07:01:06 +08:00
<property name="dist.bin.name" value="hyperic-sigar-${sigar.version}"/>
<property name="dist.src.name" value="${dist.bin.name}-src"/>
<property name="dist.bin" location="${build}/${dist.bin.name}"/>
<property name="dist.src" location="${build}/${dist.src.name}"/>
2004-06-22 06:37:04 +08:00
<property name="perl" value="perl"/>
<!-- trick TestFQDN into passing with: ant test -Dsigar.fdqn=foo.bar -->
<property name="sigar.fqdn" value=""/>
<path id="libjars">
<fileset dir="lib" includes="*.jar"/>
</path>
<path id="alljars">
<path refid="libjars"/>
2008-01-26 09:09:25 +08:00
<fileset dir="${sigar-bin}/lib" includes="${sigar.jar}"/>
2010-04-09 00:41:45 +08:00
<fileset dir="${ant.library.dir}" includes="junit*.jar"/>
2004-06-22 06:37:04 +08:00
</path>
<target name="javadoc_check">
<uptodate property="javadoc.notrequired"
2004-07-15 08:06:31 +08:00
targetfile="${build.javadoc}/packages.html" >
2004-06-22 06:37:04 +08:00
<srcfiles dir="src" includes="**/*.java"/>
</uptodate>
</target>
2004-07-15 08:06:31 +08:00
<path id="javadoc.path">
2004-06-22 06:37:04 +08:00
<pathelement path="src"/>
<pathelement path="${build}/src"/>
<pathelement path="${jni.src.java}"/>
2004-06-22 06:37:04 +08:00
</path>
2004-07-15 08:06:31 +08:00
<target name="javadoc" depends="javadoc_check">
<mkdir dir="${build.javadoc}"/>
<javadoc packagenames="org.hyperic.sigar.*"
excludepackagenames="org.hyperic.sigar.test.*,org.hyperic.jni.*,org.hyperic.sigar.pager.*,org.hyperic.sigar.jmx.*,org.hyperic.sigar.win32.test.*"
2004-06-22 06:37:04 +08:00
useexternalfile="yes"
2004-07-15 08:06:31 +08:00
sourcepathref="javadoc.path"
destdir="${build.javadoc}"
2004-06-22 06:37:04 +08:00
author="false"
version="false"
windowtitle="Sigar API"
doctitle="Sigar">
<group title="Sigar" packages="org.hyperic.sigar" />
2004-06-22 06:37:04 +08:00
<classpath refid="libjars"/>
2010-04-09 00:41:45 +08:00
<classpath><path path="${ant.library.dir}/ant.jar"/></classpath>
<bottom>Copyright &#169; ${copyright.year} <![CDATA[<a target="_top" href="http://www.hyperic.com/">Hyperic</a>]]>. All Rights Reserved.</bottom>
2004-06-22 06:37:04 +08:00
</javadoc>
</target>
<target name="compile">
<mkdir dir="${build}/classes"/>
<available classname="junit.framework.TestCase" property="junit.present">
<classpath refid="alljars"/>
</available>
2004-06-22 06:37:04 +08:00
<javac destdir="${build}/classes"
2008-07-08 06:16:12 +08:00
source="1.4" target="1.4"
sourcepath=""
2004-06-22 06:37:04 +08:00
debug="true"
classpathref="libjars">
<src path="${src}"/>
<src path="${build}/src"/>
<src path="${jni.src.java}"/>
<include name="**/*.java"/>
<exclude name="**/test/*.java" unless="junit.present"/>
2004-06-22 06:37:04 +08:00
</javac>
</target>
<target name="version-file">
<property name="version.file.srcdir"
value="."/>
<property name="version.file.dstdir"
value="."/>
<property name="version.tofile"
value="${build}/${version.file.dstdir}/${version.file}"/>
<echo>cp ${version.file.srcdir}/${version.file}.in -> ${version.tofile}</echo>
<copy file="${version.file.srcdir}/${version.file}.in"
tofile="${version.tofile}" overwrite="true"/>
<replace file="${version.tofile}">
2004-07-24 01:36:17 +08:00
<replacefilter token="@@BUILD_DATE@@" value="${BUILD_DATE}"/>
<replacefilter token="@@VERSION_STRING@@" value="${sigar.version}.${version.build}"/>
<replacefilter token="@@SCM_REVISION@@" value="${jni.scmrev}"/>
2005-12-15 07:48:28 +08:00
<replacefilter token="@@ARCHNAME@@" value="${jni.libarch}"/>
2005-12-15 08:14:03 +08:00
<replacefilter token="@@ARCHLIB@@" value="${jni.libname.full}"/>
2005-12-15 07:48:28 +08:00
<replacefilter token="@@BINNAME@@" value="${jni.project.archname}"/>
2005-08-28 15:09:24 +08:00
<replacefilter token="@@VERSION_MAJOR@@" value="${version.major}"/>
<replacefilter token="@@VERSION_MINOR@@" value="${version.minor}"/>
<replacefilter token="@@VERSION_MAINT@@" value="${version.maint}"/>
<replacefilter token="@@VERSION_BUILD@@" value="${version.build}"/>
2005-08-28 15:11:44 +08:00
<replacefilter token="@@COPYRIGHT_YEAR@@" value="${copyright.year}"/>
2005-08-28 15:09:24 +08:00
</replace>
2004-07-24 01:36:17 +08:00
</target>
<target name="sigar-version">
<tstamp>
<format property="BUILD_DATE" pattern="MM/dd/yyyy hh:mm aa"/>
</tstamp>
<echo message="SIGAR git revision ${jni.scmrev}"/>
<antcall target="version-file">
<param name="version.file"
2009-04-30 01:17:58 +08:00
value="src/org/hyperic/sigar/Version.java"/>
</antcall>
<antcall target="version-file">
<param name="version.file.srcdir"
value="../.."/>
<param name="version.file"
value="src/sigar_version.c"/>
2008-08-10 10:47:05 +08:00
<param name="version.tofile"
value="${build}/src/sigar_version.c"/>
</antcall>
2007-12-13 13:47:56 +08:00
<antcall target="version-file">
<param name="version.file.srcdir"
value="../.."/>
<param name="version.file"
value="src/os/darwin/Info.plist"/>
<param name="version.tofile"
value="${build}/src/Info.plist"/>
</antcall>
2008-05-12 13:28:07 +08:00
<antcall target="version-file">
<param name="version.file.srcdir"
value="../.."/>
<param name="version.file"
value="src/os/win32/sigar.rc"/>
<param name="version.tofile"
value="${build}/src/sigar.rc"/>
</antcall>
</target>
<target name="sigar.rc" if="win32">
<exec executable="rc" dir="${build}/src">
<arg value="/r"/>
<arg value="sigar.rc"/>
</exec>
</target>
2008-05-12 13:28:07 +08:00
<target name="prepare-src" depends="sigar-version,sigar.rc">
2004-06-22 06:37:04 +08:00
<mkdir dir="${build}/src"/>
<exec executable="${perl}" dir=".">
2007-09-03 08:20:19 +08:00
<arg value="-Mlib=.."/>
<arg value="-MSigarWrapper"/>
<arg value="-e"/>
<arg value="generate"/>
<arg value="Java"/>
2004-06-22 06:37:04 +08:00
<arg value="${build}/src"/>
</exec>
<condition property="win32.jni" value="jni/win32">
<isset property="win32"/>
</condition>
<condition property="vmware.jni" value="jni/vmware">
<or>
<isset property="win32"/>
<isset property="linux"/>
</or>
</condition>
2004-06-22 06:37:04 +08:00
<!-- include sigar *.c files rather than link against libsigar -->
<patternset id="jni.source.files">
<include name="src/*.c"/>
2005-12-15 13:35:43 +08:00
<exclude name="src/sigar_main.c"/>
2004-06-22 06:37:04 +08:00
<include name="src/os/${jni.src}/*.c"/>
2009-08-06 04:47:13 +08:00
<include name="src/os/${jni.src}/*.cpp"/>
2004-11-21 05:01:48 +08:00
<include name="bindings/java/src/jni/*.c"/>
<include name="bindings/java/src/${win32.jni}/*.cpp"/>
<include name="bindings/java/src/${win32.jni}/*.c"/>
<include name="bindings/java/src/${vmware.jni}/*.c"/>
<include name="bindings/java/build/src/sigar_version.c"/>
2004-06-22 06:37:04 +08:00
</patternset>
<path id="jni.include.dirs">
<path location="../../include"/>
<path location="../../src/os/${jni.src}"/>
<path location="${build}/src"/>
2004-11-21 05:01:48 +08:00
<path location="src/jni"/>
2004-06-22 06:37:04 +08:00
</path>
<!-- extra solaris libs -->
2004-06-22 06:37:04 +08:00
<condition property="jni.libset.dir" value="/usr/lib">
<isset property="solaris"/>
</condition>
<condition property="jni.libset.libs" value="kstat">
<isset property="solaris"/>
</condition>
<!-- extra aix libs -->
<condition property="jni.libset.dir" value="/usr/lib">
<isset property="aix"/>
</condition>
2009-02-16 11:02:25 +08:00
<condition property="jni.libset.libs" value="odm,cfg,perfstat,pthreads">
<isset property="aix"/>
</condition>
2004-06-22 06:37:04 +08:00
</target>
<target name="copy-includes">
<mkdir dir="${sigar-bin}/include"/>
<copy toDir="${sigar-bin}/include" overwrite="true">
<fileset dir="../../include">
<include name="sigar.h"/>
<include name="sigar_fileinfo.h"/>
2007-05-19 12:18:31 +08:00
<include name="sigar_format.h"/>
2008-09-14 08:01:06 +08:00
<include name="sigar_ptql.h"/>
<include name="sigar_log.h"/>
2004-06-22 06:37:04 +08:00
</fileset>
</copy>
</target>
2005-12-15 13:35:43 +08:00
<target name="sigar-exe-cpptasks">
<cc outtype="executable"
2006-01-01 02:29:55 +08:00
outfile="${jni.bin}/lib/${jni.libname}"
2005-12-15 13:35:43 +08:00
objdir="${jni.objdir}">
<compiler name="${jni.compiler}" debug="${jni.debug}"/>
<linker name="${jni.compiler}">
<libset dir="${jni.bin}/lib"
libs="${jni.libname}"/>
</linker>
2006-01-01 02:29:55 +08:00
<includepath location="../../include"/>
2005-12-15 13:35:43 +08:00
<fileset dir="${jni.source.dir}">
<include name="src/sigar_main.c"/>
</fileset>
</cc>
</target>
2005-12-16 09:32:09 +08:00
<target name="sigar-exe" if="jni.compiler.isgcc">
2005-12-15 13:35:43 +08:00
<exec executable="${jni.compiler}"
dir="${jni.source.dir}"
failonerror="true">
2005-12-16 04:23:33 +08:00
<arg value="-Wall"/>
<arg value="-Werror"/>
2005-12-15 13:35:43 +08:00
<arg value="-ldl"/>
<arg value="-I./include"/>
<arg value="src/sigar_main.c"/>
<arg value="-o"/>
<arg value="${jni.bin}/lib/${jni.libname}"/>
</exec>
<chmod perm="a+x">
<fileset dir="${jni.bin}/lib">
<include name="${jni.libname}"/>
</fileset>
</chmod>
</target>
2004-06-22 06:37:04 +08:00
<target name="build-jni"
2005-12-20 06:05:36 +08:00
depends="jni-init,prepare-src,jni-compile,jni-lib-copy,copy-includes"
2004-06-22 06:37:04 +08:00
if="jni.libarch"/>
2005-05-11 04:33:53 +08:00
<target name="pack">
2008-01-26 09:09:25 +08:00
<jar jarfile="${sigar-bin}/lib/${sigar.jar}"
2004-06-22 06:37:04 +08:00
basedir="${build}/classes">
<manifest>
<attribute name="Main-Class"
value="org.hyperic.sigar.cmd.Runner"/>
2004-06-22 06:37:04 +08:00
</manifest>
</jar>
</target>
2009-02-16 11:02:25 +08:00
<target name="build" depends="build-jni,compile,pack"/>
2004-06-22 06:37:04 +08:00
<target name="clean">
<delete dir="${build}"/>
<delete dir="${sigar-bin}"/>
</target>
2008-07-08 13:40:57 +08:00
<target name="xtest" depends="jni-init">
2004-11-21 09:17:51 +08:00
<condition property="win32.test" value="win32/test">
<os family="windows"/>
</condition>
2008-07-14 08:08:38 +08:00
<condition property="junit.args" value="${env.ANT_OPTS}">
<isset property="env.ANT_OPTS"/>
</condition>
<condition property="junit.args" value="">
<not>
<isset property="junit.args"/>
</not>
</condition>
2008-08-11 09:33:08 +08:00
<property name="testresults"
location="${build}/testresults/${jni.libarch}"/>
<mkdir dir="${testresults}"/>
<!-- test/capture sigar.jar version -->
<java fork="yes" failonerror="yes"
output="${testresults}/version.txt"
jvm="${java.home}/bin/java"
jvmargs="${junit.args}"
jar="${sigar-bin}/lib/${sigar.jar}">
<arg value="version"/>
</java>
2008-10-09 15:08:43 +08:00
<property name="junit.mx" value="-Dcom.sun.management.jmxremote"/>
2004-06-22 06:37:04 +08:00
<junit printsummary="yes" fork="yes"
haltonfailure="yes" showoutput="true">
2008-10-09 15:08:43 +08:00
<jvmarg line="${junit.args} ${junit.mx}"/>
2004-06-22 06:37:04 +08:00
<classpath refid="alljars"/>
2008-07-08 13:40:57 +08:00
<formatter type="xml"/>
2004-06-22 06:37:04 +08:00
2008-08-11 09:06:13 +08:00
<batchtest fork="yes" todir="${testresults}">
2004-06-22 06:37:04 +08:00
<fileset dir="${src}">
<include name="org/hyperic/sigar/test/Test*.java"/>
<include name="org/hyperic/sigar/${win32.test}/Test*.java"/>
2004-11-21 09:17:51 +08:00
<exclude name="**/.java"/>
2004-06-22 06:37:04 +08:00
<!-- slow; run by hand with bin/run_tests.sh Threads -->
<exclude name="**/TestThreads*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="test" depends="build,xtest"/>
2006-07-18 07:01:06 +08:00
<target name="dist-pack" depends="dist-common">
<zip destfile="${dist}.zip"
basedir="${build}"
includes="${dist.name}/**/*"/>
<!-- Stupid ant tar task, doesn't preserve file permissions
without making you jump through some hoops -->
<tar tarfile="${dist}.tar.gz"
longfile="gnu"
compression="gzip">
<tarfileset dir="${dist}/.." mode="755">
<include name="${dist.name}/**/bin/*"/>
<include name="${dist.name}/**/*.sh"/>
<include name="${dist.name}/**/*.bat"/>
<include name="${dist.name}/**/*.cmd"/>
<include name="${dist.name}/**/*.sl"/>
</tarfileset>
<tarfileset dir="${dist}/..">
<exclude name="${dist.name}/**/bin/*"/>
<exclude name="${dist.name}/**/*.sh"/>
<exclude name="${dist.name}/**/*.bat"/>
<exclude name="${dist.name}/**/*.cmd"/>
<exclude name="${dist.name}/**/*.sl"/>
<include name="${dist.name}/**"/>
</tarfileset>
</tar>
</target>
<target name="dist-bin">
<!-- binaries -->
2006-07-18 07:01:06 +08:00
<mkdir dir="${dist.bin}/sigar-bin"/>
<copy toDir="${dist.bin}/sigar-bin">
2004-09-19 01:46:28 +08:00
<fileset dir="${sigar-bin-dir}">
<include name="lib/*.jar"/>
<include name="lib/*.dll"/>
<include name="lib/*.sl"/>
<include name="lib/*.so"/>
<include name="lib/*.dylib"/>
<include name="lib/*.lib"/>
</fileset>
<fileset dir=".">
2008-09-14 07:50:18 +08:00
<include name="lib/log4j.jar"/>
</fileset>
</copy>
2006-07-18 07:01:06 +08:00
<!-- header files -->
<copy toDir="${dist.bin}/sigar-bin">
<fileset dir="${sigar-bin}">
<include name="include/*.h"/>
2004-07-22 02:39:58 +08:00
</fileset>
</copy>
2006-07-18 07:01:06 +08:00
<copy toDir="${dist.bin}/sigar-bin/lib">
<fileset dir=".">
<include name=".sigar_shellrc"/>
2004-07-22 04:06:18 +08:00
</fileset>
</copy>
2006-07-18 07:01:06 +08:00
<mkdir dir="${dist.bin}/bindings/java/examples"/>
<copy toDir="${dist.bin}/bindings/java/examples">
<fileset dir="src/org/hyperic/sigar/cmd">
<include name="*.java"/>
2004-07-22 04:14:21 +08:00
</fileset>
</copy>
2006-07-18 07:01:06 +08:00
</target>
2004-07-22 04:14:21 +08:00
2006-07-18 07:01:06 +08:00
<target name="dist-bindings">
2006-07-18 07:01:06 +08:00
<!-- bindings -->
<copy toDir="${dist}">
<fileset dir="../..">
2008-02-01 12:41:47 +08:00
<include name="bindings/SigarWrapper.pm"/>
2006-07-18 07:01:06 +08:00
<include name="bindings/java/examples/*.java"/>
2004-07-15 08:23:34 +08:00
2006-07-18 07:01:06 +08:00
<include name="bindings/perl/Makefile.PL"/>
<include name="bindings/perl/typemap"/>
<include name="bindings/perl/*.xs"/>
<include name="bindings/perl/**/*.pm"/>
<include name="bindings/perl/examples/*.pl"/>
2008-02-01 12:41:47 +08:00
<include name="bindings/dotnet/default.build"/>
<include name="bindings/dotnet/**/*.cs"/>
<include name="bindings/php/config.m4"/>
<include name="bindings/php/php_sigar.c"/>
<include name="bindings/php/php_sigar.h"/>
<include name="bindings/php/examples/*.php"/>
<include name="bindings/python/_sigar.c"/>
<include name="bindings/python/sigar.py"/>
<include name="bindings/python/setup.py"/>
<include name="bindings/python/examples/*.py"/>
<include name="bindings/ruby/rbsigar.c"/>
<include name="bindings/ruby/extconf.rb"/>
<include name="bindings/ruby/examples/*.rb"/>
2006-04-01 02:03:07 +08:00
</fileset>
2004-07-15 08:23:34 +08:00
</copy>
2006-07-18 07:01:06 +08:00
<copy toDir="${dist}/bindings/perl">
<fileset dir="${build}/src">
<include name="Sigar_generated.xs"/>
2004-07-15 08:23:34 +08:00
</fileset>
</copy>
2006-07-18 07:01:06 +08:00
</target>
2004-07-15 08:23:34 +08:00
2006-07-18 07:01:06 +08:00
<target name="dist-common" depends="javadoc,dist-bindings">
<copy toDir="${dist}" overwrite="true">
<fileset dir="../..">
<include name="README"/>
2010-04-29 06:24:17 +08:00
<include name="LICENSE"/>
<include name="NOTICE"/>
2006-07-18 07:01:06 +08:00
<include name="ChangeLog"/>
2004-07-15 08:23:34 +08:00
</fileset>
</copy>
2006-07-18 07:01:06 +08:00
<!-- docs -->
<mkdir dir="${dist}/docs"/>
<copy toDir="${dist}/docs">
<fileset dir="${build}">
<include name="javadoc/**"/>
2004-06-22 06:37:04 +08:00
</fileset>
</copy>
2006-07-18 07:01:06 +08:00
</target>
2006-07-18 07:01:06 +08:00
<target name="dist" depends="dist-bin">
<copy toDir="${dist.src}">
<fileset dir="../..">
2009-04-05 10:29:15 +08:00
<include name="version.properties"/>
2006-07-18 07:01:06 +08:00
<include name="include/*.h"/>
<include name="src/**/*.h"/>
<include name="src/**/*.c"/>
<include name="src/**/*.in"/>
<include name="bindings/java/hyperic_jni/**"/>
<include name="bindings/java/**/*.java"/>
<include name="bindings/java/**/*.java.in"/>
<include name="bindings/java/**/*.c"/>
<include name="bindings/java/**/*.h"/>
<include name="bindings/java/**/*.pl"/>
<include name="bindings/java/**/build.xml"/>
<include name="bindings/java/.classpath"/>
<include name="bindings/java/.project"/>
<include name="bindings/java/.sigar_shellrc"/>
2008-09-14 07:50:18 +08:00
<include name="bindings/java/lib/log4j.jar"/>
<include name="bindings/java/lib/junit.jar"/>
2006-07-18 07:01:06 +08:00
<exclude name="**/.svn/**"/>
<exclude name="bindings/java/build/**"/>
</fileset>
</copy>
2004-06-22 06:37:04 +08:00
2006-07-18 07:01:06 +08:00
<antcall target="dist-pack">
<param name="dist" value="${dist.bin}"/>
<param name="dist.name" value="${dist.bin.name}"/>
</antcall>
2006-07-18 07:01:06 +08:00
<antcall target="dist-pack">
<param name="dist" value="${dist.src}"/>
<param name="dist.name" value="${dist.src.name}"/>
</antcall>
</target>
2004-06-22 06:37:04 +08:00
</project>