plugins { id "com.android.application" } android { compileSdkVersion project.properties.compileSdkVersion.toInteger() ndkVersion = System.getenv("JITPACK_NDK_VERSION") ?: project.properties.ndkVersion dependencies { implementation "androidx.annotation:annotation:1.2.0" implementation "androidx.core:core:1.6.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:$markwonVersion" implementation "io.noties.markwon:ext-strikethrough:$markwonVersion" implementation "io.noties.markwon:linkify:$markwonVersion" implementation "io.noties.markwon:recycler:$markwonVersion" implementation project(":terminal-view") implementation project(":termux-shared") } defaultConfig { applicationId "com.termux" minSdkVersion project.properties.minSdkVersion.toInteger() targetSdkVersion project.properties.targetSdkVersion.toInteger() versionCode 117 versionName "0.117" 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" } } splits { abi { enable gradle.startParameter.taskNames.any { it.contains("Debug") } reset () include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' universalApk true } } } 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 } } packagingOptions { jniLibs { useLegacyPackaging true } } applicationVariants.all { variant -> variant.outputs.all { output -> if (variant.buildType.name == "debug") { def abi = output.getFilter(com.android.build.OutputFile.ABI) def releaseTag = System.getenv("RELEASE_TAG") outputFileName = new File("termux-app-" + (abi ? abi : "universal") + (releaseTag ? "-" + releaseTag : "") + "-debug.apk") } } } } dependencies { testImplementation "junit:junit:4.13.2" 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.08.18-r1" downloadBootstrap("aarch64", "7136344e7d19de5ca82ab9e2c616c41233a8b42b67f03c49c966c7aef7889b30", version) downloadBootstrap("arm", "f0587456e2a3d6e0710475bd6fc39c089b3a8c0b26965a67cf470898caea4fdc", version) downloadBootstrap("i686", "9be0b2251ea56b885615f748e53b0b9c56f3b071e62cb183d5aa34b37d8a8150", version) downloadBootstrap("x86_64", "54dcd7cb52e3041651275191019158c7f0e3d043cf061411f7fb9715300cbccf", version) } } afterEvaluate { android.applicationVariants.all { variant -> variant.javaCompileProvider.get().dependsOn(downloadBootstraps) } }