Marcus R. Brown avatar Marcus R. Brown committed 3d6f269

Duplicate several ant targets to support building for Android. Copy in the "compile" target as "compile-android" (all other Android-specific targets use a "-android" suffix).

Comments (0)

Files changed (1)

         </uptodate>
     </target>
 
+    <target name="needed-check-android" unless="full-build">
+        <uptodate property="antlr.notneeded" targetfile="${gen.dir}/org/python/antlr/PythonParser.java">
+            <srcfiles dir="grammar" includes="*.g" />
+        </uptodate>
+    </target>
+
     <target name="init">
         <property file="${user.home}/ant.properties" />
         <property file="${basedir}/ant.properties" />
         <mkdir dir="${dist.dir}" />
     </target>
 
+    <target name ="prepare-output-android" depends="init,needed-check-android,clean-if-antlr-needed">
+        <mkdir dir="${out.classes.dir}" />
+        <mkdir dir="${gen.dir}/org/python/antlr" />
+        <mkdir dir="${exposed.dir}" />
+        <mkdir dir="${dist.dir}" />
+    </target>
+
     <!-- create necessary directories -->
     <target name="prepare" depends="prepare-full, prepare-checkout, prepare-output"/>
 
 	</copy>
     </target>
 
+    <target name="antlr_gen-android" depends="prepare-output-android" unless="antlr.notneeded">
+        <java classname="org.antlr.Tool" failonerror="true" fork="true" dir="${jython.base.dir}">
+            <jvmarg value="-Xmx128m"/>
+            <arg value="-Xconversiontimeout"/>
+            <arg value="2000"/>
+            <arg value="-fo"/>
+            <arg path="${gen.dir}/org/python/antlr"/>
+            <arg value="-lib"/>
+            <arg path="${gen.dir}/org/python/antlr"/>
+            <arg file="${jython.base.dir}/grammar/Python.g"/>
+            <arg file="${jython.base.dir}/grammar/PythonPartial.g"/>
+            <classpath refid="main.classpath"/>
+        </java>
+        
+        <!-- copy the .tokens to /grammar, for usage in ANTLRWorks -->
+        <!--
+        <copy todir="grammar" preservelastmodified="true">
+            <fileset dir="build/gensrc/org/python/antlr">
+                <include name="Python.tokens" />
+            </fileset>
+        </copy>
+        -->
+
+    </target>
+
+    <target name="compile-android"
+            depends="init,antlr_gen-android,brand-version,-resource-src,-aidl,-pre-compile"
+            description="Compiles project's .java files into .class files">
+        <!-- If android rules are used for a test project, its classpath should include
+             tested project's location -->
+        <condition property="extensible.classpath"
+                           value="${tested.project.absolute.dir}/bin/classes" else=".">
+            <isset property="tested.project.absolute.dir" />
+        </condition>
+        <condition property="extensible.libs.classpath"
+                value="${tested.project.absolute.dir}/libs"
+                else="./libs">
+            <isset property="tested.project.absolute.dir" />
+        </condition>
+        <javac encoding="${java.encoding}"
+                source="${java.source}" target="${java.target}"
+                debug="true" extdirs=""
+                destdir="${out.classes.absolute.dir}"
+                bootclasspathref="android.target.classpath"
+                verbose="${verbose}"
+                classpath="${extensible.classpath}"
+                classpathref="android.libraries.jars">
+            <src path="${source.absolute.dir}" />
+            <src path="${gen.absolute.dir}" />
+            <src refid="android.libraries.src" />
+
+            <exclude name="**/handler/InformixDataHandler.java" unless="informix.present" />
+            <exclude name="**/handler/OracleDataHandler.java" unless="oracle.present" />
+
+            <classpath refid="main.classpath" />
+            <classpath>
+                <fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
+                <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
+            </classpath>
+        </javac>
+
+        <javac srcdir="${source.absolute.dir}/Lib"
+               includes="jxxload_help/**"
+               destdir="${out.classes.absolute.dir}"
+               target="${java.target}"
+               source="${java.source}"
+               debug="true"
+               deprecation="${deprecation}"
+               nowarn="${nowarn}"
+               verbose="${verbose}">
+            <compilerarg line="${javac.Xlint}"/>
+        </javac>
+
+        <copy file="${source.dir}/org/python/modules/ucnhash.dat"
+              todir="${out.classes.dir}/org/python/modules"
+              preservelastmodified="true" />
+
+        <copy todir="${out.classes.dir}" preservelastmodified="true">
+            <fileset dir="${source.dir}">
+                <include name="**/*.properties" />
+            </fileset>
+        </copy>
+        <!-- grammar must now be up to date -->
+        <property name="antlr.notneeded" value="true" />
+
+        <copy todir="${out.classes.dir}/META-INF/services">
+            <fileset dir="${source.dir}/META-INF/services" />
+        </copy>
+    </target>
+
     <!--
     If you run this before running regrtest, test__rawffi.py should pass.
     So far I have been unable to enable cpptasks without passing an arg to ant.
     -->
     <setup />
 
+    <!-- From https://code.google.com/p/android/issues/detail?id=13024 -->
+    <path id="android.libraries.src"><path refid="project.libraries.src" /></path>
+    <path id="android.libraries.jars"><path refid="project.libraries.jars" /></path>
+
 </project>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.