switch to clang

add option, and invoke it, to build jni code with clang rather than gcc.
This commit is contained in:
Eric House 2016-09-30 11:13:30 -07:00
parent a710bdd46e
commit abf4aa4d80
11 changed files with 52 additions and 28 deletions

View file

@ -92,10 +92,11 @@ LOCAL_LDLIBS := -L${SYSROOT}/usr/lib -llog -lz
include $(BUILD_SHARED_LIBRARY)
ifneq ($(shell which ccache),)
TARGET_CC = ccache $(TOOLCHAIN_PREFIX)gcc
TARGET_CXX = ccache $(TOOLCHAIN_PREFIX)g++
endif
# This recipe doesn't work with clang. Fix if using gcc again
# ifneq ($(shell which ccache),)
# TARGET_CC = ccache $(TOOLCHAIN_PREFIX)gcc
# TARGET_CXX = ccache $(TOOLCHAIN_PREFIX)g++
# endif
COMMON_SRC_FILES :=
COMMON_PATH :=

View file

@ -104,13 +104,13 @@ andCountSpecials( AndDictionaryCtxt* ctxt )
static XP_Bool
andMakeBitmap( AndDictionaryCtxt* ctxt, XP_U8 const** ptrp,
const XP_U8 const* end, XP_Bitmap* result )
const XP_U8* end, XP_Bitmap* result )
{
XP_Bool success = XP_TRUE;
XP_U8 const* ptr = *ptrp;
jobject bitmap = NULL;
CHECK_PTR( ptr, 1, end );
XP_U8 nCols = *ptr++;
jobject bitmap = NULL;
if ( nCols > 0 ) {
CHECK_PTR( ptr, 1, end );
XP_U8 nRows = *ptr++;
@ -157,7 +157,7 @@ andMakeBitmap( AndDictionaryCtxt* ctxt, XP_U8 const** ptrp,
static XP_Bool
andLoadSpecialData( AndDictionaryCtxt* ctxt, XP_U8 const** ptrp,
const XP_U8 const* end )
const XP_U8* end )
{
XP_Bool success = XP_TRUE;
XP_U16 nSpecials = andCountSpecials( ctxt );
@ -305,7 +305,7 @@ parseDict( AndDictionaryCtxt* ctxt, XP_U8 const* ptr, XP_U32 dictLength,
{
XP_Bool success = XP_TRUE;
XP_ASSERT( !!ptr );
const XP_U8 const* end = ptr + dictLength;
const XP_U8* end = ptr + dictLength;
XP_U32 offset;
XP_U16 nFaces, numFaceBytes = 0;
XP_U16 flags;

View file

@ -502,7 +502,7 @@ and_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
#ifdef XWFEATURE_CHAT
static void
and_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR const* msg, XP_S16 from )
and_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR* msg, XP_S16 from )
{
UTIL_CBK_HEADER( "showChat", "(Ljava/lang/String;ILjava/lang/String;)V" );
jstring jname = NULL;

View file

@ -9,9 +9,9 @@
<arg value="./local.properties" />
</exec>
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null"
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null"
failonerror="true" >
<arg value="${build.target}"/>
<arg value="--with-clang"/>
</exec>
</target>
@ -23,8 +23,8 @@
</exec>
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null"
failonerror="true">
<arg value="${build.target}"/>
failonerror="true" >
<arg value="--with-clang"/>
</exec>
<exec dir="." executable="../scripts/ndkbuild.sh" failonerror="true">

View file

@ -2,13 +2,34 @@
set -u -e
USE_CLANG=''
APPMK=./jni/Application.mk
TMP_MK=/tmp/tmp_$$_Application.mk
XWORDS_DEBUG_ARMONLY=${XWORDS_DEBUG_ARMONLY:-""}
XWORDS_DEBUG_X86ONLY=${XWORDS_DEBUG_X86ONLYx:-""}
usage() {
echo "usage $0 [--with-clang]"
exit 1
}
while [ $# -gt 0 ]; do
case $1 in
--with-clang)
USE_CLANG=1
;;
*)
usage "Unexpected param $1"
;;
esac
shift
done
echo "# Generated by $0; do not edit!!!" > $TMP_MK
[ -n "$USE_CLANG" ] && echo "NDK_TOOLCHAIN_VERSION := clang" >> $TMP_MK
if [ -n "$XWORDS_DEBUG_ARMONLY" ]; then
echo "APP_ABI := armeabi" >> $TMP_MK
elif [ -n "$XWORDS_DEBUG_X86ONLY" ]; then
@ -24,7 +45,7 @@ fi
if [ ! -f $APPMK ]; then
cp $TMP_MK $APPMK
elif ! diff $APPMK $TMP_MK; then
elif ! diff -q $APPMK $TMP_MK >/dev/null; then
cp $TMP_MK $APPMK
fi
rm -f $TMP_MK

View file

@ -835,7 +835,7 @@ board_canHint( const BoardCtxt* board )
}
void
board_sendChat( const BoardCtxt* board, const XP_UCHAR const* msg )
board_sendChat( const BoardCtxt* board, const XP_UCHAR* msg )
{
server_sendChat( board->server, msg, board->selPlayer );
}

View file

@ -133,7 +133,7 @@ XP_Bool board_canHideRack( const BoardCtxt* board );
XP_Bool board_canTrade( BoardCtxt* board );
XP_Bool board_canTogglePending( const BoardCtxt* board );
XP_Bool board_canHint( const BoardCtxt* board );
void board_sendChat( const BoardCtxt* board, const XP_UCHAR const* msg );
void board_sendChat( const BoardCtxt* board, const XP_UCHAR* msg );
/* zoomBy: >0: zoom in; < 0: zoom out; 0: query only */
XP_Bool board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canInOut );

View file

@ -514,9 +514,8 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
engine->searchHorizontal = XP_FALSE;
}
} /* forever */
outer:
result = result; /* c++ wants a statement after the label */
}
outer:
/* Search is finished. Choose (or just return) the best move found. */
if ( engine->returnNOW ) {
result = XP_FALSE;

View file

@ -784,11 +784,15 @@ wordScoreFormatterAddTile( WordScoreFormatter* fmtr, Tile tile,
}
fullBufPtr = fmtr->fullBuf + fmtr->bufLen;
fmtr->bufLen +=
XP_SNPRINTF( fullBufPtr,
(XP_U16)(sizeof(fmtr->fullBuf) - fmtr->bufLen),
(XP_UCHAR*)(tileMultiplier > 1?"%s(%dx%d)":"%s%d"),
prefix, tileScore, tileMultiplier );
XP_U16 len = sizeof(fmtr->fullBuf) - fmtr->bufLen;
if ( tileMultiplier > 1 ) {
fmtr->bufLen += XP_SNPRINTF( fullBufPtr, len,
"%s(%dx%d)", prefix, tileScore,
tileMultiplier );
} else {
fmtr->bufLen += XP_SNPRINTF( fullBufPtr, len,
"%s%d", prefix, tileScore );
}
XP_ASSERT( XP_STRLEN(fmtr->fullBuf) == fmtr->bufLen );
XP_ASSERT( fmtr->bufLen < sizeof(fmtr->fullBuf) );

View file

@ -636,7 +636,7 @@ server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream )
#ifdef XWFEATURE_CHAT
static void
sendChatTo( ServerCtxt* server, XP_U16 devIndex, const XP_UCHAR const* msg,
sendChatTo( ServerCtxt* server, XP_U16 devIndex, const XP_UCHAR* msg,
XP_S8 from )
{
if ( comms_canChat( server->vol.comms ) ) {
@ -652,7 +652,7 @@ sendChatTo( ServerCtxt* server, XP_U16 devIndex, const XP_UCHAR const* msg,
static void
sendChatToClientsExcept( ServerCtxt* server, XP_U16 skip,
const XP_UCHAR const* msg, XP_S8 from )
const XP_UCHAR* msg, XP_S8 from )
{
XP_U16 devIndex;
for ( devIndex = 1; devIndex < server->nv.nDevices; ++devIndex ) {
@ -663,7 +663,7 @@ sendChatToClientsExcept( ServerCtxt* server, XP_U16 skip,
}
void
server_sendChat( ServerCtxt* server, const XP_UCHAR const* msg, XP_S16 from )
server_sendChat( ServerCtxt* server, const XP_UCHAR* msg, XP_S16 from )
{
if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) {
sendChatTo( server, SERVER_DEVICE, msg, from );

View file

@ -122,8 +122,7 @@ XP_Bool server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream );
#endif
#ifdef XWFEATURE_CHAT
void server_sendChat( ServerCtxt* server, const XP_UCHAR const* msg,
XP_S16 from );
void server_sendChat( ServerCtxt* server, const XP_UCHAR* msg, XP_S16 from );
#endif
void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,