Skip to content

Commit

Permalink
gradle: add native-image plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pjonsson committed Oct 18, 2023
1 parent e7594d2 commit 5eecc96
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// sudo apt install libfreetype-dev
plugins {
id 'application'
id 'com.diffplug.spotless' version '6.22.0'
id 'org.graalvm.buildtools.native' version '0.9.27'
}

group = 'org.contikios.cooja'
Expand Down Expand Up @@ -95,6 +97,31 @@ application {
'--enable-preview', '--enable-native-access', 'ALL-UNNAMED']
}

graalvmNative {
binaries {
main {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.matching("Oracle Corporation")
}
fallback = true
useFatJar = true
buildArgs.add('--enable-preview')
buildArgs.add('--report-unsupported-elements-at-runtime')
// Permit java.lang.foreign.SymbolLookup::libraryLookup.
buildArgs.add('--enable-native-access=ALL-UNNAMED')
// FIXME: no support for nativeRun --args?
// runtimeArgs.add("--no-gui")
// runtimeArgs.add("../../tests/07-simulation-base/02-ringbufindex.csc")
}
}
}

tasks.named("nativeCompile") {
dependsOn fullJar
classpathJar = layout.buildDirectory.file("libs/cooja-full.jar")
}

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['--enable-preview',
"-Aproject=${project.group}/${project.name}"]
Expand Down
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
Expand Down

0 comments on commit 5eecc96

Please sign in to comment.