Commit a775f553 authored by David 'Digit' Turner's avatar David 'Digit' Turner
Browse files

Allow platforms and samples to be located under development/ndk/{platforms,samples}

Change-Id: Idb631a91de71c60dc6edc7d1989925fff9adc1aa
parent 09c4bfe0
......@@ -302,6 +302,13 @@ modules-closure = \
#
# =============================================================================
# -----------------------------------------------------------------------------
# Function : parent-dir
# Arguments: 1: path
# Returns : Parent dir or path of $1, with final separator removed.
# -----------------------------------------------------------------------------
parent-dir = $(patsubst %/,%,$(dir $1))
# -----------------------------------------------------------------------------
# Function : check-user-define
# Arguments: 1: name of variable that must be defined by the user
......@@ -357,7 +364,7 @@ check-LOCAL_MODULE = \
# Returns : the directory of the current Makefile
# Usage : $(my-dir)
# -----------------------------------------------------------------------------
my-dir = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
my-dir = $(call parent-dir,$(lastword $(MAKEFILE_LIST)))
# -----------------------------------------------------------------------------
# Function : all-makefiles-under
......
......@@ -263,7 +263,34 @@ $(foreach tc,$(NDK_ALL_TOOLCHAINS),\
#
# ====================================================================
NDK_PLATFORMS_ROOT := $(NDK_ROOT)/build/platforms
# The platform files were moved in the Android source tree from
# $TOP/ndk/build/platforms to $TOP/development/ndk/platforms. However,
# the official NDK release packages still place them under the old
# location for now, so deal with this here
#
NDK_PLATFORMS_ROOT := $(strip $(NDK_PLATFORMS_ROOT))
ifndef NDK_PLATFORMS_ROOT
NDK_PLATFORMS_ROOT := $(strip $(wildcard $(NDK_ROOT)/build/platforms))
ifndef NDK_PLATFORMS_ROOT
NDK_PLATFORMS_ROOT := $(strip $(wildcard $(call parent-dir,$(NDK_ROOT))/development/ndk/platforms))
endif
ifndef NDK_PLATFORMS_ROOT
$(call __ndk_info,Could not find platform files (headers and libraries))
$(call __ndk_info,Please define NDK_PLATFORMS_ROOT to point to a valid)
$(call __ndk_info,root directory for these.)
$(call __ndk_error,Aborting)
endif
$(call ndk_log,Found platform root directory: $(NDK_PLATFORMS_ROOT))
else
ifeq ($(strip $(wildcard $(NDK_PLATFORMS_ROOT)/android-*)),)
$(call __ndk_info,Your NDK_PLATFORMS_ROOT points to an invalid directory)
$(call __ndk_info,Current value: $(NDK_PLATFORMS_ROOT))
$(call __ndk_error,Aborting)
endif
endif
NDK_ALL_PLATFORMS := $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/android-*)))
$(call ndk_log,Found supported platforms: $(NDK_ALL_PLATFORMS))
......
......@@ -44,6 +44,18 @@ PREBUILT_NDK=
# be copied into the archive.
USE_GIT_FILES=yes
# Find the location of the platforms root directory
PLATFORMS_ROOT=$NDK_ROOT_DIR/build/platforms
if [ ! -d $PLATFORMS_ROOT ] ; then
PLATFORMS_ROOT=`dirname $NDK_ROOT_DIR`/development/ndk/platforms
fi
# Find the location of the samples
SAMPLES_ROOT=$NDK_ROOT_DIR/samples
if [ ! -d $SAMPLES_ROOT ] ; then
SAMPLES_ROOT=`dirname $NDK_ROOT_DIR`/development/ndk/samples
fi
OPTION_HELP=no
for opt do
......@@ -70,6 +82,10 @@ for opt do
;;
--no-git) USE_GIT_FILES=no
;;
--platforms-root=*) PLATFORMS_ROOT=$optarg
;;
--samples-root=*) SAMPLES_ROOT=$optarg
;;
*)
echo "unknown option '$opt', use --help"
exit 1
......@@ -106,6 +122,8 @@ if [ $OPTION_HELP = yes ] ; then
echo " --prebuilt-ndk=FILE Specify a previous NDK package [$PREBUILT_NDK]"
echo " --systems=SYSTEMS List of host system packages [$PREBUILT_SYSTEMS]"
echo " --no-git Don't use git to list input files, take all of them."
echo " --platforms-root=PATH Specify platforms root directory [$PLATFORMS_ROOT]"
echo " --samples-root=PATH Specify samples root directory [$SAMPLES_ROOT]"
echo ""
exit 1
fi
......@@ -195,6 +213,29 @@ if [ $? != 0 ] ; then
exit 2
fi
# copy platform files if needed
echo "Copying platform files"
if [ ! -d $REFERENCE/build/platforms ] ; then
echo "REF=$REFERENCE/build/platforms"
mkdir -p $REFERENCE/build/platforms &&
(cd $PLATFORMS_ROOT && tar cf - android-*) | (cd $REFERENCE/build/platforms && tar xf -)
if [ $? != 0 ] ; then
echo "Could not copy platform files. Aborting."
exit 2
fi
fi
# copy sample files if needed
echo "Copying samples"
if [ ! -d $REFERENCE/samples ] ; then
mkdir -p $REFERENCE/samples &&
(cd $SAMPLES_ROOT && tar cf - *) | (cd $REFERENCE/samples && tar xf -)
if [ $? != 0 ] ; then
echo "Could not copy samples. Aborting."
exit 2
fi
fi
# now, for each system, create a package
#
for SYSTEM in $PREBUILT_SYSTEMS; do
......
......@@ -327,6 +327,22 @@ fix_option ()
fi
}
# If SYSROOT is empty, check that $1/$2 contains a sysroot
# and set the variable to it.
#
# $1: sysroot path
# $2: platform/arch suffix
check_sysroot ()
{
if [ -z "$SYSROOT" ] ; then
log "Probing directory for sysroot: $1/$2"
if [ -d $1/$2 ] ; then
SYSROOT=$1/$2
fi
fi
}
# Determine sysroot
# $1: Option value (or empty)
#
......@@ -336,13 +352,16 @@ fix_sysroot ()
eval SYSROOT="$1"
log "Using specified sysroot: $1"
else
SYSROOT_SUFFIX=build/platforms/$PLATFORM/arch-$ARCH
if [ -d $NDK_DIR/$SYSROOT_SUFFIX ] ; then
SYSROOT=$NDK_DIR/$SYSROOT_SUFFIX
log "Using target NDK sysroot: $SYSROOT"
else
SYSROOT=$ANDROID_NDK_ROOT/$SYSROOT_SUFFIX
log "Using install NDK sysroot: $SYSROOT"
SYSROOT_SUFFIX=$PLATFORM/arch-$ARCH
SYSROOT=
check_sysroot $NDK_DIR/build/platforms $SYSROOT_SUFFIX
check_sysroot $ANDROID_NDK_ROOT/build/platforms $SYSROOT_SUFFIX
check_sysroot `dirname $ANDROID_NDK_ROOT`/development/ndk/platforms $SYSROOT_SUFFIX
if [ -z "$SYSROOT" ] ; then
echo "ERROR: Could not find NDK sysroot path for $SYSROOT_SUFFIX."
echo " Use --sysroot=<path> to specify one."
exit 1
fi
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment