Skip to content

Commit

Permalink
🐛 Fix dll path on windows (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhs0602 committed Jan 24, 2025
1 parent 1ab5f98 commit 9e806a1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/craftground/MinecraftEnv/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,35 @@ tasks.register('compileCpp', Exec) {
} else if (os.isMacOsX()) {
outputs.file("libnative-lib.dylib")
} else if (os.isWindows()) {
outputs.file("native-lib.dll")
outputs.files(file("Debug/native-lib.dll"), file("Release/native-lib.dll"))
}
dependsOn 'configureCppProject'

// Copy the built native library to the project root (Only for Windows)
doLast {
if (os.isWindows()) {
// Copy the built native library to the project root
def debugOutput = new File("Debug/native-lib.dll")
def releaseOutput = new File("Release/native-lib.dll")
def targetDir = new File("native-lib.dll") // Copy to the project root

if (debugOutput.exists()) {
copy {
from debugOutput
into targetDir.parentFile
}
println "Copied ${debugOutput} to ${targetDir}"
} else if (releaseOutput.exists()) {
copy {
from releaseOutput
into targetDir.parentFile
}
println "Copied ${releaseOutput} to ${targetDir}"
} else {
throw new RuntimeException("Cannot find the built native library")
}
}
}
}

tasks.named('runClient').configure {
Expand Down

0 comments on commit 9e806a1

Please sign in to comment.