Support building Android version in release mode (without -g and with -DNDEBUG=1)

This commit is contained in:
Aaron Culliney 2016-01-03 13:59:52 -08:00
parent 64338d30c3
commit 0bb0df0960
7 changed files with 108 additions and 75 deletions

View File

@ -35,6 +35,12 @@ else
LOCAL_SRC_FILES += $(APPLE2_ARM_SRC)
endif
ifeq ($(BUILD_MODE),release)
LOCAL_CFLAGS += -DNDEBUG=1
else
LOCAL_CFLAGS += -g
endif
ifeq ($(EMBEDDED_STACKWALKER),1)
LOCAL_CPPFLAGS += -DEMBEDDED_STACKWALKER=1
else

View File

@ -12,7 +12,7 @@ usage() {
echo "$0"
echo " # uninstalls $package_id"
else
echo "$0 [build] [load|debug]"
echo "$0 [build|release] [load|debug]"
echo " # default builds $package_id and then load or debug"
fi
exit 0
@ -22,6 +22,14 @@ export EMBEDDED_STACKWALKER=1
while test "x$1" != "x"; do
case "$1" in
"build")
do_build=1
;;
"release")
do_release=1
;;
"debug")
do_debug=1
;;
@ -45,6 +53,11 @@ while test "x$1" != "x"; do
shift
done
if test "x$do_build" = "x1" -a "x$do_release" = "x1" ; then
echo "Must specify either build or release"
usage
fi
set -x
if test "$(basename $0)" = "clean" ; then
@ -74,22 +87,6 @@ if test "$(basename $0)" = "uninstall" ; then
exit 0
fi
#CC=`which clang`
CC=`which gcc`
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
if test "$(basename $0)" = "testcpu" ; then
ln -s testcpu.mk Android.mk
elif test "$(basename $0)" = "testvm" ; then
@ -104,61 +101,91 @@ fi
###############################################################################
# build native sources
ndk-build V=1 NDK_MODULE_PATH=. NDK_DEBUG=1 # NDK_TOOLCHAIN_VERSION=clang
ret=$?
if test "x$ret" != "x0" ; then
exit $ret
if test "x$do_build" = "x1" -o "x$do_release" = "x1" ; then
#CC=`which clang`
CC=`which gcc`
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
if test "x$do_build" = "x1" ; then
export BUILD_MODE=debug
ndk-build V=1 NDK_MODULE_PATH=. NDK_DEBUG=1 # NDK_TOOLCHAIN_VERSION=clang
ret=$?
if test "x$ret" != "x0" ; then
exit $ret
fi
else
export BUILD_MODE=release
ndk-build V=1 NDK_MODULE_PATH=. # NDK_TOOLCHAIN_VERSION=clang
ret=$?
if test "x$ret" != "x0" ; then
exit $ret
fi
fi
# Symbolicate and move symbols file into location to be deployed on device
SYMFILE=libapple2ix.so.sym
ARCHES_TO_SYMBOLICATE='armeabi armeabi-v7a x86'
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
fi
###############################################################################
# Symbolicate and move symbols file into location to be deployed on device
SYMFILE=libapple2ix.so.sym
ARCHES_TO_SYMBOLICATE='armeabi armeabi-v7a x86'
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
###############################################################################
# usually we should build the Java stuff from within Android Studio
if test "x$do_load" = "x1" ; then

View File

@ -39,7 +39,7 @@ APPLE2_MAIN_SRC = \
$(APPLE2_SRC_PATH)/interface.c $(APPLE2_SRC_PATH)/disk.c $(APPLE2_SRC_PATH)/cpu-supp.c \
jnihooks.c jniprefs.c androidkeys.c
APPLE2_OPTIM_CFLAGS := -g -O2
APPLE2_OPTIM_CFLAGS := -O2
APPLE2_BASE_CFLAGS := -DAPPLE2IX=1 -DINTERFACE_TOUCH=1 -DMOBILE_DEVICE=1 -DVIDEO_OPENGL=1 -DDEBUGGER=1 -DAUDIO_ENABLED=1 -std=gnu11 -DPREVENT_TEXTREL=1 -fPIC $(APPLE2_OPTIM_CFLAGS) -I$(APPLE2_SRC_PATH)
APPLE2_BASE_LDLIBS := -llog -landroid -lGLESv2 -lz -lOpenSLES

View File

@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
LOCAL_MODULE := libapple2ix
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testcpu.c
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -DTEST_CPU -DTESTING=1
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_CPU -DTESTING=1
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
# Add assembly files first ... mostly for the benefit of the ARM assembler ...

View File

@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
LOCAL_MODULE := libapple2ix
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testdisk.c
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -DTEST_DISK -DTESTING=1 -DDISK_TRACING=1
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_DISK -DTESTING=1 -DDISK_TRACING=1
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
# Add assembly files first ... mostly for the benefit of the ARM assembler ...

View File

@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
LOCAL_MODULE := libapple2ix
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testdisplay.c
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -DTEST_DISPLAY -DTESTING=1
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_DISPLAY -DTESTING=1
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
# Add assembly files first ... mostly for the benefit of the ARM assembler ...

View File

@ -12,7 +12,7 @@ include $(COMMON_SOURCES_MK)
LOCAL_MODULE := libapple2ix
LOCAL_SRC_FILES := $(APPLE2_SRC_PATH)/test/testcommon.c $(APPLE2_SRC_PATH)/test/testvm.c
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -DTEST_VM -DTESTING=1
LOCAL_CFLAGS := $(APPLE2_BASE_CFLAGS) -g -DTEST_VM -DTESTING=1
LOCAL_LDLIBS := $(APPLE2_BASE_LDLIBS)
# Add assembly files first ... mostly for the benefit of the ARM assembler ...