当前位置 : 主页 > 手机开发 > 其它 >

模块依赖如何在Android中运行?

来源:互联网 收集:自由互联 发布时间:2021-06-22
我对su-binary( https://github.com/git-core/su-binary)做了一些小改动,添加了一个目标来设置SUID. 我使用的Android.mk: http://pastebin.com/N0gMJT4u 在Android源代码树的根目录下运行make时,运行正常: $make
我对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
[...]

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

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

Apart from “make name-of-module” as suggested by Ying Wang, you can
run “mm” inside a directory to build (and install) all modules defined
there. However, this will build only those modules, any dependent
modules will not be built. Hence, it’s only useful for incremental
builds of existing trees where you keep track of the dependencies.

试过:

$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中运行?

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

>以不同方式命名$(SU_BINARY)目标,即$(SU_BINARY)-post.更好,因为之前它与LOCAL_MODULE和BUILD_EXECUTABLE组合定义的目标具有相同的名称.
>在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是我认为模块安装后很晚才出现的规则.但我要深入研究它是否是我想在这里做的最好的解决方案.

网友评论