Fix building individual applet

This commit is contained in:
topjohnwu 2022-08-27 05:06:28 -07:00
parent 357d913f18
commit d1d26f4481
5 changed files with 24 additions and 26 deletions

View File

@ -64,7 +64,7 @@ cpu_count = multiprocessing.cpu_count()
archs = ['armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64']
triples = ['armv7a-linux-androideabi', 'i686-linux-android', 'aarch64-linux-android', 'x86_64-linux-android']
default_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'busybox']
support_targets = default_targets + ['resetprop', 'test']
support_targets = default_targets + ['resetprop']
rust_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy']
sdk_path = os.environ['ANDROID_SDK_ROOT']
@ -220,6 +220,8 @@ def run_ndk_build(flags):
def run_cargo_build(args):
os.chdir(op.join('native', 'src'))
targets = set(args.target) & set(rust_targets)
if 'resetprop' in args.target:
targets.add('magisk')
env = os.environ.copy()
env['CARGO_BUILD_RUSTC'] = op.join(rust_bin, 'rustc' + EXE_EXT)

View File

@ -4,30 +4,34 @@ LOCAL_PATH := $(call my-dir)
# Rust compilation outputs
###########################
ifdef B_MAGISK
LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagisk-rs.a
ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH)))
include $(CLEAR_VARS)
LOCAL_MODULE := magisk-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagisk-rs.a
LOCAL_SRC_FILES := $(LIBRARY_PATH)
include $(PREBUILT_STATIC_LIBRARY)
endif
ifdef B_BOOT
LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskboot-rs.a
ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH)))
include $(CLEAR_VARS)
LOCAL_MODULE := boot-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskboot-rs.a
LOCAL_SRC_FILES := $(LIBRARY_PATH)
include $(PREBUILT_STATIC_LIBRARY)
endif
ifdef B_INIT
LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskinit-rs.a
ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH)))
include $(CLEAR_VARS)
LOCAL_MODULE := init-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskinit-rs.a
LOCAL_SRC_FILES := $(LIBRARY_PATH)
include $(PREBUILT_STATIC_LIBRARY)
endif
ifdef B_POLICY
LIBRARY_PATH = ../out/$(TARGET_ARCH_ABI)/libmagiskpolicy-rs.a
ifneq (,$(wildcard $(LOCAL_PATH)/$(LIBRARY_PATH)))
include $(CLEAR_VARS)
LOCAL_MODULE := policy-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskpolicy-rs.a
LOCAL_SRC_FILES := $(LIBRARY_PATH)
include $(PREBUILT_STATIC_LIBRARY)
endif

View File

@ -150,29 +150,14 @@ LOCAL_STATIC_LIBRARIES := \
LOCAL_SRC_FILES := \
core/applet_stub.cpp \
resetprop/persist_properties.cpp \
resetprop/resetprop.cpp \
resetprop/persist.cpp \
LOCAL_CFLAGS := -DAPPLET_STUB_MAIN=resetprop_main
include $(BUILD_EXECUTABLE)
endif
ifdef B_TEST
ifneq (,$(wildcard src/test.cpp))
include $(CLEAR_VARS)
LOCAL_MODULE := test
LOCAL_STATIC_LIBRARIES := \
libbase \
libphmap
LOCAL_SRC_FILES := test.cpp
include $(BUILD_EXECUTABLE)
endif
endif
########################
# Libraries
########################

View File

@ -1,10 +1,15 @@
#include <sys/stat.h>
#include <magisk.hpp>
#include <selinux.hpp>
#include <base.hpp>
int main(int argc, char *argv[]) {
umask(0);
if (argc < 1)
return 1;
enable_selinux();
cmdline_logging();
init_argv0(argc, argv);
umask(0);
return APPLET_STUB_MAIN(argc, argv);
}

View File

@ -6,6 +6,8 @@
#include <resetprop.hpp>
#include <base.hpp>
#undef __INTRODUCED_IN
#define __INTRODUCED_IN(...)
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <_system_properties.h>