avatar-js/common.xml

352 lines
15 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project name="avatar-js-libs" basedir=".">
<target name="common-init">
<property file="${user.home}/.avatar-js.properties"/>
<property name="javac.debug" value="true"/>
<property name="javac.debuglevel" value="lines"/>
<property name="common.dir" location="${basedir}/.."/>
<property name="common.lib.dir" value="${common.dir}/lib"/>
<property name="common.dist.dir" value="${common.dir}/dist"/>
<property name="classes.dir" location="classes"/>
<property name="dist.dir" location="dist"/>
<property name="test.classes.dir" location="test-classes"/>
<property name="test.reports.dir" location="test-reports"/>
<property name="test.output.dir" location="test-output"/>
<condition property="isMacOSX">
<and>
<os family="unix"/>
<os family="mac"/>
</and>
</condition>
<condition property="isLinux">
<and>
<os family="unix"/>
<os name="Linux"/>
</and>
</condition>
<condition property="isSolaris">
<and>
<os family="unix"/>
<os name="SunOS"/>
</and>
</condition>
<condition property="isUnix">
<and>
<os family="unix"/>
<not>
<os family="windows"/>
</not>
</and>
</condition>
<condition property="isWindows">
<and>
<os family="windows"/>
<not>
<os family="unix"/>
</not>
</and>
</condition>
<!-- workaround for ant setting java.home to the jdk's jre -->
<condition property="is.jre">
<matches string="${java.home}" pattern="[/|\\]jre$"/>
</condition>
<condition property="jdk.home" value="${java.home}/..">
<isset property="is.jre"/>
</condition>
<condition property="jdk.home" value="${java.home}">
<not>
<isset property="is.jre"/>
</not>
</condition>
<condition property="isRelease">
<matches string="${build.type}" pattern="Release"/>
</condition>
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath location="${testng.jar}"/>
</taskdef>
<tstamp/>
</target>
<target name="init-unix" depends="init" if="isUnix">
<property name="product.lib" value="${dist.dir}/${product.name}.so"/>
</target>
<target name="init-macos" depends="init" if="isMacOSX">
<property name="product.lib" value="${dist.dir}/${product.name}.dylib"/>
</target>
<target name="init-windows" depends="init" if="isWindows">
<property name="product.lib" value="${dist.dir}/${product.name}.dll"/>
</target>
<target name="config-gyp">
<property name="gypi" value="config.gypi"/>
<echo file="${gypi}" append="false"># Do not edit. Generated by 'ant configure'. ${line.separator}</echo>
<echo file="${gypi}" append="true">{ 'variables': { ${line.separator}</echo>
<echo file="${gypi}" append="true"> 'JAVA_HOME%': '${jdk.home}', ${line.separator}</echo>
<echo file="${gypi}" append="true"> 'SOURCE_HOME%': '${source.home}', ${line.separator}</echo>
<echo file="${gypi}" append="true"> 'LIBUV_JAVA_HOME%': '${libuv.home}', ${line.separator}</echo>
<echo file="${gypi}" append="true"> 'HTTP_PARSER_JAVA_HOME%': '${http-parser.home}', ${line.separator}</echo>
<echo file="${gypi}" append="true"> 'AVATAR_JS_HOME%': '${avatar-js.home}', ${line.separator}</echo>
<echo file="${gypi}" append="true"> },${line.separator}</echo>
<echo file="${gypi}" append="true"> 'target_defaults': {'default_configuration': '${build.type}'}${line.separator}</echo>
<echo file="${gypi}" append="true">}${line.separator}</echo>
</target>
<macrodef name="gyp">
<attribute name="format"/>
<attribute name="library"/>
<attribute name="target"/>
<sequential>
<exec executable="python" dir="." failonerror="true">
<arg value="${source.home}/tools/gyp/gyp_main.py"/>
<arg value="--depth=."/>
<arg value="--format=@{format}"/>
<arg value="-Dtarget_arch=x64"/>
<arg value="-Dlibrary=@{library}"/>
<arg value="-Dtarget=@{target}"/>
<arg value="${product.name}.gyp"/>
</exec>
</sequential>
</macrodef>
<target name="configure" depends="init-unix, init-macos, init-windows, configure-unix, configure-mac, configure-windows">
<copy todir="${native.build.dir}">
<fileset dir="src/main/native" includes="**/*.cpp"/>
<fileset dir="src/main/native" includes="**/*.h"/>
</copy>
<uptodate property="product.lib.uptodate" targetfile="${product.lib}">
<srcfiles dir="${native.build.dir}" includes="**/*.h"/>
<srcfiles dir="${native.build.dir}" includes="**/*.cpp"/>
</uptodate>
</target>
<target name="compile" depends="init">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" debug="${javac.debug}" destdir="${classes.dir}" srcdir="${src.java.dir}">
<compilerarg value="-Xlint:all"/>
<compilerarg value="-deprecation"/>
<compilerarg value="-Werror"/>
<classpath refid="javac.classpath.id"/>
</javac>
</target>
<target name="make" depends="configure, compile, javah, make-linux, make-solaris, make-macos, make-windows"
description="runs make to build native sources">
<mkdir dir="${dist.dir}"/>
</target>
<target name="make-linux" if="isLinux" unless="product.lib.uptodate">
<exec executable="make" failonerror="true">
<arg value="builddir_name=out"/>
</exec>
</target>
<target name="make-macos" if="isMacOSX" unless="product.lib.uptodate">
<exec executable="make" failonerror="true">
<arg value="builddir_name=out"/>
</exec>
</target>
<target name="make-windows" if="isWindows" unless="product.lib.uptodate">
<exec executable="msbuild" failonerror="true">
<arg value="${product.name}.sln"/>
<arg value="/p:outdir=out/${build.type}/"/>
<arg value="/p:Platform=x64"/>
<arg value="/p:Configuration=${build.type}"/>
</exec>
</target>
<target name="shlib-linux" depends="init" if="isLinux">
<fileset dir="${basedir}/out/${source.home}" id="libuv" includes="**/*.o" excludes="**/test/*" erroronmissingdir="false"/>
<pathconvert property="libuv.objs" refid="libuv" pathsep=" " />
<fileset dir="${libuv.home}/out/${build.type}" id="libuv-java" includes="**/*.o" excludes="**/test/*" erroronmissingdir="false"/>
<pathconvert property="libuv-java.objs" refid="libuv-java" pathsep=" "/>
<fileset dir="${http-parser.home}/out/${build.type}" id="http-parser-java" includes="**/*.o" erroronmissingdir="false"/>
<pathconvert property="http-parser-java.objs" refid="http-parser-java" pathsep=" " />
<fileset dir="${avatar-js.home}/out/${build.type}" id="avatar-js" includes="**/*.o" erroronmissingdir="false"/>
<pathconvert property="avatar-js.objs" refid="avatar-js" pathsep=" " />
<exec executable="gcc" dir="${dist.dir}" failonerror="true">
<arg value="-shared"/>
<arg value="-o"/>
<arg value="libavatar-js.so"/>
<arg line="${libuv.objs}"/>
<arg line="${libuv-java.objs}"/>
<arg line="${http-parser-java.objs}"/>
<arg line="${avatar-js.objs}"/>
<arg value="-lm"/>
<arg value="-ldl"/>
<arg value="-lrt"/>
<arg value="-pthread"/>
<arg value="-lstdc++"/>
</exec>
</target>
<target name="shlib-solaris" depends="init" if="isSolaris">
<fileset dir="${basedir}/out/${source.home}" id="libuv" includes="**/*.o" excludes="**/test/*" erroronmissingdir="false"/>
<pathconvert property="libuv.objs" refid="libuv" pathsep=" " />
<fileset dir="${libuv.home}/out/${build.type}" id="libuv-java" includes="**/*.o" excludes="**/test/*" erroronmissingdir="false"/>
<pathconvert property="libuv-java.objs" refid="libuv-java" pathsep=" "/>
<fileset dir="${http-parser.home}/out/${build.type}" id="http-parser-java" includes="**/*.o" erroronmissingdir="false"/>
<pathconvert property="http-parser-java.objs" refid="http-parser-java" pathsep=" " />
<fileset dir="${avatar-js.home}/out/${build.type}" id="avatar-js" includes="**/*.o" erroronmissingdir="false"/>
<pathconvert property="avatar-js.objs" refid="avatar-js" pathsep=" " />
<exec executable="gcc" dir="${dist.dir}" failonerror="true">
<arg value="-m64"/>
<arg value="-shared"/>
<arg value="-o"/>
<arg value="libavatar-js.so"/>
<arg line="${libuv.objs}"/>
<arg line="${libuv-java.objs}"/>
<arg line="${http-parser-java.objs}"/>
<arg line="${avatar-js.objs}"/>
<arg value="-lm"/>
<arg value="-ldl"/>
<arg value="-lrt"/>
<arg value="-pthreads"/>
<arg value="-lstdc++"/>
</exec>
</target>
<target name="shlib-macos" depends="init" if="isMacOSX">
<fileset dir="${libuv.home}/out/${build.type}" id="libuv-java" includes="**/*.o" excludes="**/test/*" erroronmissingdir="false"/>
<pathconvert property="libuv-java.objs" refid="libuv-java" pathsep=" "/>
<fileset dir="${http-parser.home}/out/${build.type}" id="http-parser-java" includes="**/*.o" erroronmissingdir="false"/>
<pathconvert property="http-parser-java.objs" refid="http-parser-java" pathsep=" " />
<fileset dir="${avatar-js.home}/out/${build.type}" id="avatar-js" includes="**/*.o" erroronmissingdir="false"/>
<pathconvert property="avatar-js.objs" refid="avatar-js" pathsep=" " />
<exec executable="c++" dir="${dist.dir}" failonerror="true">
<arg value="-shared"/>
<arg value="-o"/>
<arg value="libavatar-js.dylib"/>
<arg line="${libuv-java.objs}"/>
<arg line="${http-parser-java.objs}"/>
<arg line="${avatar-js.objs}"/>
<arg value="-lm"/>
<arg value="-framework"/>
<arg value="Foundation"/>
<arg value="-framework"/>
<arg value="CoreServices"/>
<arg value="-framework"/>
<arg value="ApplicationServices"/>
</exec>
</target>
<target name="shlib-windows" depends="init" if="isWindows">
<fileset dir="${source.home}/deps/uv/${build.type}" id="libuv" includes="**/*.obj" excludes="**/test/*" erroronmissingdir="false"/>
<pathconvert property="libuv.objs" refid="libuv" pathsep=" " />
<fileset dir="${libuv.home}/out/${build.type}" id="libuv-java" includes="**/*.obj" erroronmissingdir="false"/>
<pathconvert property="libuv-java.objs" refid="libuv-java" pathsep=" " />
<fileset dir="${http-parser.home}/out/${build.type}" id="http-parser-java" includes="**/*.obj" erroronmissingdir="false"/>
<pathconvert property="http-parser-java.objs" refid="http-parser-java" pathsep=" " />
<fileset dir="${avatar-js.home}/out/${build.type}" id="avatar-js" includes="**/*.obj" erroronmissingdir="false"/>
<pathconvert property="avatar-js.objs" refid="avatar-js" pathsep=" " />
<condition property="release.arg1" value="/LTCG" else="">
<istrue value="${isRelease}"/>
</condition>
<condition property="release.arg2" value="msvcrt.lib" else="">
<istrue value="${isRelease}"/>
</condition>
<exec executable="link.exe" dir="${dist.dir}" failonerror="true">
<arg value="/NODEFAULTLIB:msvcrt"/>
<arg value="/OUT:avatar-js.dll"/>
<arg value="/DLL"/>
<arg value="${release.arg1}"/>
<arg value="${release.arg2}"/>
<arg value="advapi32.lib"/>
<arg value="iphlpapi.lib"/>
<arg value="psapi.lib"/>
<arg value="shell32.lib"/>
<arg value="ws2_32.lib"/>
<arg line="${libuv.objs}"/>
<arg line="${libuv-java.objs}"/>
<arg line="${http-parser-java.objs}"/>
<arg line="${avatar-js.objs}"/>
</exec>
</target>
<target name="clean" depends="init" description="clean output dirs">
<delete dir="out"/>
<delete dir="${classes.dir}"/>
<delete dir="${test.classes.dir}"/>
<delete dir="${test.reports.dir}"/>
<delete dir="${test.output.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${build.type}"/>
<delete dir="Debug"/>
<delete dir="Default"/>
<delete dir="Release"/>
<delete dir="test/tmp"/>
<delete file="config.gypi"/>
<delete file="Makefile"/>
<delete file="${product.name}.Makefile"/>
<delete file="${product.name}.target.mk"/>
<delete file="${product.name}.sln"/>
<delete file="${product.name}.vcxproj"/>
<delete file="${product.name}.vcxproj.filters"/>
<delete file="gyp-mac-tool"/>
<delete>
<fileset dir="." includes="test*.txt"/>
<fileset dir="." includes="*.log"/>
</delete>
</target>
<target name="test" depends="compile-tests">
<testng outputdir="${test.reports.dir}" useDefaultListeners="true"
listener="org.testng.reporters.XMLReporter">
<classfileset dir="${test.classes.dir}" includes="**/*Test.class"/>
<classpath path="${classes.dir}"/>
<classpath path="${test.classes.dir}"/>
<classpath refid="javac.test.classpath.id"/>
<jvmarg value="-Xverify:all"/>
<jvmarg value="-Xcheck:jni"/>
<jvmarg value="-Xmx1g"/>
<sysproperty key="java.library.path" value="${dist.dir}"/>
</testng>
</target>
<target name="compile-tests" depends="jar">
<mkdir dir="${test.classes.dir}"/>
<javac includeantruntime="false" debug="true" destdir="${test.classes.dir}" srcdir="${test.java.dir}">
<classpath path="${classes.dir}"/>
<classpath path="${testng.jar}"/>
<classpath refid="javac.test.classpath.id"/>
</javac>
<copy todir="${test.classes.dir}" failonerror="false">
<fileset dir="${test.java.dir}/../js"/>
</copy>
</target>
</project>