Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
32
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturmes committed Aug 17, 2024
1 parent ff97125 commit cd38554
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
run: |
rustup default stable
cargo install cargo-ndk
cargo install cross --locked
rustup target install aarch64-linux-android
- name: Cache Rust
Expand Down
6 changes: 4 additions & 2 deletions apd/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions apd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ tempdir = "0.3"
chrono = "0.4"

[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
rustix = { git = "https://github.com/AndroidPatch/rustix", branch = "main", features = ["all-apis"] }
rustix = { git = "https://github.com/Rissu-Projekt/rustix", branch = "main", features = ["all-apis"] }
# some android specific dependencies which compiles under unix are also listed here for convenience of coding
android-properties = { version = "0.2.2", features = ["bionic-deprecated"] }
procfs = "0.16"
loopdev = { git = "https://github.com/AndroidPatch/loopdev" }
loopdev = { git = "https://github.com/Rissu-Projekt/loopdev" }

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.13"

[profile.release]
strip = true
opt-level = 3
opt-level = 2
codegen-units = 1
panic = "abort"
lto = true
#lto = true
3 changes: 0 additions & 3 deletions apd/src/apd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ pub fn root_shell() -> Result<()> {
if free_idx < matches.free.len() {
let name = &matches.free[free_idx];
uid = unsafe {
#[cfg(target_arch = "aarch64")]
let pw = libc::getpwnam(name.as_ptr() as *const u8).as_ref();
#[cfg(target_arch = "x86_64")]
let pw = libc::getpwnam(name.as_ptr() as *const i8).as_ref();

match pw {
Some(pw) => pw.pw_uid,
Expand Down
8 changes: 1 addition & 7 deletions apd/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ pub const RESETPROP_PATH: &str = concatcp!(BINARY_DIR, "resetprop");
pub const BUSYBOX_PATH: &str = concatcp!(BINARY_DIR, "busybox");
pub const MAGISKPOLICY_PATH: &str = concatcp!(BINARY_DIR, "magiskpolicy");

#[cfg(target_arch = "aarch64")]
#[derive(RustEmbed)]
#[folder = "../app/libs/arm64-v8a"]
struct Asset;

#[cfg(target_arch = "x86_64")]
#[derive(RustEmbed)]
#[folder = "../app/libs/x86_64"]
#[folder = "../app/libs/armeabi-v7a"]
struct Asset;

pub fn ensure_binaries() -> Result<()> {
Expand Down
41 changes: 13 additions & 28 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,22 @@ tasks.register<Download>("downloadKpimg") {
}

tasks.register<Download>("downloadKpatch") {
src("https://github.com/bmax121/KernelPatch/releases/download/${kernelPatchVersion}/kpatch-android")
dest(file("${project.projectDir}/libs/arm64-v8a/libkpatch.so"))
src("https://github.com/Arturmes/KernelPatch32/releases/download/${kernelPatchVersion}/kpatch-android")
dest(file("${project.projectDir}/libs/armeabi-v7a/libkpatch.so"))
onlyIfNewer(true)
overwrite(true)
}

tasks.register<Download>("downloadKptools") {
src("https://github.com/bmax121/KernelPatch/releases/download/${kernelPatchVersion}/kptools-android")
dest(file("${project.projectDir}/libs/arm64-v8a/libkptools.so"))
src("https://github.com/Arturmes/KernelPatch32/releases/download/${kernelPatchVersion}/kptools-android")
dest(file("${project.projectDir}/libs/armeabi-v7a/libkptools.so"))
onlyIfNewer(true)
overwrite(true)
}

tasks.register<Download>("downloadApjni") {
src("https://github.com/bmax121/KernelPatch/releases/download/${kernelPatchVersion}/libapjni.so")
dest(file("${project.projectDir}/libs/arm64-v8a/libapjni.so"))
src("https://github.com/Arturmes/KernelPatch32/releases/download/${kernelPatchVersion}/libapjni.so")
dest(file("${project.projectDir}/libs/armeabi-v7a/libapjni.so"))
onlyIfNewer(true)
overwrite(true)
}
Expand All @@ -131,17 +131,17 @@ tasks.getByName("preBuild").dependsOn(
)

// https://github.com/bbqsrc/cargo-ndk
// cargo ndk -t arm64-v8a build --release
tasks.register<Exec>("cargoBuild") {
executable("cargo")
args("ndk", "-t", "arm64-v8a", "build", "--release")
// cross clippy --manifest-path apd/Cargo.toml --target armv7-linux-androideabi --release
tasks.register<Exec>("clippyBuild") {
executable("cross")
args("clippy", "--manifest-path", "Cargo.toml", "--target", "armv7-linux-androideabi", "--release")
workingDir("${project.rootDir}/apd")
}

tasks.register<Copy>("buildApd") {
dependsOn("cargoBuild")
from("${project.rootDir}/apd/target/aarch64-linux-android/release/apd")
into("${project.projectDir}/libs/arm64-v8a")
dependsOn("clippyBuild")
from("${project.rootDir}/apd/target/armv7-linux-androideabi/release/apd")
into("${project.projectDir}/libs/armeabi-v7a")
rename("apd", "libapd.so")
}

Expand All @@ -151,21 +151,6 @@ tasks.configureEach {
}
}

tasks.register<Exec>("cargoClean") {
executable("cargo")
args("clean")
workingDir("${project.rootDir}/apd")
}

tasks.register<Delete>("apdClean") {
dependsOn("cargoClean")
delete(file("${project.projectDir}/libs/arm64-v8a/libapd.so"))
}

tasks.clean {
dependsOn("apdClean")
}

dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.navigation.compose)
Expand Down
4 changes: 0 additions & 4 deletions app/libs/arm64-v8a/.gitignore

This file was deleted.

Binary file removed app/libs/arm64-v8a/libbusybox.so
Binary file not shown.
Binary file removed app/libs/arm64-v8a/libmagiskboot.so
Binary file not shown.
Binary file removed app/libs/arm64-v8a/libmagiskpolicy.so
Binary file not shown.
Binary file removed app/libs/arm64-v8a/libresetprop.so
Binary file not shown.
Binary file added app/libs/armeabi-v7a/libbusybox.so
Binary file not shown.
Binary file added app/libs/armeabi-v7a/libmagiskboot.so
Binary file not shown.
Binary file added app/libs/armeabi-v7a/libmagiskpolicy.so
Binary file not shown.
Binary file added app/libs/armeabi-v7a/libresetprop.so
Binary file not shown.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cmaker {
)
cFlags.addAll(flags)
cppFlags.addAll(flags)
abiFilters("arm64-v8a")
abiFilters("armeabi-v7a")
}
buildTypes {
if (it.name == "release") {
Expand Down

0 comments on commit cd38554

Please sign in to comment.