Skip to content

Commit

Permalink
Update native building + supports x86 + extracts to separate folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongmario committed Feb 9, 2024
1 parent 8b7c370 commit 1c10700
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
11 changes: 3 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ dependencies {
}

test {
useJUnitPlatform()
forkEvery 1
// TODO: separate args for separate tests(?)
jvmArgs '--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED'
jvmArgs '--add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED'

systemProperty "java.library.path", file("${project(":natives").buildDir}/lib/").absolutePath
enabled = false
finalizedBy 'testVendorsAndVersions'
}

def testVendorsAndVersions = tasks.register('testVendorsAndVersions') {
Expand All @@ -58,7 +53,7 @@ targetVendors.each { spec, info ->
toolchain.vendor = spec
}
test.useJUnitPlatform()
test.systemProperty "java.library.path", file("${project(":natives").buildDir}/lib/").absolutePath
test.systemProperty "java.library.path", file("${project(":natives").buildDir}/output/").absolutePath
}
testVendorsAndVersions.configure {
dependsOn testTask
Expand Down
21 changes: 18 additions & 3 deletions natives/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import org.gradle.internal.jvm.Jvm
import org.apache.tools.ant.taskdefs.condition.Os

plugins {
id 'cpp-library'
}

library {

baseName = 'libImagineBreaker'
def archString = System.getProperty('os.arch')
def archBits = archString.contains('64') ? 'x64' : 'x32'

baseName = (Os.isFamily(Os.FAMILY_WINDOWS) ? 'libImagineBreaker' : 'ImagineBreaker') + "_$archBits"

binaries.configureEach { CppBinary binary ->
def compileTask = binary.compileTask.get()
Expand All @@ -31,14 +35,25 @@ library {
}
}

targetMachines = [ machines.windows.x86_64, machines.macOS.x86_64, machines.linux.x86_64 ]

}

tasks.named('assemble').configure {
finalizedBy 'moveNative'
}

tasks.register('moveNative', Copy) {
from 'build/lib/main/debug'
include '**.dll', '**.so', '**.dylib'
group 'build'
from 'build/lib/main/debug/'
include '**/**.dll', '**/**.so', '**/**.dylib'
eachFile {
it.path = it.name
}
into 'build/output'
doLast {
file('build/output').eachDir {
it.delete()
}
}
}

0 comments on commit 1c10700

Please sign in to comment.