Skip to content

Commit

Permalink
Use the FirefoxOS's NDK instead of downloading it.
Browse files Browse the repository at this point in the history
Use the NDK that is provided by the FirefoxOS build (cloned from
git://android.git.linaro.org/platform/prebuilt) rather than downloading
it from
http://dl.google.com/android/ndk/android-ndk-r8-linux-x86.tar.bz2

The directories' layout is a bit different between both, so some minor
adjustments to cmake/toolchain/android.toolchain.cmake are necessary.
The default behavior is not changed.
  • Loading branch information
vasild committed Apr 9, 2013
1 parent 799b65c commit 91e28b5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
26 changes: 10 additions & 16 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# file), then the B2G build system will pick apitrace automatically and
# compile and install it into the system images seamlessly.
#
# This may work in other than FirefoxOS environments, but has not been tested.
#

LOCAL_PATH := $(call my-dir)

Expand All @@ -15,8 +17,8 @@ LOCAL_MODULE_TAGS := debug eng
include $(BUILD_SHARED_LIBRARY)

# Below we hook the whole process of configuring and compiling apitrace,
# described in INSTALL.markdown. We override the
# $(linked_module): targed, which is already defined by
# described in INSTALL.markdown (but we use the FirefoxOS's NDK). We override
# the $(linked_module): targed, which is already defined by
# $(BUILD_SHARED_LIBRARY) - by default it would want to compile the
# library out of some source files.
# We also override the target $(LOCAL_INSTALLED_MODULE): which installs
Expand All @@ -28,8 +30,6 @@ include $(BUILD_SHARED_LIBRARY)
MY_APITRACE_ROOT := $(TOPDIR)external/apitrace
MY_APITRACE_BUILD_ROOT_HOST := out/host/apitrace
MY_APITRACE_BUILD_ROOT_TARGET := out/target/apitrace
MY_APITRACE_NDK_BZ2 := android-ndk-r8-linux-x86.tar.bz2
MY_APITRACE_NDK := android-ndk-r8

apitrace_private_target:
$(hide) # apitrace: run cmake for the host if it has not been run
Expand All @@ -39,23 +39,17 @@ apitrace_private_target:
fi
$(hide) # apitrace: compile for the host
$(hide) make -C $(MY_APITRACE_BUILD_ROOT_HOST)
$(hide) # apitrace: download NDK archive if it is not present
$(hide) if [ ! -e $(MY_APITRACE_ROOT)/$(MY_APITRACE_NDK_BZ2) ] ; then \
cd $(MY_APITRACE_ROOT) && \
curl -O http://dl.google.com/android/ndk/$(MY_APITRACE_NDK_BZ2) ; \
fi
$(hide) # apitrace: extract NDK archive if it is not extracted
$(hide) if [ ! -e $(MY_APITRACE_ROOT)/$(MY_APITRACE_NDK) ] ; then \
cd $(MY_APITRACE_ROOT) && \
tar -jxf $(MY_APITRACE_NDK_BZ2) ; \
fi
$(hide) # apitrace: run cmake for android if it has not been run
$(hide) if [ ! -e $(MY_APITRACE_BUILD_ROOT_TARGET)/Makefile ] ; then \
cd $(MY_APITRACE_ROOT) && \
ANDROID_NDK=$(MY_APITRACE_NDK) \
NDK_LAYOUT_GIT=1 \
cmake \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/android.toolchain.cmake \
-DANDROID_API_LEVEL=9 -H. -B../../$(MY_APITRACE_BUILD_ROOT_TARGET) ; \
-DANDROID_NDK=$(TOPDIR)/prebuilt/ndk/android-ndk-r8 \
-DANDROID_API_LEVEL=9 \
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.4.x \
-DANDROID_NO_UNDEFINED=OFF \
-H. -B../../$(MY_APITRACE_BUILD_ROOT_TARGET) ; \
fi
$(hide) # apitrace: compile for android
$(hide) make -C $(MY_APITRACE_BUILD_ROOT_TARGET)
Expand Down
32 changes: 29 additions & 3 deletions cmake/toolchain/android.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,18 @@ macro( __COPY_IF_DIFFERENT _source _destination )
unset( __fileCopyProcess )
endmacro()

# If this variable is set, then the expected NDK layout is as in GIT (e.g.
# git://android.git.linaro.org/platform/prebuilt), rather than as in
# http://dl.google.com/android/ndk/android-ndk-r8-linux-x86.tar.bz2
# XXX For some reason defining the variable NDK_LAYOUT_GIT as a
# "cache variable" does not work as expected: on the second pass, it is
# always false/unset even if cmake is given -DNDK_LAYOUT_GIT:BOOL=TRUE
# on the command line. Thus we use $ENV{NDK_LAYOUT_GIT} in this file
# and execute like:
# NDK_LAYOUT_GIT=1 cmake ...
# instead of
# cmake -DNDK_LAYOUT_GIT:BOOL=TRUE ...
#set( NDK_LAYOUT_GIT FALSE CACHE BOOL "NDK layout as found in GIT")

# stl version: by default gnustl_static will be used
set( ANDROID_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static")
Expand Down Expand Up @@ -472,13 +484,23 @@ endif()
if( BUILD_WITH_ANDROID_NDK )
file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" )
string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
if( $ENV{NDK_LAYOUT_GIT} )
set( __toolchainsRoot "${ANDROID_NDK}/../../${ANDROID_NDK_HOST_SYSTEM_NAME}/toolchain" )
else()
set( __toolchainsRoot "${ANDROID_NDK}/toolchains" )
endif()
file( GLOB __availableToolchains RELATIVE "${__toolchainsRoot}" "${__toolchainsRoot}/*" )
__LIST_FILTER( __availableToolchains "^[.]" )
set( __availableToolchainMachines "" )
set( __availableToolchainArchs "" )
set( __availableToolchainCompilerVersions "" )
foreach( __toolchain ${__availableToolchains} )
__DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
if( $ENV{NDK_LAYOUT_GIT} )
set( __toolchainRoot "${__toolchainsRoot}/${__toolchain}" )
else()
set( __toolchainRoot "${__toolchainsRoot}/${__toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
endif()
__DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${__toolchainRoot}" )
if( __machine )
string( REGEX MATCH "[0-9]+[.][0-9]+[.]*[0-9]*$" __version "${__toolchain}" )
string( REGEX MATCH "^[^-]+" __arch "${__toolchain}" )
Expand Down Expand Up @@ -670,7 +692,11 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
set( __stlLibPath "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
endif()
if( BUILD_WITH_ANDROID_NDK )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
if( $ENV{NDK_LAYOUT_GIT} )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/../../${ANDROID_NDK_HOST_SYSTEM_NAME}/toolchain/${ANDROID_TOOLCHAIN_NAME}" )
else()
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
endif()
set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
if( ANDROID_USE_STLPORT )
set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" )
Expand Down

0 comments on commit 91e28b5

Please sign in to comment.