From 49e8fe461e201cebeece993ef11e3440b5a80274 Mon Sep 17 00:00:00 2001 From: yellowhatpro Date: Wed, 5 Apr 2023 17:09:36 +0530 Subject: [PATCH] added support for x86_64-pc-windows-msvc 64-bit MSVC --- .../kotlin/org/bitcoindevkit/plugins/Enums.kt | 2 ++ .../bitcoindevkit/plugins/UniFfiJvmPlugin.kt | 27 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/Enums.kt b/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/Enums.kt index 8f586b6..85c089b 100644 --- a/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/Enums.kt +++ b/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/Enums.kt @@ -4,11 +4,13 @@ package org.bitcoindevkit.plugins val operatingSystem: OS = when { System.getProperty("os.name").contains("mac", ignoreCase = true) -> OS.MAC System.getProperty("os.name").contains("linux", ignoreCase = true) -> OS.LINUX + System.getProperty("os.name").contains("windows", ignoreCase = true) -> OS.WINDOWS else -> OS.OTHER } enum class OS { MAC, LINUX, + WINDOWS, OTHER, } diff --git a/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt b/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt index 71573ae..ca154ac 100644 --- a/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt +++ b/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt @@ -35,6 +35,14 @@ internal class UniFfiJvmPlugin : Plugin { args(cargoArgs) } } + else if(operatingSystem == OS.WINDOWS) { + exec { + workingDir("${project.projectDir}/../../bdk-ffi") + executable("cargo") + val cargoArgs: List = listOf("build", "--profile", "release-smaller", "--target", "x86_64-pc-windows-msvc") + args(cargoArgs) + } + } } // move the native libs build by cargo from target/.../release/ @@ -70,13 +78,30 @@ internal class UniFfiJvmPlugin : Plugin { ext = "so" ) ) + } else if (operatingSystem == OS.WINDOWS) { + libsToCopy.add( + CopyMetadata( + targetDir = "x86_64-pc-windows-msvc", + resDir = "win32-x86-64", + ext = "dll" + ) + ) + } + val libName = when (operatingSystem) { + OS.WINDOWS -> { + "bdkffi" + } + + else -> { + "libbdkffi" + } } libsToCopy.forEach { doFirst { copy { with(it) { - from("${project.projectDir}/../../target/${this.targetDir}/release-smaller/libbdkffi.${this.ext}") + from("${project.projectDir}/../../target/${this.targetDir}/release-smaller/${libName}.${this.ext}") into("${project.projectDir}/../../bdk-jvm/lib/src/main/resources/${this.resDir}/") } }