mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-04 01:35:39 +08:00
149 lines
4.3 KiB
Groovy
149 lines
4.3 KiB
Groovy
plugins {
|
|
id "com.android.application"
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion project.properties.compileSdkVersion.toInteger()
|
|
ndkVersion project.properties.ndkVersion
|
|
|
|
dependencies {
|
|
implementation "androidx.annotation:annotation:1.1.0"
|
|
implementation "androidx.viewpager:viewpager:1.0.0"
|
|
implementation "androidx.drawerlayout:drawerlayout:1.1.0"
|
|
implementation project(":terminal-view")
|
|
}
|
|
|
|
defaultConfig {
|
|
applicationId "com.termux"
|
|
minSdkVersion project.properties.minSdkVersion.toInteger()
|
|
targetSdkVersion project.properties.targetSdkVersion.toInteger()
|
|
versionCode 98
|
|
versionName "0.98"
|
|
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
cFlags "-std=c11", "-Wall", "-Wextra", "-Werror", "-Os", "-fno-stack-protector", "-Wl,--gc-sections"
|
|
}
|
|
}
|
|
|
|
ndk {
|
|
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
|
|
}
|
|
|
|
}
|
|
|
|
signingConfigs {
|
|
debug {
|
|
storeFile file('dev_keystore.jks')
|
|
keyAlias 'alias'
|
|
storePassword 'xrj45yWGLbsO7W0v'
|
|
keyPassword 'xrj45yWGLbsO7W0v'
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
|
|
debug {
|
|
signingConfig signingConfigs.debug
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
}
|
|
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
path "src/main/cpp/Android.mk"
|
|
}
|
|
}
|
|
|
|
testOptions {
|
|
unitTests {
|
|
includeAndroidResources = true
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
testImplementation 'junit:junit:4.13'
|
|
testImplementation 'org.robolectric:robolectric:4.3.1'
|
|
}
|
|
|
|
task versionName {
|
|
doLast {
|
|
print android.defaultConfig.versionName
|
|
}
|
|
}
|
|
|
|
def downloadBootstrap(String arch, String expectedChecksum, int version) {
|
|
def digest = java.security.MessageDigest.getInstance("SHA-256")
|
|
|
|
def localUrl = "src/main/cpp/bootstrap-" + arch + ".zip"
|
|
def file = new File(projectDir, localUrl)
|
|
if (file.exists()) {
|
|
def buffer = new byte[8192]
|
|
def input = new FileInputStream(file)
|
|
while (true) {
|
|
def readBytes = input.read(buffer)
|
|
if (readBytes < 0) break
|
|
digest.update(buffer, 0, readBytes)
|
|
}
|
|
def checksum = new BigInteger(1, digest.digest()).toString(16)
|
|
if (checksum == expectedChecksum) {
|
|
return
|
|
} else {
|
|
logger.quiet("Deleting old local file with wrong hash: " + localUrl)
|
|
file.delete()
|
|
}
|
|
}
|
|
|
|
def remoteUrl = "https://bintray.com/termux/bootstrap/download_file?file_path=bootstrap-" + arch + "-v" + version + ".zip"
|
|
logger.quiet("Downloading " + remoteUrl + " ...")
|
|
|
|
file.parentFile.mkdirs()
|
|
def out = new BufferedOutputStream(new FileOutputStream(file))
|
|
|
|
def connection = new URL(remoteUrl).openConnection()
|
|
connection.setInstanceFollowRedirects(true)
|
|
def digestStream = new java.security.DigestInputStream(connection.inputStream, digest)
|
|
out << digestStream
|
|
out.close()
|
|
|
|
def checksum = new BigInteger(1, digest.digest()).toString(16)
|
|
if (checksum != expectedChecksum) {
|
|
file.delete()
|
|
throw new GradleException("Wrong checksum for " + remoteUrl + ": expected: " + expectedChecksum + ", actual: " + checksum)
|
|
}
|
|
}
|
|
|
|
clean {
|
|
doLast {
|
|
def tree = fileTree(new File(projectDir, 'src/main/cpp'))
|
|
tree.include 'bootstrap-*.zip'
|
|
tree.each { it.delete() }
|
|
}
|
|
}
|
|
|
|
task downloadBootstraps(){
|
|
doLast {
|
|
def version = 28
|
|
downloadBootstrap("aarch64", "8f8c8af1d6c50bd0d6ecd5a1df8d5b0c3122a945b6febd0de0308504b4075ed0", version)
|
|
downloadBootstrap("arm", "179465f403a73fec6534363b11cb38eed3b6b3d8e9d922d8e55dc8a06813240d", version)
|
|
downloadBootstrap("i686", "2100ebf36befde73b08efaa7e3ccc9c218a8b5e7d69db06e16e364ab8b7dfbd5", version)
|
|
downloadBootstrap("x86_64", "3f5192f63595426370aa69f102fac07ae00c12154878eddec24e8406e640a67f", version)
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
android.applicationVariants.all { variant ->
|
|
variant.javaCompileProvider.get().dependsOn(downloadBootstraps)
|
|
}
|
|
}
|