@@ -86,7 +86,7 @@ kmpConfiguration {
8686 }
8787
8888 project.extensions.configure<CompileToBitcodeExtension >(" cklib" ) {
89- config.configure(libs)
89+ val downloadDevLLVMTask = config.configure(libs)
9090
9191 create(" crypto_rand_sys" ) {
9292 language = CompileToBitcode .Language .C
@@ -102,9 +102,10 @@ kmpConfiguration {
102102 interopTaskInfo.forEach { (interopTaskName, konanTarget, hasSysGetRandom) ->
103103 if (kt != konanTarget) return @forEach
104104
105- // Must add dependency on the test cinterop task to ensure
106- // that Kotlin/Native dependencies get downloaded beforehand
107- this .dependsOn(interopTaskName)
105+ // Must add dependency on the cinterop task to ensure
106+ // Kotlin/Native dependencies get downloaded and are
107+ // present for cklib tasks to access.
108+ dependsOn(interopTaskName)
108109
109110 if (hasSysGetRandom != null ) {
110111 compilerArgs.add(hasSysGetRandom)
@@ -115,6 +116,8 @@ kmpConfiguration {
115116 }
116117 }
117118 }
119+
120+ dependsOn(downloadDevLLVMTask)
118121 }
119122 }
120123 }
@@ -148,7 +151,7 @@ private object LLVM {
148151 }
149152}
150153
151- private fun CKlibGradleExtension.configure (libs : LibrariesForLibs ) {
154+ private fun CKlibGradleExtension.configure (libs : LibrariesForLibs ): Task {
152155 kotlinVersion = libs.versions.gradle.kotlin.get()
153156 check(kotlinVersion == " 2.2.20" ) {
154157 " Kotlin version out of date! Download URLs for LLVM need to be updated for ${project.path} "
@@ -179,7 +182,7 @@ private fun CKlibGradleExtension.configure(libs: LibrariesForLibs) {
179182
180183 val source = DependencySource .Remote .Public (subDirectory = " ${LLVM .VERSION } -${arch} -${host} " )
181184
182- DependencyProcessor (
185+ val processor = DependencyProcessor (
183186 dependenciesRoot = cklibDir,
184187 dependenciesUrl = LLVM .URL ,
185188 dependencyToCandidates = mapOf (llvmDev to listOf (source)),
@@ -194,5 +197,9 @@ private fun CKlibGradleExtension.configure(libs: LibrariesForLibs) {
194197 println (" Downloading[$llvmDev ] - $current / $total " )
195198 },
196199 archiveType = archive,
197- ).run ()
200+ )
201+
202+ return project.tasks.register(" downloadDevLLVM" ) {
203+ actions = listOf (Action { processor.run () })
204+ }.get()
198205}
0 commit comments