mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
A lot of utils have been defined now that can be used to safely manage files. The java java.io.File API has poor support for detecting symlinks including broken symlinks. Android implementation also has issues. Check FileTypes.getFileType() function for more info. For this reason, the UnixFileAttributes and related classes has been ported from AOSP to get file attributes and type. Some file utils and android versions use google's Guava com.google.common.io.MoreFiles library for managing files, specially for safer directory deletion with SecureDirectoryStream. Some file utils and android versions use org.apache.commons.io.FileUtils for managing files. The library version used is 2.5 and it must not be incremented for compatibility with android version < 8, otherwise runtime crashes will occur.
176 lines
5.6 KiB
Groovy
176 lines
5.6 KiB
Groovy
plugins {
|
|
id "com.android.application"
|
|
}
|
|
|
|
ext.markwon_version='4.6.2'
|
|
|
|
android {
|
|
compileSdkVersion project.properties.compileSdkVersion.toInteger()
|
|
ndkVersion project.properties.ndkVersion
|
|
|
|
dependencies {
|
|
implementation "androidx.annotation:annotation:1.2.0"
|
|
implementation "androidx.core:core:1.5.0-rc01"
|
|
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
|
|
implementation "androidx.preference:preference:1.1.1"
|
|
implementation "androidx.viewpager:viewpager:1.0.0"
|
|
implementation "com.google.guava:guava:24.1-jre"
|
|
implementation "io.noties.markwon:core:$markwon_version"
|
|
implementation "io.noties.markwon:ext-strikethrough:$markwon_version"
|
|
implementation "io.noties.markwon:linkify:$markwon_version"
|
|
implementation "io.noties.markwon:recycler:$markwon_version"
|
|
implementation project(":terminal-view")
|
|
|
|
// Do not increment version higher than 2.5 or there
|
|
// will be runtime exceptions on android < 8
|
|
// due to missing classes like java.nio.file.Path.
|
|
implementation "commons-io:commons-io:2.5"
|
|
}
|
|
|
|
defaultConfig {
|
|
applicationId "com.termux"
|
|
minSdkVersion project.properties.minSdkVersion.toInteger()
|
|
targetSdkVersion project.properties.targetSdkVersion.toInteger()
|
|
versionCode 108
|
|
versionName "0.108"
|
|
|
|
manifestPlaceholders.TERMUX_PACKAGE_NAME = "com.termux"
|
|
manifestPlaceholders.TERMUX_APP_NAME = "Termux"
|
|
manifestPlaceholders.TERMUX_API_APP_NAME = "Termux:API"
|
|
manifestPlaceholders.TERMUX_BOOT_APP_NAME = "Termux:Boot"
|
|
manifestPlaceholders.TERMUX_FLOAT_APP_NAME = "Termux:Float"
|
|
manifestPlaceholders.TERMUX_STYLING_APP_NAME = "Termux:Styling"
|
|
manifestPlaceholders.TERMUX_TASKER_APP_NAME = "Termux:Tasker"
|
|
manifestPlaceholders.TERMUX_WIDGET_APP_NAME = "Termux:Widget"
|
|
|
|
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"
|
|
}
|
|
}
|
|
|
|
lintOptions {
|
|
disable 'ProtectedPermissions'
|
|
}
|
|
|
|
testOptions {
|
|
unitTests {
|
|
includeAndroidResources = true
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
testImplementation "junit:junit:4.13.1"
|
|
testImplementation "org.robolectric:robolectric:4.4"
|
|
}
|
|
|
|
task versionName {
|
|
doLast {
|
|
print android.defaultConfig.versionName
|
|
}
|
|
}
|
|
|
|
def downloadBootstrap(String arch, String expectedChecksum, String 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://github.com/termux/termux-packages/releases/download/bootstrap-" + version + "/bootstrap-" + arch + ".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 = "2021.02.19-r1"
|
|
downloadBootstrap("aarch64", "1e3d80bd8cc8771715845ab4a1e67fc125d84c4deda3a1a435116fe4d1f86160", version)
|
|
downloadBootstrap("arm", "317a987cab3d4da6f9d42f024a5f25e3aaf8557b8ec68eaf80411fde6b8ea78d", version)
|
|
downloadBootstrap("i686", "dd4632350474058fe5dec14b7bd882798bb3e9fe738b2de8c84a51a0b6395f4b", version)
|
|
downloadBootstrap("x86_64", "5458119186c3ea631420833e59730461dc2a5faf17b8fad239823c88aa4569ae", version)
|
|
}
|
|
}
|
|
|
|
afterEvaluate {
|
|
android.applicationVariants.all { variant ->
|
|
variant.javaCompileProvider.get().dependsOn(downloadBootstraps)
|
|
}
|
|
}
|