Skip to content

Commit

Permalink
Fail if a module has missing dependencies.
Browse files Browse the repository at this point in the history
    include $(CLEAR_VARS)
    LOCAL_MODULE := foo
    LOCAL_SRC_FILES := foo.cpp
    LOCAL_STATIC_LIBRARIES := never-defined
    include $(BUILD_SHARED_LIBRARY)

In the above example, the build would succeed even though it had
missing dependencies. This seems to have always been the behavior (I
checked back to r10e), so there's a good chance that there are builds
out there that depend on this behavior.

By default we will now abort in this situation because this is so
completely broken. A user may define `APP_ALLOW_MISSING_DEPS` to
"false" in their Application.mk or on the command line to revert to
the old, broken behavior.

Test: ./run_tests.py --filter APP_ALLOW_MISSING_DEPS
Bug: android/ndk#208
Change-Id: Ie77ad18a7e8000ef468c79f8e89aa2e5ae1788dd
  • Loading branch information
DanAlbert committed Sep 28, 2016
1 parent 192d726 commit 860ca72
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Announcements
become stable enough to be the default, as some parts of gnustl are still
incompatible with Clang. It will likely be removed after that point.

ndk-build
---------

* Module builds will now fail if they have any missing dependencies. To revert
to the old behavior, set `APP_ALLOW_MISSING_DEPS=false`. See
https://github.com/android-ndk/ndk/issues/208.

Known Issues
------------

Expand Down
20 changes: 20 additions & 0 deletions build/core/build-binary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,26 @@ shared_libs := $(call module-filter-shared-libraries,$(all_libs))
static_libs := $(call module-filter-static-libraries,$(all_libs))
whole_static_libs := $(call module-extract-whole-static-libs,$(LOCAL_MODULE),$(static_libs))
static_libs := $(filter-out $(whole_static_libs),$(static_libs))
all_defined_libs := $(shared_libs) $(static_libs) $(whole_static_libs)
undefined_libs := $(filter-out $(all_defined_libs),$(all_libs))

ifdef undefined_libs
$(call __ndk_warning,Module $(LOCAL_MODULE) depends on undefined modules: $(undefined_libs))

# https://github.com/android-ndk/ndk/issues/208
# ndk-build didn't used to fail the build for a missing dependency. This
# seems to have always been the behavior, so there's a good chance that
# there are builds out there that depend on this behavior (as of right now,
# anything using libc++ on ARM has this problem because of libunwind).
#
# By default we will abort in this situation because this is so completely
# broken. A user may define APP_ALLOW_MISSING_DEPS to "false" in their
# Application.mk or on the command line to revert to the old, broken
# behavior.
ifneq ($(APP_ALLOW_MISSING_DEPS),true)
$(call __ndk_error,Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies))
endif
endif

$(call -ndk-mod-debug,module $(LOCAL_MODULE) [$(LOCAL_BUILT_MODULE)])
$(call -ndk-mod-debug,. all_libs='$(all_libs)')
Expand Down
7 changes: 7 additions & 0 deletions tests/build/APP_ALLOW_MISSING_DEPS/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo.cpp
LOCAL_STATIC_LIBRARIES := missing-dep
include $(BUILD_EXECUTABLE)
1 change: 1 addition & 0 deletions tests/build/APP_ALLOW_MISSING_DEPS/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_ALLOW_MISSING_DEPS := true
3 changes: 3 additions & 0 deletions tests/build/APP_ALLOW_MISSING_DEPS/jni/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int main(int, char**) {
return 0;
}

0 comments on commit 860ca72

Please sign in to comment.