aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2011-09-14 14:30:51 +0200
committerDavid 'Digit' Turner <digit@google.com>2011-09-21 17:14:27 +0200
commit5edfe75d8ad0f19be9d05908822ed47628ba80ba (patch)
tree73794e54d175c051e54e55e1c346aa97979ae095
parent8d06600aad07ddf7b6f80c0242269e0e44b3d99a (diff)
downloadndk-5edfe75d8ad0f19be9d05908822ed47628ba80ba.tar.gz
Allow imported shared libraries to be installed by default.
This patch ensures that imported shared libraries are now copied to the install location (libs/<abi>) by default. Previously, one had to list them explicitely in APP_MODULES to do that (only top-level project modules were installed). Change-Id: I5a8628d2246d1ce4b4a8a56970fda64541bf3f19
-rw-r--r--build/core/definitions.mk24
-rw-r--r--build/core/setup-toolchain.mk3
-rw-r--r--docs/CHANGES.html14
-rw-r--r--tests/build/import-install/README3
-rwxr-xr-xtests/build/import-install/build.sh41
-rw-r--r--tests/build/import-install/jni/Android.mk10
-rw-r--r--tests/build/import-install/jni/Application.mk1
-rw-r--r--tests/build/import-install/jni/main.c7
-rw-r--r--tests/build/import-install/path1/Android.mk14
-rw-r--r--tests/build/import-install/path1/path1.c8
-rw-r--r--tests/build/import-install/path1/path1.h4
-rw-r--r--tests/build/import-install/path2/Android.mk10
-rw-r--r--tests/build/import-install/path2/path2.c7
-rw-r--r--tests/build/import-install/path2/path2.h4
-rwxr-xr-xtests/build/multi-module-path/build.sh2
-rwxr-xr-xtests/run-tests.sh1
16 files changed, 147 insertions, 6 deletions
diff --git a/build/core/definitions.mk b/build/core/definitions.mk
index 8e23e3725..6e4405273 100644
--- a/build/core/definitions.mk
+++ b/build/core/definitions.mk
@@ -463,11 +463,11 @@ module-get-installed = $(__ndk_modules.$1.INSTALLED)
# Usage : $(call modules-all-get-dependencies,<list of module names>)
# Rationale: This computes the closure of all module dependencies starting from $1
# -----------------------------------------------------------------------------
-module-get-all-dependencies = \
- $(strip $(call modules-get-closure,$1,depends))
+module-get-all-dependencies = $(strip \
+ $(call modules-get-closure,$1,depends))
modules-get-closure = \
- $(eval __closure_deps := $(strip $1)) \
+ $(eval __closure_deps := $(strip $(call strip-lib-prefix,$1))) \
$(eval __closure_wq := $(__closure_deps)) \
$(eval __closure_field := $(strip $2)) \
$(call modules-closure)\
@@ -481,11 +481,27 @@ modules-get-closure = \
modules-closure = \
$(eval __closure_mod := $(call first,$(__closure_wq))) \
$(eval __closure_wq := $(call rest,$(__closure_wq))) \
- $(eval __closure_new := $(filter-out $(__closure_deps),$(__ndk_modules.$(__closure_mod).$(__closure_field))))\
+ $(eval __closure_val := $(call strip-lib-prefix,$(__ndk_modules.$(__closure_mod).$(__closure_field)))) \
+ $(eval __closure_new := $(filter-out $(__closure_deps),$(__closure_val)))\
$(eval __closure_deps += $(__closure_new)) \
$(eval __closure_wq := $(strip $(__closure_wq) $(__closure_new)))\
$(if $(__closure_wq),$(call modules-closure)) \
+# -----------------------------------------------------------------------------
+# Function : modules-get-all-installable
+# Arguments: 1: list of module names
+# Returns : List of all the installable modules $1 depends on transitively.
+# Usage : $(call modules-all-get-installable,<list of module names>)
+# Rationale: This computes the closure of all installable module dependencies starting from $1
+# -----------------------------------------------------------------------------
+
+# For now, only the closure of LOCAL_SHARED_LIBRARIES is enough
+modules-get-all-installable = $(strip \
+ $(call map,strip-lib-prefix,\
+ $(call modules-get-closure,$1,SHARED_LIBRARIES)\
+ )\
+ )
+
# Return the C++ extension of a given module
#
module-get-cpp-extension = $(strip \
diff --git a/build/core/setup-toolchain.mk b/build/core/setup-toolchain.mk
index 1b453f511..1579abb6c 100644
--- a/build/core/setup-toolchain.mk
+++ b/build/core/setup-toolchain.mk
@@ -166,9 +166,10 @@ $(foreach __pass2_module,$(__ndk_modules),\
#
# If APP_MODULES is not defined in the Application.mk, we
# will build all modules that were listed from the top-level Android.mk
+# and the installable imported ones they depend on
#
ifeq ($(strip $(NDK_APP_MODULES)),)
- WANTED_MODULES := $(call modules-get-top-list)
+ WANTED_MODULES := $(call modules-get-all-installable,$(modules-get-top-list))
else
WANTED_MODULES := $(call module-get-all-dependencies,$(NDK_APP_MODULES))
endif
diff --git a/docs/CHANGES.html b/docs/CHANGES.html
index 7ad599294..ad28989f6 100644
--- a/docs/CHANGES.html
+++ b/docs/CHANGES.html
@@ -29,6 +29,20 @@ IMPORTANT CHANGES:
Which is a quick way to check that your project builds for all supported
ABIs without changing its Application.mk file.
+IMPORTANT BUG FIXES:
+
+- Imported shared libraries are now installed by default to the target
+ installation location (i.e. libs/%lt;abi%gt;) if APP_MODULES is not
+ defined in your Application.mk.
+
+ This means that if a top-level module "foo" imports a module "bar", then
+ both libfoo.so and libbar.so will be copied to the install location.
+
+ Previously, only libfoo.so was, unless you listed 'bar' in your APP_MODULES
+ too.
+
+ If you define APP_MODULES explicitely, the behaviour is unchanged.
+
-------------------------------------------------------------------------------
android-ndk-r6b
diff --git a/tests/build/import-install/README b/tests/build/import-install/README
new file mode 100644
index 000000000..417b7cbb5
--- /dev/null
+++ b/tests/build/import-install/README
@@ -0,0 +1,3 @@
+The purpose of this test is to check that imported shared libraries
+are properly installed to the target location, i.e. libs/<abi>/
+
diff --git a/tests/build/import-install/build.sh b/tests/build/import-install/build.sh
new file mode 100755
index 000000000..07e65763c
--- /dev/null
+++ b/tests/build/import-install/build.sh
@@ -0,0 +1,41 @@
+cd `dirname $0`
+PWD=$(pwd)
+
+# Update NDK_MODULE_PATH so we can find our imported modules
+export NDK_MODULE_PATH="$PWD"
+
+# Build everything
+$NDK/ndk-build "$@"
+
+# Extract ABIs list from parameters, we're looking for something like APP_ABI=<something>
+PARAM_ABIS=$(echo "$@" | tr ' ' '\n' | grep -e "^APP_ABI=")
+PARAM_ABIS=${PARAM_ABIS##APP_ABI=}
+if [ -z "$PARAM_ABIS" ]; then
+ echo "NO ABIS in param '$@'"
+ ABIS="armeabi armeabi-v7a x86"
+else
+ echo "FOUND ABIS in param '$@': $PARAM_ABIS"
+ ABIS="$PARAM_ABIS"
+fi
+
+# Now ensure that all files were installed to all supported ABIs
+MISSING=
+for ABI in $ABIS; do
+ DIR=$PWD/libs/$ABI
+ for FILENAME in libfoo.so libpath1.so libpath2.so; do
+ FILE=$DIR/$FILENAME
+ if [ ! -f "$FILE" ]; then
+ MISSING="$MISSING $FILE"
+ fi
+ done
+done
+
+# In case of missing files, error out
+if [ "$MISSING" ]; then
+ echo "ERROR: Missing files in build tree:"
+ for FILE in $MISSING; do echo " $FILE"; done
+ exit 1
+fi
+
+# Otherwise, our test is good
+exit 0 \ No newline at end of file
diff --git a/tests/build/import-install/jni/Android.mk b/tests/build/import-install/jni/Android.mk
new file mode 100644
index 000000000..f6a31766b
--- /dev/null
+++ b/tests/build/import-install/jni/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libfoo
+LOCAL_SRC_FILES := main.c
+LOCAL_SHARED_LIBRARIES := libpath1
+include $(BUILD_SHARED_LIBRARY)
+
+$(call import-module,path1)
+
diff --git a/tests/build/import-install/jni/Application.mk b/tests/build/import-install/jni/Application.mk
new file mode 100644
index 000000000..a252a72d7
--- /dev/null
+++ b/tests/build/import-install/jni/Application.mk
@@ -0,0 +1 @@
+APP_ABI := all
diff --git a/tests/build/import-install/jni/main.c b/tests/build/import-install/jni/main.c
new file mode 100644
index 000000000..91aaf0ed8
--- /dev/null
+++ b/tests/build/import-install/jni/main.c
@@ -0,0 +1,7 @@
+#include "path1.h"
+
+int foo(int x)
+{
+ return path1(x) - 16;
+}
+
diff --git a/tests/build/import-install/path1/Android.mk b/tests/build/import-install/path1/Android.mk
new file mode 100644
index 000000000..99e5b2e18
--- /dev/null
+++ b/tests/build/import-install/path1/Android.mk
@@ -0,0 +1,14 @@
+# This is a trivial shared library that will be imported
+# by the main project's binary. Note that it imports
+# another library
+#
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libpath1
+LOCAL_SRC_FILES := path1.c
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
+LOCAL_SHARED_LIBRARIES := libpath2
+include $(BUILD_SHARED_LIBRARY)
+
+$(call import-module,path2)
diff --git a/tests/build/import-install/path1/path1.c b/tests/build/import-install/path1/path1.c
new file mode 100644
index 000000000..6ccfcae89
--- /dev/null
+++ b/tests/build/import-install/path1/path1.c
@@ -0,0 +1,8 @@
+#include "path1.h"
+#include "path2.h"
+
+int path1(int x)
+{
+ return path2(x + 1);
+}
+
diff --git a/tests/build/import-install/path1/path1.h b/tests/build/import-install/path1/path1.h
new file mode 100644
index 000000000..7453d1677
--- /dev/null
+++ b/tests/build/import-install/path1/path1.h
@@ -0,0 +1,4 @@
+#ifndef PATH1_H
+#define PATH1_H
+extern int path1(int x);
+#endif
diff --git a/tests/build/import-install/path2/Android.mk b/tests/build/import-install/path2/Android.mk
new file mode 100644
index 000000000..3e06ca2e8
--- /dev/null
+++ b/tests/build/import-install/path2/Android.mk
@@ -0,0 +1,10 @@
+# This is a trivial shared library that will be imported
+# by 'libpath1', and hence by the project's main binary
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libpath2
+LOCAL_SRC_FILES := path2.c
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/build/import-install/path2/path2.c b/tests/build/import-install/path2/path2.c
new file mode 100644
index 000000000..a1e76e763
--- /dev/null
+++ b/tests/build/import-install/path2/path2.c
@@ -0,0 +1,7 @@
+#include "path2.h"
+
+int path2(int x)
+{
+ return x*42;
+}
+
diff --git a/tests/build/import-install/path2/path2.h b/tests/build/import-install/path2/path2.h
new file mode 100644
index 000000000..fc55614c8
--- /dev/null
+++ b/tests/build/import-install/path2/path2.h
@@ -0,0 +1,4 @@
+#ifndef PATH2_H
+#define PATH2_H
+extern int path2(int x);
+#endif
diff --git a/tests/build/multi-module-path/build.sh b/tests/build/multi-module-path/build.sh
index e013e3060..9f4b88ad2 100755
--- a/tests/build/multi-module-path/build.sh
+++ b/tests/build/multi-module-path/build.sh
@@ -4,7 +4,7 @@ echo "\$0=$0"
cd `dirname $0`
echo "PWD=`pwd`"
export NDK_MODULE_PATH=`pwd`/path1:`pwd`/path2
-../../../ndk-build "$@"
+$NDK/ndk-build "$@"
if [ $? != 0 ]; then
echo "ERROR: Can't build test program!"
exit 1
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index df5fe58eb..88776de0f 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -463,6 +463,7 @@ if is_testable build; then
{
echo "Building NDK build test: `basename $1`"
if [ -f $1/build.sh ]; then
+ export NDK
run $1/build.sh "$NDK_BUILD_FLAGS"
if [ $? != 0 ]; then
echo "!!! BUILD FAILURE [$1]!!! See $NDK_LOGFILE for details or use --verbose option!"