Skip to content

Commit

Permalink
Much simpler project management and setup. Scripts to do everything.
Browse files Browse the repository at this point in the history
bugfix for the latest kawa svn, run dx --no-locals.
  • Loading branch information
abarbu committed Dec 7, 2012
1 parent e55bd00 commit 5377ff9
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 60 deletions.
2 changes: 1 addition & 1 deletion KawaHello/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<import file="${sdk.dir}/tools/ant/build.xml" />

<target name="-dex" depends="-compile,scompile">
<dex-helper />
<dex-helper nolocals="true"/>
</target>

<!-- Compile this project's .scm files into .class files. -->
Expand Down
Empty file modified KawaHello/make-and-send
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion LearningAndroid-chapter10/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in order to avoid having your file be overridden by tools such as "android updat
<import file="${sdk.dir}/tools/ant/build.xml" />

<target name="-dex" depends="-compile,scompile">
<dex-helper />
<dex-helper nolocals="true"/>
</target>

<property name="out.classes.dir" value="${out.dir}/classes" />
Expand Down
Empty file modified LearningAndroid-chapter10/make-and-send
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion LearningAndroid-chapter6/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in order to avoid having your file be overridden by tools such as "android updat
<import file="${sdk.dir}/tools/ant/build.xml" />

<target name="-dex" depends="-compile,scompile">
<dex-helper />
<dex-helper nolocals="true"/>
</target>

<property name="out.classes.dir" value="${out.dir}/classes" />
Expand Down
Empty file modified LearningAndroid-chapter6/make-and-send
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion LearningAndroid-chapter7/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in order to avoid having your file be overridden by tools such as "android updat
<import file="${sdk.dir}/tools/ant/build.xml" />

<target name="-dex" depends="-compile,scompile">
<dex-helper />
<dex-helper nolocals="true"/>
</target>

<property name="out.classes.dir" value="${out.dir}/classes" />
Expand Down
Empty file modified LearningAndroid-chapter7/make-and-send
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion LearningAndroid-chapter8/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in order to avoid having your file be overridden by tools such as "android updat
<import file="${sdk.dir}/tools/ant/build.xml" />

<target name="-dex" depends="-compile,scompile">
<dex-helper />
<dex-helper nolocals="true"/>
</target>

<property name="out.classes.dir" value="${out.dir}/classes" />
Expand Down
Empty file modified LearningAndroid-chapter8/make-and-send
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion LearningAndroid-chapter9/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in order to avoid having your file be overridden by tools such as "android updat
<import file="${sdk.dir}/tools/ant/build.xml" />

<target name="-dex" depends="-compile,scompile">
<dex-helper />
<dex-helper nolocals="true"/>
</target>

<property name="out.classes.dir" value="${out.dir}/classes" />
Expand Down
Empty file modified LearningAndroid-chapter9/make-and-send
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion LunarLander/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<import file="${sdk.dir}/tools/ant/build.xml" />

<target name="-dex" depends="compile,scompile">
<dex-helper />
<dex-helper nolocals="true"/>
</target>

<!-- Compile this project's .scm files into .class files. -->
Expand Down
Empty file modified LunarLander/make-and-send
100644 → 100755
Empty file.
38 changes: 21 additions & 17 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,38 @@
Android"

These were written while I was figuring out if Kawa can be used for
Android development, and how one might do so as there are few examples
of this and many Android&Kawa-specific quirks to figure out. All
examples try to mostly stay true to their source however badly
designed that source was. As such this isn't a good place to look for
good Scheme style or idiomatic Kawa.
Android development and how to work out various Android&Kawa-specific
quirks. All examples try to mostly stay true to their source however
badly designed that source was. As such this isn't a good place to
look for good Scheme style or idiomatic Kawa.

To get started you'll need a custom build for Kawa:
To get started you'll need a custom build for Kawa, this will fetch
the latest svn sources
#+BEGIN_SRC sh
svn -q checkout svn://sourceware.org/svn/kawa/trunk kawa
./configure --with-android=$ANDROID_HOME/platforms/$ANDROID_PLATFORM/android.jar --disable-xquery --disable-jemacs
bin/setup-kawa
#+END_SRC
and to get the examples to work you need to set them up
#+BEGIN_SRC sh
bin/setup-examples
#+END_SRC
and you will need to place kawa-1.11.jar in the libs/ directory in for each of the examples.

To create a new project you can use:
#+BEGIN_SRC sh
android create project --target $ANDROID_PLATFORM --name $PROJECT --activity $ACTIVITY --path $PROJECT --package kawa.android
cd $PROJECT
rm $PROJECT/src/kawa/android/$ACTIVITY.jar
touch $PROJECT/src/kawa/android/$ACTIVITY.scm
ln -s $KAWA_INSTALL_DIR/kawa-1.11.jar $PROJECT/libs/kawa.jar
(cd $PROJECT; patch < ../build-xml.patch)
bin/make-project android-14 HelloWorld hello
#+END_SRC
the arguments are: the platform/api level, the project name and the
original activity name. This calls 'android create project' and
patches the resulting build.xml file. It will create a trivial
application that displays a message. Sources are in
<project-name>/src/kawa/android/<activity>.scm.

The resulting directory contains a make-and-send script which builds
the project, uploads it to the emulator or to the phone and starts it
up.

You may need to update local.properties in each of the examples
directory to change the path to the SDK.

Each directory contains a simple make-and-send script which builds the project, uploads it to the emulator and starts it up.

