NekoX/bin/kts/update_libwebp.kts

30 lines
921 B
Plaintext
Raw Normal View History

2020-10-13 16:53:22 +02:00
import java.io.File
import kotlin.system.exitProcess
2021-01-16 17:25:30 +01:00
val projectRoot = File("../..")
2020-10-13 16:53:22 +02:00
val webpSources = File(projectRoot, "TMessagesProj/jni/libwebp/Android.mk")
.readLines()
.map { it.trim() }
.filter { it.startsWith("src/") && it.endsWith("\\") }
.map { "libwebp/" + it.substring(0, it.length - 2).replace("\$(NEON)", "c") }
val cmakeLists = File(projectRoot, "TMessagesProj/jni/CMakeLists.txt")
var cmakeListsSource = cmakeLists.readText()
val cmakeListsSourceNew = cmakeListsSource.substringBefore("add_library(webp STATIC") + "add_library(webp STATIC" +
webpSources.joinToString("\n", "\n") { " $it" } + ")" +
cmakeListsSource.substringAfter("add_library(webp STATIC").substringAfter(")")
if (cmakeListsSource == cmakeListsSourceNew) {
println("No changes")
exitProcess(0)
}
cmakeLists.writeText(cmakeListsSourceNew)
println("Updated sources")