2015-02-16 02:25:54 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-09-05 21:40:44 +00:00
|
|
|
package_id="org.deadc0de.apple2ix.basic"
|
2015-03-10 20:15:36 +00:00
|
|
|
apple2_src_path=apple2ix-src
|
2015-06-26 04:32:37 +00:00
|
|
|
glue_srcs="$apple2_src_path/disk.c $apple2_src_path/misc.c $apple2_src_path/display.c $apple2_src_path/vm.c $apple2_src_path/cpu-supp.c $apple2_src_path/audio/speaker.c $apple2_src_path/audio/mockingboard.c"
|
2015-09-07 06:43:26 +00:00
|
|
|
target_arch=armeabi-v7a
|
2015-02-19 00:18:38 +00:00
|
|
|
|
|
|
|
usage() {
|
2015-09-19 06:05:04 +00:00
|
|
|
echo "$0 [--build-release] [--load] [--debug] [--armeabi | --armeabi-v7a]"
|
2015-02-19 00:18:38 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2015-10-04 18:02:57 +00:00
|
|
|
export EMBEDDED_STACKWALKER=1
|
|
|
|
|
2015-02-19 00:18:38 +00:00
|
|
|
while test "x$1" != "x"; do
|
|
|
|
case "$1" in
|
|
|
|
"--debug")
|
|
|
|
do_debug=1
|
|
|
|
;;
|
|
|
|
|
2015-09-19 06:05:04 +00:00
|
|
|
"--load")
|
|
|
|
do_load=1
|
2015-09-07 06:43:26 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
"--armeabi")
|
|
|
|
target_arch=armeabi
|
|
|
|
;;
|
|
|
|
|
|
|
|
"--v7a")
|
|
|
|
target_arch=armeabi-v7a
|
2015-02-19 00:18:38 +00:00
|
|
|
;;
|
|
|
|
|
2015-09-19 06:05:04 +00:00
|
|
|
"--build-release")
|
|
|
|
do_release=1
|
|
|
|
;;
|
|
|
|
|
2015-02-19 00:18:38 +00:00
|
|
|
"-h")
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
|
|
|
|
"--help")
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
|
2015-03-15 22:52:10 +00:00
|
|
|
*)
|
|
|
|
package_id=$1
|
|
|
|
;;
|
2015-02-19 00:18:38 +00:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
2015-02-16 02:25:54 +00:00
|
|
|
if test "$(basename $0)" = "clean" ; then
|
2015-09-07 06:43:26 +00:00
|
|
|
|
2015-02-16 02:25:54 +00:00
|
|
|
/bin/rm $apple2_src_path/rom.c
|
|
|
|
/bin/rm $apple2_src_path/font.c
|
|
|
|
/bin/rm $apple2_src_path/x86/glue.S
|
|
|
|
/bin/rm $apple2_src_path/arm/glue.S
|
2015-02-18 19:34:09 +00:00
|
|
|
|
2015-02-19 00:18:38 +00:00
|
|
|
# considered dangerous
|
|
|
|
/bin/rm -rf ../bin
|
|
|
|
/bin/rm -rf ../libs
|
|
|
|
/bin/rm -rf ../gen
|
|
|
|
/bin/rm -rf ../obj
|
2015-02-18 19:34:09 +00:00
|
|
|
|
2015-10-04 18:02:57 +00:00
|
|
|
ndk-build V=1 NDK_MODULE_PATH=. clean
|
2015-09-07 06:43:26 +00:00
|
|
|
##cd ..
|
|
|
|
##ant clean
|
|
|
|
|
2015-02-19 00:18:38 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2015-02-18 19:34:09 +00:00
|
|
|
|
2015-09-07 06:43:26 +00:00
|
|
|
/bin/rm Android.mk
|
|
|
|
|
2015-02-19 00:18:38 +00:00
|
|
|
if test "$(basename $0)" = "uninstall" ; then
|
|
|
|
adb uninstall $package_id
|
2015-02-16 02:25:54 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-09-19 06:05:04 +00:00
|
|
|
#CC=`which clang`
|
|
|
|
CC=`which gcc`
|
2015-02-16 02:25:54 +00:00
|
|
|
CFLAGS="-std=gnu11"
|
|
|
|
|
|
|
|
# ROMz
|
|
|
|
$CC $CFLAGS -o $apple2_src_path/genrom $apple2_src_path/genrom.c && \
|
|
|
|
$apple2_src_path/genrom $apple2_src_path/rom/apple_IIe.rom $apple2_src_path/rom/slot6.rom > $apple2_src_path/rom.c
|
|
|
|
|
|
|
|
# font
|
|
|
|
$CC $CFLAGS -o $apple2_src_path/genfont $apple2_src_path/genfont.c && \
|
|
|
|
$apple2_src_path/genfont < $apple2_src_path/font.txt > $apple2_src_path/font.c
|
|
|
|
|
|
|
|
# glue
|
|
|
|
$apple2_src_path/x86/genglue $glue_srcs > $apple2_src_path/x86/glue.S
|
|
|
|
$apple2_src_path/arm/genglue $glue_srcs > $apple2_src_path/arm/glue.S
|
|
|
|
|
2015-02-18 19:34:09 +00:00
|
|
|
if test "$(basename $0)" = "testcpu" ; then
|
|
|
|
ln -s testcpu.mk Android.mk
|
|
|
|
elif test "$(basename $0)" = "testvm" ; then
|
|
|
|
ln -s testvm.mk Android.mk
|
|
|
|
elif test "$(basename $0)" = "testdisplay" ; then
|
|
|
|
ln -s testdisplay.mk Android.mk
|
|
|
|
elif test "$(basename $0)" = "testdisk" ; then
|
|
|
|
ln -s testdisk.mk Android.mk
|
|
|
|
else
|
|
|
|
ln -s apple2ix.mk Android.mk
|
|
|
|
fi
|
2015-02-16 02:25:54 +00:00
|
|
|
|
2015-09-26 22:20:54 +00:00
|
|
|
###############################################################################
|
2015-09-07 06:43:26 +00:00
|
|
|
# build native sources
|
2015-09-19 06:05:04 +00:00
|
|
|
if test "x$do_release" = "x1" ; then
|
2015-10-04 18:02:57 +00:00
|
|
|
ndk-build V=1 NDK_MODULE_PATH=. # NDK_TOOLCHAIN_VERSION=clang
|
2015-09-19 06:05:04 +00:00
|
|
|
else
|
2015-10-04 18:02:57 +00:00
|
|
|
ndk-build V=1 NDK_MODULE_PATH=. NDK_DEBUG=1 # NDK_TOOLCHAIN_VERSION=clang
|
2015-09-19 06:05:04 +00:00
|
|
|
fi
|
2015-09-07 06:43:26 +00:00
|
|
|
ret=$?
|
|
|
|
if test "x$ret" != "x0" ; then
|
|
|
|
exit $ret
|
|
|
|
fi
|
|
|
|
|
2015-09-26 22:00:07 +00:00
|
|
|
###############################################################################
|
|
|
|
# Symbolicate and move symbols file into location to be deployed on device
|
|
|
|
|
|
|
|
SYMFILE=libapple2ix.so.sym
|
2015-11-10 06:19:52 +00:00
|
|
|
ARCHES_TO_SYMBOLICATE='armeabi armeabi-v7a x86'
|
2015-09-26 22:00:07 +00:00
|
|
|
|
|
|
|
for arch in $ARCHES_TO_SYMBOLICATE ; do
|
|
|
|
SYMDIR=../assets/symbols/$arch/libapple2ix.so
|
|
|
|
|
|
|
|
# remove old symbols (if any)
|
|
|
|
/bin/rm -rf $SYMDIR
|
|
|
|
|
|
|
|
# Run Breakpad's dump_syms
|
|
|
|
../../externals/bin/dump_syms ../obj/local/$arch/libapple2ix.so > $SYMFILE
|
|
|
|
|
|
|
|
ret=$?
|
|
|
|
if test "x$ret" != "x0" ; then
|
|
|
|
echo "OOPS, dump_syms failed for $arch"
|
|
|
|
exit $ret
|
|
|
|
fi
|
|
|
|
|
|
|
|
# strip to the just the numeric id in the .sym header and verify it makes sense
|
|
|
|
sym_id=$(head -1 $SYMFILE | cut -d ' ' -f 4)
|
|
|
|
sym_id_check=$(echo $sym_id | wc -c)
|
|
|
|
if test "x$sym_id_check" != "x34" ; then
|
|
|
|
echo "OOPS symbol header not expected size, meat-space intervention needed =P"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sym_id_check=$(echo $sym_id | tr -d 'A-Fa-f0-9' | wc -c)
|
|
|
|
if test "x$sym_id_check" != "x1" ; then
|
|
|
|
echo "OOPS unexpected characters in symbol header, meat-space intervention needed =P"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $SYMDIR/$sym_id
|
|
|
|
ret=$?
|
|
|
|
if test "x$ret" != "x0" ; then
|
|
|
|
echo "OOPS, could not create symbols directory for arch:$arch and sym_id:$sym_id"
|
|
|
|
exit $ret
|
|
|
|
fi
|
|
|
|
|
|
|
|
/bin/mv $SYMFILE $SYMDIR/$sym_id/
|
|
|
|
ret=$?
|
|
|
|
if test "x$ret" != "x0" ; then
|
|
|
|
echo "OOPS, could not move $SYMFILE to $SYMDIR/$sym_id/"
|
|
|
|
exit $ret
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
###############################################################################
|
2015-09-19 06:05:04 +00:00
|
|
|
# usually we should build the Java stuff from within Android Studio
|
2015-09-07 06:43:26 +00:00
|
|
|
if test "x$do_load" = "x1" ; then
|
|
|
|
ant -f ../build.xml debug install
|
|
|
|
ret=$?
|
|
|
|
if test "x$ret" != "x0" ; then
|
|
|
|
exit $ret
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-09-26 22:00:07 +00:00
|
|
|
###############################################################################
|
2015-09-07 06:43:26 +00:00
|
|
|
if test "x$do_debug" = "x1" ; then
|
|
|
|
cd ..
|
|
|
|
/bin/rm ./libs/gdbserver
|
|
|
|
/bin/ln -s $target_arch/gdbserver libs/gdbserver
|
|
|
|
##/bin/rm ./libs/gdb.setup
|
|
|
|
##/bin/ln -s $target_arch/gdb.setup libs/gdb.setup
|
2015-09-19 06:05:04 +00:00
|
|
|
##ndk-gdb --verbose --force --launch=org.deadc0de.apple2ix.Apple2Activity
|
|
|
|
ndk-gdb --nowait --verbose --force --launch=org.deadc0de.apple2ix.Apple2Activity
|
2015-09-07 06:43:26 +00:00
|
|
|
elif test "x$do_load" = "x1" ; then
|
|
|
|
adb shell am start -a android.intent.action.MAIN -n org.deadc0de.apple2ix.basic/org.deadc0de.apple2ix.Apple2Activity
|
|
|
|
fi
|
2015-02-18 19:34:09 +00:00
|
|
|
|
2015-02-16 02:25:54 +00:00
|
|
|
set +x
|
|
|
|
|