build(android): Use cacheable Gradle task for downloading Vulkan validation layers (#4412)

This commit is contained in:
Jaakko Malkki
2026-07-18 01:06:10 +03:00
committed by GitHub
parent cdde840e67
commit ce3caaf783

View File

@@ -1,4 +1,4 @@
import java.net.URL
import java.net.URI
/**
@@ -29,23 +29,32 @@ val vvlLibRoot = projectDir // Set project root or change to rootDir if needed
val vvlJniLibDir = "$vvlLibRoot/src/vulkanDebug/jniLibs"
val vvlSoName = "libVkLayer_khronos_validation.so"
// Download the release zip file to ${vvlLibRoot}/
val download = tasks.register("download") {
val vvlZipName = "releases/download/vulkan-sdk-$vvlVersion/android-binaries-$vvlVersion.zip"
val zipFile = file("$vvlLibRoot/android-binaries-$vvlVersion.zip")
abstract class Download : DefaultTask() {
@get:Input
abstract val url: Property<String>
mkdir(vvlLibRoot)
@get:OutputFile
abstract val file: RegularFileProperty
doLast {
// Download the zip file from the Vulkan Validation Layers GitHub repo.
URL("$vvlSite/$vvlZipName").openStream().use { inputStream ->
zipFile.outputStream().use { outputStream ->
inputStream.copyTo(outputStream)
}
@TaskAction
fun download() {
URI.create(url.get()).toURL().openStream().use { inputStream ->
file.get().asFile
.outputStream()
.use { outputStream ->
inputStream.copyTo(outputStream)
}
}
}
}
val download = tasks.register<Download>("download") {
// Download the zip file from the Vulkan Validation Layers GitHub repo.
url = "$vvlSite/releases/download/vulkan-sdk-$vvlVersion/android-binaries-$vvlVersion.zip"
// Download the release zip file to ${vvlLibRoot}/
file = file("$vvlLibRoot/android-binaries-$vvlVersion.zip")
}
val unzip = tasks.register<Copy>("unzip") {
dependsOn(download)