From 78a03570a3bd50d2c179753222c3c5a0cf7aa50e Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Sat, 15 Jul 2023 13:56:26 +0200 Subject: [PATCH] Fixed rust build to make it work on windows --- build.gradle.kts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 60e3aa0..fc970f7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -197,20 +197,28 @@ task("rustTasks") { dependsOn("rust_copyBuild") } -task("rust_copyBuild", type = Exec::class) { +task("rust_copyBuild") { val outputDir = "${buildDir}/classes/kotlin/main" println("Copy rs called") - workingDir = File(project.projectDir, "rs") + val workingDir = File(project.projectDir, "rs/target/release") - val f = File(outputDir) - f.mkdirs() + val directory = File(outputDir) + directory.mkdirs() - val lib = when (currentOs()) { + val originLib = when (currentOs()) { OS.LINUX -> "libuniffi_gitnuro.so" - OS.WINDOWS -> "libuniffi_gitnuro.dll" + OS.WINDOWS -> "gitnuro_rs.dll" OS.MAC -> "libuniffi_gitnuro.so" //TODO or is it a dylib? must be tested } - commandLine = listOf( - "cp", "target/release/libgitnuro_rs.so", "$outputDir/$lib", - ) + + val destinyLib = when (currentOs()) { + OS.LINUX -> "libuniffi_gitnuro.so" + OS.WINDOWS -> "uniffi_gitnuro.dll" + OS.MAC -> "libuniffi_gitnuro.so" //TODO or is it a dylib? must be tested + } + + val originFile = File(workingDir, originLib) + val destinyFile = File(directory, destinyLib) + + com.google.common.io.Files.copy(originFile, destinyFile) }