4

我对 su-binary ( https://github.com/git-core/su-binary )做了一些小改动,添加了一个目标来设置 SUID。我使用的 Android.mk:http://pastebin.com/N0gMJT4u Android 源代码树的根目录下运行 make 时,一切正常:

$ make -j5
[...]
system/core/rootdir/Android.mk:42: warning: ignoring old commands for target `out/target/product/panda/root/init.rc'
echo "Setting SUID/GUID to su-binary"
Setting SUID/GUID to su-binary
Installing busybox
chmod ug+s out/target/product/panda/system/xbin/su
[...]

mm -B在外部/su-binary 中运行时:http: //pastebin.com/8HmUJBA0 相同的行为mmm external/su-binary

根据https://groups.google.com/forum/#!msg/android-building/dtNZFj5pe1w/PRY2MXADXG4J

除了 Ying Wang 建议的“make name-of-module”之外,您还可以在目录中运行“mm”来构建(和安装)那里定义的所有模块。但是,这只会构建那些模块,不会构建任何依赖的模块。因此,它仅对跟踪依赖关系的现有树的增量构建有用。

试过了:

$ rm out/target/product/panda/system/xbin/su
$ make external/su-binary
[...]
make: Nothing to be done for `external/su-binary'.

$ rm out/target/product/panda/obj/EXECUTABLES/su_intermediates/su
$ make external/su-binary
[...]
make: Nothing to be done for `external/su-binary`.

模块依赖在 Android 中是如何工作的?

4

1 回答 1

4

好的,我通过更改 Android.mk 让它运行:

  1. 以不同的方式命名$(SU_BINARY)目标,即$(SU_BINARY)-post. LOCAL_MODULE更好,因为以前,它与andBUILD_EXECUTABLE组合定义的目标具有相同的名称。
  2. 把这个目标放在前面include $(BUILD_EXECUTABLE)

看起来像:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := su
LOCAL_SRC_FILES := su.c db.c activity.cpp

SU_SHARED_LIBRARIES := liblog libsqlite
ifeq ($(PLATFORM_SDK_VERSION),4)
    LOCAL_CFLAGS += -DSU_LEGACY_BUILD
    SU_SHARED_LIBRARIES += libandroid_runtime
else
    SU_SHARED_LIBRARIES += libcutils libbinder libutils
    LOCAL_MODULE_TAGS := eng
endif

LOCAL_C_INCLUDES += external/sqlite/dist

LOCAL_SHARED_LIBRARIES := $(SU_SHARED_LIBRARIES)

LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)


SU_INSTALL_DIR := $(TARGET_OUT)/xbin
SU_BINARY := $(SU_INSTALL_DIR)/su
# taken from busybox-android
$(SU_BINARY)-post: su
    @echo "Setting SUID/GUID to su-binary..."
    chmod ug+s $(TARGET_OUT_OPTIONAL_EXECUTABLES)/su
    ln -sf $(TARGET_OUT_OPTIONAL_EXECUTABLES)/su $(TARGET_OUT_EXECUTABLES)/su

ALL_DEFAULT_INSTALLED_MODULES += $(SU_BINARY)-post

include $(BUILD_EXECUTABLE)

ALL_DEFAULT_INSTALLED_MODULES我认为是在模块安装后很晚才出现的规则。但我必须深入研究它以检查这是否是我想要在这里做的最佳解决方案。

于 2012-05-19T21:56:29.383 回答