Skip to content

Commit

Permalink
Version - v1.2 (#7)
Browse files Browse the repository at this point in the history
* Main code update

* Add build.xml from mit-cml/extension-template

* Add libraries from mit-cml/extension-template

* Fix Errors

* Main code update - 2

* Remove GitHub Action

As version 1.2 switches to MIT's extension template, this action won't work anymore, so it is better to delete it for now.

* Make SetProperty block more stable

* Disable RemoveAll block for now
  • Loading branch information
ysfchn authored May 30, 2020
1 parent d9d58d9 commit 70cec20
Show file tree
Hide file tree
Showing 18 changed files with 946 additions and 163 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/build.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/*
out/*
203 changes: 203 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project name="" default="all">

<property name="Extensions.dir" location="out" />
<property name="AndroidRuntime-classes.dir" location="build/classes"/>
<property name="ExternalComponent.dir" location="build/externalComponents" />
<property name="ExternalComponent-class.dir" location="build/externalComponents-classes" />

<target name="all" depends="extensions">
</target>

<target name="clean">
<delete dir="build" />
<delete dir="out" />
</target>

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="lib/ant-contrib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>

<target name="javac">
<mkdir dir="${AndroidRuntime-classes.dir}" />
<depend srcdir="src" destdir="dest">
<include name="**/*.java" />
</depend>
<javac target="7" source="7" destdir="${AndroidRuntime-classes.dir}" srcdir="src" encoding="utf-8"
includeantruntime="false">
<classpath>
<pathelement location="lib/appinventor/AndroidRuntime.jar" />
<pathelement location="lib/appinventor/AnnotationProcessors.jar" />
<pathelement location="lib/kawa/kawa-1.11-modified.jar" />
<fileset dir="lib/android">
<include name="*.jar" />
</fileset>
<fileset dir="lib/deps">
<include name="*.jar" />
</fileset>
</classpath>
<include name="**/*.java" />
</javac>
</target>

<target name="process" depends="javac">
<mkdir dir="${Extensions.dir}" />
<mkdir dir="${ExternalComponent.dir}" />
<mkdir dir="${ExternalComponent-class.dir}" />
<java failonerror="true" classname="com.google.appinventor.components.scripts.ExternalComponentGenerator">
<classpath>
<pathelement location="lib/appinventor/AnnotationProcessors.jar" />
</classpath>
<arg path="${AndroidRuntime-classes.dir}/simple_components.json" />
<arg path="${AndroidRuntime-classes.dir}/simple_components_build_info.json" />
<arg path="${ExternalComponent.dir}" />
<arg path="${AndroidRuntime-classes.dir}" />
<arg path="lib/deps" />
<arg path="${ExternalComponent-class.dir}" />
<arg value="false" />
</java>
</target>

<!-- =====================================================================
unjarAllExtensionLibraries : Unjarring extension's library in order for the extensions'dex to work properly.
===================================================================== -->
<target name="unjarAllExtensionLibraries">
<foreach target="unjarExtensionLibraries" param="extension" inheritall="true">
<path>
<dirset dir="build/externalComponents-classes">
<include name="*" />
</dirset>
</path>
</foreach>
</target>

<target name="unjarExtensionLibraries">
<basename property="extensionClassFolder" file="${extension}" />
<unzip dest="build/externalComponents-classes/${extensionClassFolder}">
<fileset dir="build/externalComponents-classes/${extensionClassFolder}">
<include name="**/*.jar" />
</fileset>
</unzip>
</target>

<!-- =====================================================================
jarAllExtensions: create ${extension}.jar and AndroidRuntime.jar for each extension.
===================================================================== -->
<target name="jarAllExtensions" depends="process,unjarAllExtensionLibraries" >
<foreach target="jarExtension" param="extension" inheritall="true">
<path>
<dirset dir="${ExternalComponent-class.dir}">
<include name="*" />
</dirset>
</path>
</foreach>
</target>

<target name="jarExtension">
<basename property="extensionClassFolder" file="${extension}" />
<jar destfile="${ExternalComponent-class.dir}/${extensionClassFolder}.jar"
basedir="${ExternalComponent-class.dir}/${extensionClassFolder}"
includes="**/*.class"
excludes="*.jar" />
<antcall target="ProGuard">
<param name="extensionClassFolder" value="${extensionClassFolder}" />
</antcall>
<copy file="${ExternalComponent-class.dir}/${extensionClassFolder}.jar"
tofile="${ExternalComponent.dir}/${extensionClassFolder}/files/AndroidRuntime.jar"/>
<echo>Generated build file AndroidRuntime.jar [${extensionClassFolder}]</echo>
</target>

<!-- =====================================================================
dexAllExtensions: create classes.dex for each extension.
===================================================================== -->
<target name="dexAllExtensions" depends="jarAllExtensions">
<foreach target="dexExtension" param="extension">
<path>
<fileset dir="${ExternalComponent-class.dir}" >
<include name="*.jar"/>
</fileset>
</path>
</foreach>
</target>

<target name="dexExtension" depends="">
<basename property="extensionType" file="${extension}" suffix=".jar"/>
<java jar="lib/android/dx.jar"
fork="true"
failonerror="true">
<arg value="--dex"/>
<arg value="--no-strict"/>
<arg value="--output"/>
<arg value="${ExternalComponent.dir}/${extensionType}/classes.jar"/>
<arg value="${ExternalComponent-class.dir}/${extensionType}.jar"/>
</java>
<echo>Dexing extension: ${extensionType}</echo>
</target>



<!-- =====================================================================
extensions: create ${extension}.aix for each external component.
===================================================================== -->
<target name="packExtension">
<basename property="extensionType" file="${extension}" />
<zip destfile="${Extensions.dir}/${extensionType}.aix"
basedir="${ExternalComponent.dir}"
includes="${extensionType}/"
/>
</target>

<target name="extensions" depends="jarAllExtensions, dexAllExtensions">
<mkdir dir="${Extensions.dir}" />
<foreach target="packExtension" param="extension" inheritall="true">
<path>
<dirset dir="${ExternalComponent.dir}">
<include name="*" />
</dirset>
</path>
</foreach>
</target>

<!-- =====================================================================
ProGuard: obfuscates and minifies the AndroidRuntime.jar file, containing
the extensions source code. Only runs if the task has been called
like "ant extensions -Dproguard=1".
===================================================================== -->

<condition property="skipProguard">
<not>
<equals arg1="${proguard}" arg2="1" />
</not>
</condition>

<target name="ProGuard" unless="skipProguard">
<taskdef resource="proguard/ant/task.properties"
classpath="lib/proguard/proguard.jar" />
<proguard printmapping="out/${extensionClassFolder}-proguard.map"
overloadaggressively="on"
configuration="lib/proguard/proguard.cfg"
ignorewarnings="false">

<injar file="${ExternalComponent-class.dir}/${extensionClassFolder}.jar" />
<outjar file="${ExternalComponent-class.dir}/${extensionClassFolder}_p.jar" />

<libraryjar>
<fileset dir="lib">
<include name="**/*.jar"/>
<include name="**/*.aar"/>
<exclude name="*/dx.jar"/>
</fileset>
</libraryjar>

<dontnote filter="proguard.configuration.ConfigurationLogger" />
<adaptresourcefilecontents filter="proguard/ant/task.properties" />
</proguard>

<delete file="${ExternalComponent-class.dir}/${extensionClassFolder}.jar" />
<move file="${ExternalComponent-class.dir}/${extensionClassFolder}_p.jar"
tofile="${ExternalComponent-class.dir}/${extensionClassFolder}.jar" />
</target>

</project>
Binary file added lib/android/android.jar
Binary file not shown.
Binary file added lib/android/appcompat-v7-28.0.0.jar
Binary file not shown.
Binary file added lib/android/dx.jar
Binary file not shown.
Binary file added lib/ant-contrib/ant-contrib-1.0b3.jar
Binary file not shown.
Binary file added lib/appinventor/AndroidRuntime.jar
Binary file not shown.
Binary file added lib/appinventor/AnnotationProcessors.jar
Binary file not shown.
1 change: 1 addition & 0 deletions lib/deps/.placeholder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Any external dependencies should be placed in this directory.
106 changes: 106 additions & 0 deletions lib/kawa/kawa-1.11-changes.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
==== gnu/bytecode/ObjectType.java#1 - gnu/bytecode/ObjectType.java#2 ====
45c45,49
< return t.isExisting();
---
> // start Google
> return ! (t instanceof ObjectType) || ((ObjectType) t).isExisting();
> // instead of
> // return t.isExisting();
> // end Google
89a94,100
> // start Google
> try
> {
> return Class.forName(cname, false, ObjectType.class.getClassLoader());
> }
> catch (java.lang.ClassNotFoundException ex)
> {
90a102,105
> }
> // instead of
> // return Class.forName(cname, false, getContextClassLoader());
> // end Google
171a187
> // if Google
172a189
> // end Google
176c193,197
< return getMethods(filter, searchSupers, result);
---
> // if Google
> return Type.objectType.getMethods(filter, searchSupers, result, context);
> // instead of
> // return getMethods(filter, searchSupers, result);
> // end Google
==== gnu/expr/Compilation.java#1 - gnu/expr/Compilation.java#2 ====
2444,2445c2444,2446
< if (! mustCompile && ! ModuleExp.compilerAvailable)
< error('e', "this expression must be compiled, but compiler is unavailable");
---
> if (! mustCompile && ! ModuleExp.compilerAvailable) {
> error('w', "this expression claimed that it must be compiled, but compiler is unavailable");
> } else {
2447a2449
> }
==== gnu/expr/ModuleExp.java#1 - gnu/expr/ModuleExp.java#2 ====
174a175,190
> // start Google
> /** Flag to force no compilation */
> public static boolean neverCompile = false;
>
> public static void mustNeverCompile() {
> alwaysCompile = false;
> neverCompile = true;
> compilerAvailable = false;
> }
>
> public static void mustAlwaysCompile() {
> alwaysCompile = true;
> neverCompile = false;
> }
> // end Google
>
204a221,234
>
> // if Google -- NOTE: EVERYTHING FAILS IF THESE ENABLED
> // alwaysCompile = false;
> // neverCompile = true;
> // compilerAvailable = false;
>
> if (alwaysCompile && neverCompile)
> {
> throw new RuntimeException("alwaysCompile and neverCompile are both true!");
> }
> if (neverCompile)
> comp.mustCompile = false;
> // end Google
>
212a243,246
> // if Google
> // if (! alwaysCompile && ! comp.mustCompile)
> // { // optimization - don't generate unneeded Class.
> // instead of
214a249
> // end Google
244c279
< return null;
---
> return false;
273c308
< if (inst instanceof Class)
---
> if (inst instanceof Class) {
275c310
<
---
> }
==== gnu/text/Path.java#1 - gnu/text/Path.java#2 ====
13c13
< implements javax.tools.FileObject
---
> // implements javax.tools.FileObject
==== kawa/Version.java#1 - kawa/Version.java#2 ====
5c5
< return "1.11 (revision 6811M)";
---
> return "1.11";
Binary file added lib/kawa/kawa-1.11-modified.jar
Binary file not shown.
Loading

0 comments on commit 70cec20

Please sign in to comment.