-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmake-project
executable file
·89 lines (76 loc) · 2.92 KB
/
make-project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
set -e
EXPECTED_ARGS=3
E_BADARGS=65
if [ $# -lt $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` android-platform project-name activity package-name"
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
PKG_PATH=$(echo $4 | sed -e "s:\.:/:g")
TARGET=$1
NAME=$2
ACTIVITY=$3
PKG=$4
android create project --target ${TARGET} --name ${NAME} --activity ${ACTIVITY} --path ${NAME} --package ${PKG} > /dev/null || (echo "Failed to create an android project! File a bug at github.com/abarbu/android-kawa" && exit 1)
rm -f ${NAME}/src/${PKG_PATH}/${ACTIVITY}.jar
touch ${NAME}/src/${PKG_PATH}/${ACTIVITY}.scm
ln -s `pwd`/kawa/kawa-1.*.jar ${NAME}/libs/kawa.jar
(cd ${NAME}; (patch -p0 <<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 ${PKG}. --warn-undefined-variable --module-static-run --warn-invoke-unknown-method --warn-as-error"/>
+ <arg value="-C"/>
+ <arg file="src/${PKG_PATH}/${ACTIVITY}.scm"/>
+<!-- <fileset dir=".">
+ <include name="**/*.scm"/>
+ </fileset>
+-->
+ </java>
+ </target>
+
</project>
EOF
) > /dev/null \
|| (echo "Failed to patch the build file! File a bug at github.com/abarbu/android-kawa" && exit 1))
echo "adb shell kill \$(adb shell ps|grep -i ${PKG}|awk '{ print $2 }') > /dev/null" > ${NAME}/make-and-send
echo "ant debug && adb install -r bin/${NAME}-debug.apk && adb shell am start -a android.intent.action.MAIN ${PKG}/.${ACTIVITY}" >> ${NAME}/make-and-send
chmod +x ${NAME}/make-and-send
cat > ${NAME}/src/${PKG_PATH}/${ACTIVITY}.scm <<EOF
(require 'android-defs)
(define-namespace Log "class:android.util.Log")
(activity ${ACTIVITY}
(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 ${NAME} && ./make-and-send\" to see it action. Sources are in ${PKG_PATH}/${ACTIVITY}.scm"