kitgit

tirbofish/dropbear · commit

01c4c64ea374082640b4a1593d6a5b2539b57f48

ci: fixing build.gradle.kts for dokka docs

Unverified

tk <4tkbytes@pm.me> · 2025-10-19 05:06

view full diff

diff --git a/build.gradle.kts b/build.gradle.kts
index 5f3b449..786e8fa 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -33,7 +33,6 @@ val libPathProvider = provider {
     )
 
     candidates.firstOrNull { it.exists() }?.absolutePath
-        ?: println("No Rust library exists")
 }
 
 kotlin {
@@ -51,13 +50,33 @@ kotlin {
     }
 
     val nativeLibPath = libPathProvider.get()
-    val nativeLibDir = file(nativeLibPath).parentFile.absolutePath
-    val nativeLibFileName = file(nativeLibPath).name
-    val nativeLibNameForLinking = when {
-        isMacOs -> nativeLibFileName.removePrefix("lib").removeSuffix(".dylib")
-        isLinux -> nativeLibFileName.removePrefix("lib").removeSuffix(".so")
-        isMingwX64 -> nativeLibFileName.removeSuffix(".dll")
-        else -> throw GradleException("Unsupported OS for library name derivation.")
+    if (nativeLibPath != null) {
+        val nativeLibDir = file(nativeLibPath).parentFile.absolutePath
+        val nativeLibFileName = file(nativeLibPath).name
+        val nativeLibNameForLinking = when {
+            isMacOs -> nativeLibFileName.removePrefix("lib").removeSuffix(".dylib")
+            isLinux -> nativeLibFileName.removePrefix("lib").removeSuffix(".so")
+            isMingwX64 -> nativeLibFileName.removeSuffix(".dll")
+            else -> throw GradleException("Unsupported OS for library name derivation.")
+        }
+
+        nativeTarget.apply {
+            binaries {
+                sharedLib {
+                    baseName = "dropbear"
+
+                    if (isLinux || isMacOs) {
+                        linkerOpts("-L$nativeLibDir", "-l$nativeLibNameForLinking", "-Wl,-rpath,\\\$ORIGIN")
+                    } else if (isMingwX64) {
+                        val importLibName = "$nativeLibNameForLinking.lib"
+                        val importLibPath = file("$nativeLibDir/$importLibName").absolutePath
+                        linkerOpts(
+                            importLibPath
+                        )
+                    }
+                }
+            }
+        }

Large diffs are not rendered by default. Showing the first 50 of 102 lines. Show full diff