forked from NextAlone/Nagram
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LiuYi0526
authored and
LiuYi0526
committed
Feb 17, 2024
1 parent
bce98cd
commit 3d17951
Showing
38 changed files
with
1,277 additions
and
13,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import com.android.build.gradle.internal.tasks.factory.dependsOn | ||
|
||
plugins { | ||
id("com.android.library") | ||
id("org.mozilla.rust-android-gradle.rust-android") | ||
} | ||
|
||
var targetAbi = "" | ||
if (gradle.startParameter.taskNames.isNotEmpty()) { | ||
if (gradle.startParameter.taskNames.size == 1) { | ||
val targetTask = gradle.startParameter.taskNames[0].toLowerCase() | ||
if (targetTask.contains("arm64")) { | ||
targetAbi = "arm64" | ||
} else if (targetTask.contains("arm")) { | ||
targetAbi = "arm" | ||
} | ||
} | ||
} | ||
|
||
android { | ||
|
||
ndkVersion = rootProject.extra.get("ndkVersion").toString() | ||
|
||
compileSdk = 31 | ||
defaultConfig { | ||
minSdk = 23 | ||
targetSdk = 31 | ||
} | ||
buildToolsVersion = "31.0.0" | ||
namespace = "io.nekohasekai.ss_rust" | ||
|
||
if (targetAbi.isNotBlank()) splits.abi { | ||
reset() | ||
include(* when (targetAbi) { | ||
"arm" -> arrayOf("armeabi-v7a") | ||
"arm64" -> arrayOf("arm64-v8a") | ||
else -> arrayOf("x86", "x86_64") | ||
}) | ||
} | ||
|
||
} | ||
|
||
cargo { | ||
module = "src/main/rust/shadowsocks-rust" | ||
libname = "ss-local" | ||
targets = when { | ||
targetAbi.isBlank() -> listOf("arm", "arm64", "x86", "x86_64") | ||
targetAbi == "arm" -> listOf("arm") | ||
targetAbi == "arm64" -> listOf("arm64") | ||
else -> listOf("arm", "arm64") | ||
} | ||
profile = findProperty("CARGO_PROFILE")?.toString() ?: "release" | ||
extraCargoBuildArguments = listOf("--bin", "sslocal") | ||
featureSpec.noDefaultBut(arrayOf( | ||
"stream-cipher", | ||
"logging", | ||
"local-flow-stat", | ||
"local-dns")) | ||
exec = { spec, toolchain -> | ||
spec.environment("RUST_ANDROID_GRADLE_LINKER_WRAPPER_PY", "$projectDir/$module/../linker-wrapper.py") | ||
spec.environment("RUST_ANDROID_GRADLE_TARGET", "target/${toolchain.target}/$profile/lib$libname.so") | ||
} | ||
} | ||
|
||
tasks.whenTaskAdded { | ||
when (name) { | ||
"mergeDebugJniLibFolders", "mergeReleaseJniLibFolders" -> dependsOn("cargoBuild") | ||
} | ||
} | ||
|
||
tasks.register<Exec>("cargoClean") { | ||
executable("cargo") // cargo.cargoCommand | ||
args("clean") | ||
workingDir("$projectDir/${cargo.module}") | ||
} | ||
|
||
tasks.clean.dependsOn("cargoClean") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
import os | ||
import pipes | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
||
args = [os.environ['RUST_ANDROID_GRADLE_CC'], os.environ['RUST_ANDROID_GRADLE_CC_LINK_ARG']] + sys.argv[1:] | ||
|
||
# This only appears when the subprocess call fails, but it's helpful then. | ||
printable_cmd = ' '.join(pipes.quote(arg) for arg in args) | ||
print(printable_cmd) | ||
|
||
code = subprocess.call(args) | ||
if code == 0: | ||
shutil.copyfile(sys.argv[sys.argv.index('-o') + 1], os.environ['RUST_ANDROID_GRADLE_TARGET']) | ||
sys.exit(code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
plugins { | ||
id 'com.android.library' | ||
} | ||
|
||
def targetAbi = "" | ||
if (!gradle.startParameter.taskNames.isEmpty()) { | ||
if (gradle.startParameter.taskNames.size == 1) { | ||
def targetTask = gradle.startParameter.taskNames[0].toLowerCase() | ||
if (targetTask.contains("arm64")) { | ||
targetAbi = "arm64" | ||
} else if (targetTask.contains("arm")) { | ||
targetAbi = "arm" | ||
} | ||
} else { | ||
targetAbi = "~" | ||
} | ||
} | ||
|
||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion '30.0.3' | ||
ndkVersion rootProject.ext.ndkVersion | ||
|
||
defaultConfig { | ||
minSdkVersion 19 | ||
targetSdkVersion 30 | ||
|
||
externalNativeBuild { | ||
ndkBuild { | ||
if (!targetAbi.isBlank()) { | ||
if (targetAbi == "arm64") { | ||
abiFilters 'arm64-v8a' | ||
} else if (targetAbi == "arm") { | ||
abiFilters 'armeabi-v7a' | ||
} else { | ||
abiFilters 'armeabi-v7a', 'arm64-v8a' | ||
} | ||
} else { | ||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' | ||
} | ||
|
||
arguments "NDK_APPLICATION_MK:=src/main/jni/Application.mk", "APP_PLATFORM:=android-21", "--jobs=${Runtime.getRuntime().availableProcessors()}" | ||
} | ||
} | ||
} | ||
|
||
externalNativeBuild { | ||
ndkBuild { | ||
path 'src/main/jni/Android.mk' | ||
} | ||
} | ||
namespace 'io.nekohasekai.ssr_libev' | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
Oops, something went wrong.