1 <project name="gdx-bullet-module-swig-gen" basedir="." default="all"> 2 3 <property name="module.name" value="unknown" /> 4 <property name="module.interface" value="${module.name}/${module.name}.i" /> 5 <property name="module.package" value="com.badlogic.gdx.physics.bullet.${module.name}" /> 6 <property name="module.path" value="com/badlogic/gdx/physics/bullet/${module.name}" /> 7 8 <property name="dir.out" location="${basedir}/../swig-src/${module.name}/" /> 9 10 <property name="module.wrapper" value="${dir.out}/${module.name}_wrap.cpp" /> 11 12 <target name="clean"> 13 <echo message="Deleting previously generated files in ${dir.out}" level="info" /> 14 15 <mkdir dir="${dir.out}" /> 16 <delete> 17 <fileset dir="${dir.out}" includes="**/*" /> 18 </delete> 19 </target> 20 21 <target name="gen"> 22 23 <mkdir dir="${dir.out}/${module.path}" /> 24 25 <echo message="Swigging" level="info" /> 26 27 <exec executable="swig"> 28 <arg value="-java" /> 29 <arg value="-c++" /> 30 <arg value="-fvirtual" /> 31 <arg value="-package" /> 32 <arg value="${module.package}" /> 33 <arg value="-I${basedir}/../src/bullet" /> 34 <arg value="-I${basedir}/../src/custom" /> 35 <arg value="-I${basedir}/../src/extras/Serialize" /> 36 <!-- Disable Bullet profiling --> 37 <arg value="-DBT_NO_PROFILE" /> 38 <arg value="-outdir" /> 39 <arg value="${dir.out}/${module.path}" /> 40 <arg value="-o" /> 41 <arg value="${module.wrapper}" /> 42 <arg value="${basedir}/${module.interface}" /> 43 44 </exec> 45 </target> 46 47 <target name="fix_casts"> 48 49 <echo message="Replacing director dynamic_cast with C-style casts to avoid RTTI" level="info" /> 50 <replaceregexp file="${module.wrapper}" flags="g"> 51 <regexp pattern="(SwigDirector_[\w]+) \*director = dynamic_cast<(SwigDirector_[\w]+ \*)>\(obj\);" /> 52 <substitution expression="\1 *director = (\2)(obj);" /> 53 </replaceregexp> 54 55 <replace file="${module.wrapper}" token="bool ExceptionMatches" value="inline bool ExceptionMatches" /> 56 57 </target> 58 59 <target name="remove_weak_global"> 60 <echo message="Remove weak_global" level="info" /> 61 <replace file="${module.wrapper}" 62 token="weak_global_ = weak_global || !mem_own;" 63 value="weak_global_ = !mem_own;" /> 64 </target> 65 66 <target name="list_classes"> 67 <fileset id="classes" dir="${dir.out}" includes="**/*.java" /> 68 <pathconvert property="classlist" refid="classes" pathsep="${line.separator}" /> 69 <echo file="${dir.out}/classes.i" message="${classlist}" /> 70 <replace file="${dir.out}/classes.i" token="${dir.out}" value="" /> 71 <replace file="${dir.out}/classes.i" token="/" value="." /> 72 <replace file="${dir.out}/classes.i" token="\" value="." /> 73 <replaceregexp file="${dir.out}/classes.i" flags="g"> 74 <regexp pattern="\.([a-z0-9]+([\.][a-z0-9]+)+)\.([^\.]+)\.java" /> 75 <substitution expression="SPECIFY_CLASS(\3, \1)" /> 76 </replaceregexp> 77 </target> 78 79 <target name="all" depends="clean,gen,fix_casts,remove_weak_global,list_classes"> 80 <echo message="Wrapper files generated for ${module.name}." level="info" /> 81 </target> 82 </project> 83