This has been tested with Android SDK r15.

LearningAndroid examples need to a copy of jtwitter.jar and
Expand Down
85 changes: 79 additions & 6 deletions bin/make-project
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,80 @@
android create project --target $ANDROID_PLATFORM --name KawaHello --activity hello --path KawaHello --package kawa.android
cd KawaHello
rm KawaHello/src/kawa/android/hello.jar
touch KawaHello/src/kawa/android/hello.scm
ln -s kawa/kawa-1.11.jar KawaHello/libs/kawa.jar
(cd KawaHello; patch < ../build-xml.patch)
#!/bin/bash

EXPECTED_ARGS=3
E_BADARGS=65

if [ $# -lt $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` android-platform project-name activity"
echo "Setups a new Android project with Kawa."
echo " Kawa should exist in the kawa/ directory as set up by bin/setup-kawa"
echo " bin/make-project android-14 KawaHello2 hello"
exit $E_BADARGS
fi

if [ ! -d kawa ]; then
echo "Error: Kawa should exist in the kawa/ directory as set up by bin/setup-kawa."
exit 1;
fi

if [ -d $2 ]; then
echo "Error: $2 already exists. You can't create a new project into an existing directory."
exit 1;
fi

android create project --target $1 --name $2 --activity $3 --path $2 --package kawa.android
rm -f $2/src/kawa/android/$3.jar
touch $2/src/kawa/android/$3.scm
ln -s `pwd`/kawa/kawa-1.*.jar $2/libs/kawa.jar

cat > $2/build.xml.patch <<EOF
--- build.xml.orig 2010-10-11 15:48:59.092681778 -0700
+++ build.xml 2010-11-04 22:26:34.565673740 -0700
@@ -64,4 +64,27 @@
-->
<setup />
+ <target name="-dex" depends="-compile,scompile">
+ <dex-helper nolocals="true"/>
+ </target>
+
+ <!-- Compile this project's .scm files into .class files. -->
+ <target name="scompile" depends="-code-gen">
+ <java failonerror="true" fork="true" classname="kawa.repl">
+ <classpath>
+ <pathelement path="libs/kawa.jar"/>
+ <pathelement path="\${sdk.dir}/platforms/\${target}/android.jar"/>
+ <pathelement path="\${out.classes.absolute.dir}"/>
+ </classpath>
+ <arg value="-d"/> <arg path="\${out.classes.absolute.dir}"/>
+ <arg line="-P kawa.android. --warn-undefined-variable --module-static-run --warn-invoke-unknown-method --warn-as-error"/>
+ <arg value="-C"/>
+ <arg file="src/kawa/android/$3.scm"/>
+<!-- <fileset dir=".">
+ <include name="**/*.scm"/>
+ </fileset>
+-->
+ </java>
+ </target>
+
</project>
EOF

(cd $2; patch < build.xml.patch)
echo 'adb shell kill $(adb shell ps|grep -i kawa.android|awk '"'"'{ print $2 }'"') > /dev/null" > $2/make-and-send
echo "ant debug && adb install -r bin/$2-debug.apk && adb shell am start -a android.intent.action.MAIN kawa.android/.$3" >> $2/make-and-send

cat > $2/src/kawa/android/$3.scm <<EOF
(require 'android-defs)
(define-namespace Log "class:android.util.Log")
(activity $3
(on-create-view
(Log:i "kawa" "Just letting you know we're alive.")
(android.widget.TextView
(this)
text: "Hello from Kawa Scheme!")))
EOF

echo "Done! Use \"cd $2 && ./make-and-send\" to see it action. Sources are in kawa/android/$3.scm"
14 changes: 14 additions & 0 deletions bin/setup-examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ ! -d kawa ]; then
echo "Error: Kawa should exist in the kawa/ directory as set up by bin/setup-kawa."
exit 1;
fi

ln -s `pwd`/kawa/kawa-1.*.jar KawaHello/libs/kawa.jar
ln -s `pwd`/kawa/kawa-1.*.jar LearningAndroid-chapter10/libs/kawa.jar
ln -s `pwd`/kawa/kawa-1.*.jar LearningAndroid-chapter6/libs/kawa.jar
ln -s `pwd`/kawa/kawa-1.*.jar LearningAndroid-chapter7/libs/kawa.jar
ln -s `pwd`/kawa/kawa-1.*.jar LearningAndroid-chapter8/libs/kawa.jar
ln -s `pwd`/kawa/kawa-1.*.jar LearningAndroid-chapter9/libs/kawa.jar
ln -s `pwd`/kawa/kawa-1.*.jar LunarLander/libs/kawa.jar
19 changes: 19 additions & 0 deletions bin/setup-kawa
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

EXPECTED_ARGS=2
E_BADARGS=65

if [ $# -lt $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` android-home android-platform"
echo " Setup a Kawa install in the current directory for a particular Android version."
echo " for example: bin/setup-kawa /opt/android-sdk-update-manager android-14"
exit $E_BADARGS
fi

svn -q checkout svn://sourceware.org/svn/kawa/trunk kawa
cd kawa
./configure --with-android=$ANDROID_HOME/platforms/$ANDROID_PLATFORM/android.jar --disable-xquery --disable-jemacs
# Because kawa docs sometimes fail to build.
echo '' > doc/kawa.texi
make
30 changes: 0 additions & 30 deletions build-xml.patch

This file was deleted.

0 comments on commit 5377ff9

Please sign in to comment.