GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GhostLock/build.gradle.kts at main · EV-Toolkit/GhostLock

Expand file tree

/

build.gradle.kts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
162 lines (144 loc) · 6 KB
/

build.gradle.kts

Copy path

File metadata and controls

162 lines (144 loc) · 6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import java.util.Properties
plugins {
id("com.android.application") version "9.1.0" apply false
id("org.jetbrains.kotlin.plugin.compose") version "2.4.20" apply false
id("org.jetbrains.kotlin.jvm") version "2.4.20" apply false
}
private fun localProperties(): Properties = Properties().also { properties ->
val propertiesFile = rootProject.file("local.properties")
if (propertiesFile.isFile) {
propertiesFile.inputStream().use(properties::load)
}
}
private fun ondkHome(): String? =
System.getenv("ONDK_HOME")?.takeIf(String::isNotBlank)
?: localProperties().getProperty("ondk.dir")?.takeIf(String::isNotBlank)
private fun useOndk(): Boolean = !ondkHome().isNullOrBlank()
private fun resolveNdkDir(): String {
val ondk = ondkHome()
if (ondk != null) return ondk
val properties = localProperties()
val ndkEnvironment = System.getenv("ANDROID_NDK_HOME")
?: System.getenv("ANDROID_NDK_ROOT")
if (!ndkEnvironment.isNullOrBlank()) return ndkEnvironment
properties.getProperty("ndk.dir")?.takeIf(String::isNotBlank)?.let { return it }
val sdkDir = properties.getProperty("sdk.dir") ?: System.getenv("ANDROID_HOME")
if (!sdkDir.isNullOrBlank()) {
val ndkRoot = File(sdkDir, "ndk")
val versions = ndkRoot.listFiles()
?.filter(File::isDirectory)
?.map(File::getName)
?.sorted()
.orEmpty()
if (versions.isNotEmpty()) return File(ndkRoot, versions.last()).absolutePath
}
throw GradleException("NDK not found; set ANDROID_NDK_HOME or ndk.dir in local.properties")
}
private data class NdkTools(val clang: String, val ar: String)
private fun resolveCargoExecutable(): String {
val cargoOnPath = System.getenv("PATH")
.orEmpty()
.split(File.pathSeparator)
.asSequence()
.map { File(it, "cargo") }
.firstOrNull { it.isFile && it.canExecute() }
if (cargoOnPath != null) return cargoOnPath.absolutePath
val cargoInRustupHome = File(System.getProperty("user.home"), ".cargo/bin/cargo")
return if (cargoInRustupHome.isFile && cargoInRustupHome.canExecute()) {
cargoInRustupHome.absolutePath
} else {
"cargo"
}
}
private fun extractNdkTools(): NdkTools {
val ndk = resolveNdkDir()
val osName = System.getProperty("os.name").lowercase()
val isWindows = osName.contains("windows")
val prebuilt = when {
isWindows -> "windows-x86_64"
osName.contains("mac") -> "darwin-x86_64"
else -> "linux-x86_64"
}
val binDir = File(ndk, "toolchains/llvm/prebuilt/$prebuilt/bin")
return NdkTools(
clang = File(
binDir,
if (isWindows) "aarch64-linux-android34-clang.cmd" else "aarch64-linux-android34-clang",
).absolutePath,
ar = File(binDir, if (isWindows) "llvm-ar.exe" else "llvm-ar").absolutePath,
)
}
// Every module's output lives under the root build/ directory (native,
// host-test, extract, kernel-profiles, app). Delete the whole tree here so a
// single root `clean` resets all of them.
tasks.register<Delete>("clean") {
description = "Delete the root build/ directory (all module outputs)."
delete(layout.buildDirectory)
}
tasks.register<Exec>("buildGhostlockNative") {
description = "buildGhostlockNative"
workingDir(file("src"))
commandLine("make", "ghostlock")
val ndk = resolveNdkDir()
environment("ANDROID_NDK_HOME", ndk)
environment("NDK_ROOT", ndk)
inputs.files(
fileTree("src") { include("**/*.c", "**/*.h", "**/*.cpp", "**/*.hpp") },
file("src/Makefile"),
)
outputs.file(file("build/native/ghostlock"))
}
tasks.register<Copy>("prepareGhostlockJniLibs") {
description = "prepareGhostlockJniLibs"
dependsOn("buildGhostlockNative")
from("build/native/ghostlock")
into("app/src/main/jniLibs/arm64-v8a")
rename { "libghostlock.so" }
/* Strip only the packaged copy: static libc++ carries its DWARF into the
* binary, while the top-level ghostlock keeps its symbols for the
* disassembly comparisons. Paths are captured as plain strings so the
* configuration cache can serialize this task. */
val stripPath = File(extractNdkTools().clang)
.resolveSibling("llvm-strip").absolutePath
val packagedPath = File(rootDir, "app/src/main/jniLibs/arm64-v8a/libghostlock.so").absolutePath
doLast {
val code = ProcessBuilder(stripPath, "--strip-all", packagedPath)
.inheritIO()
.start()
.waitFor()
check(code == 0) { "llvm-strip failed with $code" }
}
}
tasks.register<Exec>("buildGhostlockExtract") {
description = "buildGhostlockExtract"
val tools = extractNdkTools()
val isOndk = useOndk()
val command = mutableListOf(resolveCargoExecutable())
if (isOndk) command += "+ondk"
command += listOf("build", "--release", "--target", "aarch64-linux-android")
if (isOndk) {
command += listOf("-Z", "build-std=std,panic_abort")
command += listOf("-Z", "build-std-features=optimize_for_size")
}
workingDir(rootProject.file("tools/extract_rs"))
commandLine(command)
environment("CC_aarch64_linux_android", tools.clang)
environment("AR_aarch64_linux_android", tools.ar)
environment("CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER", tools.clang)
environment("RUSTFLAGS", "-C force-unwind-tables=no -C link-arg=-Wl,--icf=all")
if (isOndk) environment("RUSTC_BOOTSTRAP", "1")
inputs.files(
fileTree("tools/extract_rs/src") { include("**/*.rs") },
file("tools/extract_rs/Cargo.toml"),
file("tools/extract_rs/Cargo.lock"),
)
inputs.property("useOndk", isOndk)
outputs.file(file("build/extract/aarch64-linux-android/release/ghostlock-extract"))
}
tasks.register<Copy>("prepareGhostlockExtractJniLibs") {
description = "prepareGhostlockExtractJniLibs"
dependsOn("buildGhostlockExtract")
from("build/extract/aarch64-linux-android/release/ghostlock-extract")
into("app/src/main/jniLibs/arm64-v8a")
rename { "libextract.so" }
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.