mirror of
https://github.com/apple/pkl.git
synced 2026-04-17 22:19:46 +02:00
Publish executables for pkldoc, pkl-codegen-java, pkl-codegen-kotlin (#1023)
This adds logic to build and publish the other executables related to Pkl. These are: * pkl-doc * pkl-codegen-kotlin * pkl-codegen-java pkl-codegen-kotlin and pkl-codegen-java are published as executable JARs, whereas pkldoc is published both as an executable JAR, and also native executables (matching the set of os/arch supported by Pkl). The reason this only publishes executable JARs for pkl-codegen-kotlin and pkl-codegen-java is because we expect that the Java requirement is not a problem for these users, and that the native executable provides negligible added value. As part of this, the following changes are made: * Introduce `pklJavaExecutable` plugin, which sets up building and publishing of executable JAR. * Introduce `pklNativeExecutable` plugin, which sets up building and publishing of native executables. * Introduce `NativeImageBuild` Gradle task, which knows how to build native-image executables. * Introduce `ExecutableSpec` extension, for projects that publish executables to configure how those executables should be published. * `./griddles buildNative`, by default, will only build the executable of the host OS/Arch, and will no longer cross-build. * The target arch of `./gradlew buildNative` can be changed using `-Dpkl.targetArch=<aarch64|amd64>`. * On linux/amd64 only, with `./gradlew buildNative`, a statically linked executable can be built using `-Dpkl.musl=true` * Make `javaExecutable` a dependency of `assemble` * Make `testStartJavaExecutable` a dependency of `check` * Change name `pklNativeBuild` to `pklNativeLifecycle` to better match the plugin's purpose * Remove Truffle SVM classes from main source set (don't publish these classes as part of the pkl-cli JAR) * Change CircleCI definition to publish new executables * Change CircleCI definition to call `buildNative` instead of individual task names
This commit is contained in:
@@ -72,21 +72,15 @@ org.eclipse.jetty:jetty-util:11.0.24=testCompileClasspath,testImplementationDepe
|
||||
org.eclipse.jetty:jetty-webapp:11.0.24=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-xml:11.0.24=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.fusesource.jansi:jansi:2.4.1=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.compiler:compiler:24.1.2=compileClasspath,compileOnlyDependenciesMetadata
|
||||
org.graalvm.nativeimage:native-image-base:24.1.2=compileClasspath,compileOnlyDependenciesMetadata
|
||||
org.graalvm.nativeimage:objectfile:24.1.2=compileClasspath,compileOnlyDependenciesMetadata
|
||||
org.graalvm.nativeimage:pointsto:24.1.2=compileClasspath,compileOnlyDependenciesMetadata
|
||||
org.graalvm.nativeimage:svm:24.1.2=compileClasspath,compileOnlyDependenciesMetadata
|
||||
org.graalvm.nativeimage:truffle-runtime-svm:24.1.2=compileClasspath,compileOnlyDependenciesMetadata
|
||||
org.graalvm.polyglot:polyglot:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.sdk:collections:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.sdk:graal-sdk:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,runtimeClasspath,testRuntimeClasspath
|
||||
org.graalvm.sdk:jniutils:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.sdk:jniutils:24.1.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.sdk:nativeimage:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.sdk:word:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.truffle:truffle-api:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.truffle:truffle-compiler:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.truffle:truffle-runtime:24.1.2=compileClasspath,compileOnlyDependenciesMetadata,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.truffle:truffle-api:24.1.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.truffle:truffle-compiler:24.1.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.graalvm.truffle:truffle-runtime:24.1.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.hamcrest:hamcrest-core:2.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.hamcrest:hamcrest:2.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
|
||||
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
|
||||
|
||||
@@ -21,14 +21,15 @@ plugins {
|
||||
pklAllProjects
|
||||
pklKotlinLibrary
|
||||
pklPublishLibrary
|
||||
pklNativeBuild
|
||||
pklJavaExecutable
|
||||
pklNativeExecutable
|
||||
`maven-publish`
|
||||
|
||||
// already on build script class path (see buildSrc/build.gradle.kts),
|
||||
// hence must only specify plugin ID here
|
||||
@Suppress("DSL_SCOPE_VIOLATION") id(libs.plugins.shadow.get().pluginId)
|
||||
id(libs.plugins.shadow.get().pluginId)
|
||||
|
||||
@Suppress("DSL_SCOPE_VIOLATION") alias(libs.plugins.checksum)
|
||||
alias(libs.plugins.checksum)
|
||||
}
|
||||
|
||||
// make Java executable available to other subprojects
|
||||
@@ -45,16 +46,7 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
val stagedMacAmd64Executable: Configuration by configurations.creating
|
||||
val stagedMacAarch64Executable: Configuration by configurations.creating
|
||||
val stagedLinuxAmd64Executable: Configuration by configurations.creating
|
||||
val stagedLinuxAarch64Executable: Configuration by configurations.creating
|
||||
val stagedAlpineLinuxAmd64Executable: Configuration by configurations.creating
|
||||
val stagedWindowsAmd64Executable: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.svm)
|
||||
compileOnly(libs.truffleSvm)
|
||||
implementation(libs.truffleRuntime)
|
||||
compileOnly(libs.graalSdk)
|
||||
|
||||
@@ -73,15 +65,6 @@ dependencies {
|
||||
|
||||
testImplementation(projects.pklCommonsTest)
|
||||
testImplementation(libs.wiremock)
|
||||
|
||||
fun executableDir(name: String) = files(layout.buildDirectory.dir("executable/$name"))
|
||||
stagedMacAmd64Executable(executableDir("pkl-macos-amd64"))
|
||||
stagedMacAmd64Executable(executableDir("pkl-macos-amd64"))
|
||||
stagedMacAarch64Executable(executableDir("pkl-macos-aarch64"))
|
||||
stagedLinuxAmd64Executable(executableDir("pkl-linux-amd64"))
|
||||
stagedLinuxAarch64Executable(executableDir("pkl-linux-aarch64"))
|
||||
stagedAlpineLinuxAmd64Executable(executableDir("pkl-alpine-linux-amd64"))
|
||||
stagedWindowsAmd64Executable(executableDir("pkl-windows-amd64.exe"))
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
@@ -100,15 +83,6 @@ tasks.shadowJar {
|
||||
exclude("module-info.*")
|
||||
}
|
||||
|
||||
val javaExecutable by
|
||||
tasks.registering(ExecutableJar::class) {
|
||||
inJar.set(tasks.shadowJar.flatMap { it.archiveFile })
|
||||
outJar.set(layout.buildDirectory.file("executable/jpkl"))
|
||||
|
||||
// uncomment for debugging
|
||||
// jvmArgs.addAll("-ea", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")
|
||||
}
|
||||
|
||||
val testJavaExecutable by
|
||||
tasks.registering(Test::class) {
|
||||
testClassesDirs = tasks.test.get().testClassesDirs
|
||||
@@ -116,7 +90,7 @@ val testJavaExecutable by
|
||||
// compiled test classes
|
||||
sourceSets.test.get().output +
|
||||
// java executable
|
||||
javaExecutable.get().outputs.files +
|
||||
tasks.javaExecutable.get().outputs.files +
|
||||
// test-only dependencies
|
||||
// (test dependencies that are also main dependencies must already be contained in java
|
||||
// executable;
|
||||
@@ -140,7 +114,7 @@ private fun setupJavaExecutableRun(
|
||||
configurator: Exec.() -> Unit = {},
|
||||
) =
|
||||
tasks.register(name, Exec::class) {
|
||||
dependsOn(javaExecutable)
|
||||
dependsOn(tasks.javaExecutable)
|
||||
val outputFile = layout.buildDirectory.file(name) // dummy output to satisfy up-to-date check
|
||||
outputs.file(outputFile)
|
||||
|
||||
@@ -151,7 +125,7 @@ private fun setupJavaExecutableRun(
|
||||
}
|
||||
standardOutput = OutputStream.nullOutputStream()
|
||||
|
||||
args("-jar", javaExecutable.get().outputs.files.singleFile.toString(), *args)
|
||||
args("-jar", tasks.javaExecutable.get().outputs.files.singleFile.toString(), *args)
|
||||
|
||||
doFirst { outputFile.get().asFile.delete() }
|
||||
|
||||
@@ -160,25 +134,6 @@ private fun setupJavaExecutableRun(
|
||||
configurator()
|
||||
}
|
||||
|
||||
// 0.14 Java executable was broken because javaExecutable.jvmArgs wasn't commented out.
|
||||
// To catch this and similar problems, test that Java executable starts successfully.
|
||||
val testStartJavaExecutable by
|
||||
setupJavaExecutableRun("testStartJavaExecutable", arrayOf("--version"))
|
||||
|
||||
// Setup `testStartJavaExecutable` tasks for multi-JDK testing.
|
||||
val testStartJavaExecutableOnOtherJdks =
|
||||
if (buildInfo.multiJdkTesting) {
|
||||
buildInfo.jdkTestRange.map { jdkTarget ->
|
||||
setupJavaExecutableRun(
|
||||
"testStartJavaExecutableJdk${jdkTarget.asInt()}",
|
||||
arrayOf("--version"),
|
||||
serviceOf<JavaToolchainService>().launcherFor { languageVersion = jdkTarget },
|
||||
)
|
||||
}
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
|
||||
val evalTestFlags = arrayOf("eval", "-x", "1 + 1", "pkl:base")
|
||||
|
||||
fun Exec.useRootDirAndSuppressOutput() {
|
||||
@@ -207,335 +162,35 @@ val testEvalJavaExecutableOnOtherJdks =
|
||||
tasks.check {
|
||||
dependsOn(
|
||||
testJavaExecutable,
|
||||
testStartJavaExecutable,
|
||||
testJavaExecutableOnOtherJdks,
|
||||
testStartJavaExecutableOnOtherJdks,
|
||||
testEvalJavaExecutable,
|
||||
testEvalJavaExecutableOnOtherJdks,
|
||||
)
|
||||
}
|
||||
|
||||
fun Exec.configureExecutable(
|
||||
graalVm: BuildInfo.GraalVm,
|
||||
outputFile: Provider<RegularFile>,
|
||||
extraArgs: List<String> = listOf(),
|
||||
) {
|
||||
inputs
|
||||
.files(sourceSets.main.map { it.output })
|
||||
.withPropertyName("mainSourceSets")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs
|
||||
.files(configurations.runtimeClasspath)
|
||||
.withPropertyName("runtimeClasspath")
|
||||
.withNormalizer(ClasspathNormalizer::class)
|
||||
val nativeImageCommandName = if (buildInfo.os.isWindows) "native-image.cmd" else "native-image"
|
||||
inputs
|
||||
.files(file(graalVm.baseDir).resolve("bin/$nativeImageCommandName"))
|
||||
.withPropertyName("graalVmNativeImage")
|
||||
.withPathSensitivity(PathSensitivity.ABSOLUTE)
|
||||
outputs.file(outputFile)
|
||||
outputs.cacheIf { true }
|
||||
|
||||
workingDir(outputFile.map { it.asFile.parentFile })
|
||||
executable = "${graalVm.baseDir}/bin/$nativeImageCommandName"
|
||||
|
||||
// For any system properties starting with `pkl.native`, strip off that prefix and pass the rest
|
||||
// through as arguments to native-image.
|
||||
//
|
||||
// Allow setting args using flags like
|
||||
// (-Dpkl.native-Dpolyglot.engine.userResourceCache=/my/cache/dir) when building through Gradle.
|
||||
val extraArgsFromProperties =
|
||||
System.getProperties()
|
||||
.filter { it.key.toString().startsWith("pkl.native") }
|
||||
.map { "${it.key}=${it.value}".substring("pkl.native".length) }
|
||||
|
||||
// JARs to exclude from the class path for the native-image build.
|
||||
val exclusions = listOf(libs.graalSdk).map { it.get().module.name }
|
||||
// https://www.graalvm.org/22.0/reference-manual/native-image/Options/
|
||||
argumentProviders.add(
|
||||
CommandLineArgumentProvider {
|
||||
buildList {
|
||||
// must be emitted before any experimental options are used
|
||||
add("-H:+UnlockExperimentalVMOptions")
|
||||
// currently gives a deprecation warning, but we've been told
|
||||
// that the "initialize everything at build time" *CLI* option is likely here to stay
|
||||
add("--initialize-at-build-time=")
|
||||
// needed for messagepack-java (see https://github.com/msgpack/msgpack-java/issues/600)
|
||||
add("--initialize-at-run-time=org.msgpack.core.buffer.DirectBufferAccess")
|
||||
add("--no-fallback")
|
||||
add("-H:IncludeResources=org/pkl/core/stdlib/.*\\.pkl")
|
||||
add("-H:IncludeResources=org/jline/utils/.*")
|
||||
add("-H:IncludeResourceBundles=org.pkl.core.errorMessages")
|
||||
add("-H:IncludeResources=org/pkl/commons/cli/PklCARoots.pem")
|
||||
add("-H:Class=org.pkl.cli.Main")
|
||||
add("-o")
|
||||
add(outputFile.get().asFile.name)
|
||||
// the actual limit (currently) used by native-image is this number + 1400 (idea is to
|
||||
// compensate for Truffle's own nodes)
|
||||
add("-H:MaxRuntimeCompileMethods=1800")
|
||||
add("-H:+EnforceMaxRuntimeCompileMethods")
|
||||
add("--enable-url-protocols=http,https")
|
||||
add("-H:+ReportExceptionStackTraces")
|
||||
// disable automatic support for JVM CLI options (puts our main class in full control of
|
||||
// argument parsing)
|
||||
add("-H:-ParseRuntimeOptions")
|
||||
// quick build mode: 40% faster compilation, 20% smaller (but presumably also slower)
|
||||
// executable
|
||||
if (!buildInfo.isReleaseBuild) {
|
||||
add("-Ob")
|
||||
}
|
||||
if (buildInfo.isNativeArch) {
|
||||
add("-march=native")
|
||||
} else {
|
||||
add("-march=compatibility")
|
||||
}
|
||||
// native-image rejects non-existing class path entries -> filter
|
||||
add("--class-path")
|
||||
val pathInput =
|
||||
sourceSets.main.get().output +
|
||||
configurations.runtimeClasspath.get().filter {
|
||||
it.exists() && !exclusions.any { exclude -> it.name.contains(exclude) }
|
||||
}
|
||||
add(pathInput.asPath)
|
||||
// make sure dev machine stays responsive (15% slowdown on my laptop)
|
||||
val processors =
|
||||
Runtime.getRuntime().availableProcessors() /
|
||||
if (buildInfo.os.isMacOsX && !buildInfo.isCiBuild) 4 else 1
|
||||
add("-J-XX:ActiveProcessorCount=${processors}")
|
||||
// Pass through all `HOMEBREW_` prefixed environment variables to allow build with shimmed
|
||||
// tools.
|
||||
addAll(environment.keys.filter { it.startsWith("HOMEBREW_") }.map { "-E$it" })
|
||||
addAll(extraArgs)
|
||||
addAll(extraArgsFromProperties)
|
||||
}
|
||||
}
|
||||
)
|
||||
tasks.checkNative {
|
||||
dependsOn(":pkl-core:checkNative")
|
||||
dependsOn(":pkl-server:checkNative")
|
||||
}
|
||||
|
||||
/** Builds the pkl CLI for macOS/amd64. */
|
||||
val macExecutableAmd64: TaskProvider<Exec> by
|
||||
tasks.registering(Exec::class) {
|
||||
dependsOn(":installGraalVmAmd64")
|
||||
configureExecutable(
|
||||
buildInfo.graalVmAmd64,
|
||||
layout.buildDirectory.file("executable/pkl-macos-amd64"),
|
||||
)
|
||||
}
|
||||
|
||||
/** Builds the pkl CLI for macOS/aarch64. */
|
||||
val macExecutableAarch64: TaskProvider<Exec> by
|
||||
tasks.registering(Exec::class) {
|
||||
dependsOn(":installGraalVmAarch64")
|
||||
configureExecutable(
|
||||
buildInfo.graalVmAarch64,
|
||||
layout.buildDirectory.file("executable/pkl-macos-aarch64"),
|
||||
listOf("-H:+AllowDeprecatedBuilderClassesOnImageClasspath"),
|
||||
)
|
||||
}
|
||||
|
||||
/** Builds the pkl CLI for linux/amd64. */
|
||||
val linuxExecutableAmd64: TaskProvider<Exec> by
|
||||
tasks.registering(Exec::class) {
|
||||
dependsOn(":installGraalVmAmd64")
|
||||
configureExecutable(
|
||||
buildInfo.graalVmAmd64,
|
||||
layout.buildDirectory.file("executable/pkl-linux-amd64"),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the pkl CLI for linux/aarch64.
|
||||
*
|
||||
* Right now, this is built within a container on Mac using emulation because CI does not have ARM
|
||||
* instances.
|
||||
*/
|
||||
val linuxExecutableAarch64: TaskProvider<Exec> by
|
||||
tasks.registering(Exec::class) {
|
||||
dependsOn(":installGraalVmAarch64")
|
||||
configureExecutable(
|
||||
buildInfo.graalVmAarch64,
|
||||
layout.buildDirectory.file("executable/pkl-linux-aarch64"),
|
||||
listOf(
|
||||
// Ensure compatibility for kernels with page size set to 4k, 16k and 64k
|
||||
// (e.g. Raspberry Pi 5, Asahi Linux)
|
||||
"-H:PageSize=65536"
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a statically linked CLI for linux/amd64.
|
||||
*
|
||||
* Note: we don't publish the same for linux/aarch64 because native-image doesn't support this.
|
||||
* Details: https://www.graalvm.org/22.0/reference-manual/native-image/ARM64/
|
||||
*/
|
||||
val alpineExecutableAmd64: TaskProvider<Exec> by
|
||||
tasks.registering(Exec::class) {
|
||||
dependsOn(":installGraalVmAmd64")
|
||||
configureExecutable(
|
||||
buildInfo.graalVmAmd64,
|
||||
layout.buildDirectory.file("executable/pkl-alpine-linux-amd64"),
|
||||
listOf("--static", "--libc=musl"),
|
||||
)
|
||||
}
|
||||
|
||||
val windowsExecutableAmd64: TaskProvider<Exec> by
|
||||
tasks.registering(Exec::class) {
|
||||
dependsOn(":installGraalVmAmd64")
|
||||
configureExecutable(
|
||||
buildInfo.graalVmAmd64,
|
||||
layout.buildDirectory.file("executable/pkl-windows-amd64"),
|
||||
listOf("-Dfile.encoding=UTF-8"),
|
||||
)
|
||||
}
|
||||
|
||||
tasks.assembleNative {
|
||||
when {
|
||||
buildInfo.os.isMacOsX -> {
|
||||
dependsOn(macExecutableAmd64)
|
||||
if (buildInfo.arch == "aarch64") {
|
||||
dependsOn(macExecutableAarch64)
|
||||
}
|
||||
}
|
||||
buildInfo.os.isWindows -> {
|
||||
dependsOn(windowsExecutableAmd64)
|
||||
}
|
||||
buildInfo.os.isLinux && buildInfo.arch == "aarch64" -> {
|
||||
dependsOn(linuxExecutableAarch64)
|
||||
}
|
||||
buildInfo.os.isLinux && buildInfo.arch == "amd64" -> {
|
||||
dependsOn(linuxExecutableAmd64)
|
||||
if (buildInfo.hasMuslToolchain) {
|
||||
dependsOn(alpineExecutableAmd64)
|
||||
}
|
||||
}
|
||||
}
|
||||
executable {
|
||||
name = "pkl"
|
||||
javaName = "jpkl"
|
||||
documentationName = "Pkl CLI"
|
||||
publicationName = "pkl-cli"
|
||||
javaPublicationName = "pkl-cli-java"
|
||||
mainClass = "org.pkl.cli.Main"
|
||||
website = "https://pkl-lang.org/main/current/pkl-cli/index.html"
|
||||
}
|
||||
|
||||
// make Java executable available to other subprojects
|
||||
// (we don't do the same for native executables because we don't want tasks assemble/build to build
|
||||
// them)
|
||||
artifacts {
|
||||
add("javaExecutable", javaExecutable.map { it.outputs.files.singleFile }) {
|
||||
add("javaExecutable", tasks.javaExecutable.map { it.outputs.files.singleFile }) {
|
||||
name = "pkl-cli-java"
|
||||
classifier = null
|
||||
extension = "jar"
|
||||
builtBy(javaExecutable)
|
||||
builtBy(tasks.javaExecutable)
|
||||
}
|
||||
}
|
||||
|
||||
// region Maven Publishing
|
||||
publishing {
|
||||
publications {
|
||||
register<MavenPublication>("javaExecutable") {
|
||||
artifactId = "pkl-cli-java"
|
||||
|
||||
artifact(javaExecutable.map { it.outputs.files.singleFile }) {
|
||||
classifier = null
|
||||
extension = "jar"
|
||||
builtBy(javaExecutable)
|
||||
}
|
||||
|
||||
pom {
|
||||
url.set("https://github.com/apple/pkl/tree/main/pkl-cli")
|
||||
description.set(
|
||||
"""
|
||||
Pkl CLI executable for Java.
|
||||
Can be executed directly, or with `java -jar <path/to/jpkl>`.
|
||||
Requires Java 17 or higher.
|
||||
"""
|
||||
.trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
create<MavenPublication>("macExecutableAmd64") {
|
||||
artifactId = "pkl-cli-macos-amd64"
|
||||
artifact(stagedMacAmd64Executable.singleFile) {
|
||||
classifier = null
|
||||
extension = "bin"
|
||||
builtBy(stagedMacAmd64Executable)
|
||||
}
|
||||
pom {
|
||||
name.set("pkl-cli-macos-amd64")
|
||||
url.set("https://github.com/apple/pkl/tree/main/pkl-cli")
|
||||
description.set("Native Pkl CLI executable for macOS/amd64.")
|
||||
}
|
||||
}
|
||||
create<MavenPublication>("macExecutableAarch64") {
|
||||
artifactId = "pkl-cli-macos-aarch64"
|
||||
artifact(stagedMacAarch64Executable.singleFile) {
|
||||
classifier = null
|
||||
extension = "bin"
|
||||
builtBy(stagedMacAarch64Executable)
|
||||
}
|
||||
pom {
|
||||
name.set("pkl-cli-macos-aarch64")
|
||||
url.set("https://github.com/apple/pkl/tree/main/pkl-cli")
|
||||
description.set("Native Pkl CLI executable for macOS/aarch64.")
|
||||
}
|
||||
}
|
||||
create<MavenPublication>("linuxExecutableAmd64") {
|
||||
artifactId = "pkl-cli-linux-amd64"
|
||||
artifact(stagedLinuxAmd64Executable.singleFile) {
|
||||
classifier = null
|
||||
extension = "bin"
|
||||
builtBy(stagedLinuxAmd64Executable)
|
||||
}
|
||||
pom {
|
||||
name.set("pkl-cli-linux-amd64")
|
||||
url.set("https://github.com/apple/pkl/tree/main/pkl-cli")
|
||||
description.set("Native Pkl CLI executable for linux/amd64.")
|
||||
}
|
||||
}
|
||||
create<MavenPublication>("linuxExecutableAarch64") {
|
||||
artifactId = "pkl-cli-linux-aarch64"
|
||||
artifact(stagedLinuxAarch64Executable.singleFile) {
|
||||
classifier = null
|
||||
extension = "bin"
|
||||
builtBy(stagedLinuxAarch64Executable)
|
||||
}
|
||||
pom {
|
||||
name.set("pkl-cli-linux-aarch64")
|
||||
url.set("https://github.com/apple/pkl/tree/main/pkl-cli")
|
||||
description.set("Native Pkl CLI executable for linux/aarch64.")
|
||||
}
|
||||
}
|
||||
create<MavenPublication>("alpineLinuxExecutableAmd64") {
|
||||
artifactId = "pkl-cli-alpine-linux-amd64"
|
||||
artifact(stagedAlpineLinuxAmd64Executable.singleFile) {
|
||||
classifier = null
|
||||
extension = "bin"
|
||||
builtBy(stagedAlpineLinuxAmd64Executable)
|
||||
}
|
||||
pom {
|
||||
name.set("pkl-cli-alpine-linux-amd64")
|
||||
url.set("https://github.com/apple/pkl/tree/main/pkl-cli")
|
||||
description.set("Native Pkl CLI executable for linux/amd64 and statically linked to musl.")
|
||||
}
|
||||
}
|
||||
|
||||
create<MavenPublication>("windowsExecutableAmd64") {
|
||||
artifactId = "pkl-cli-windows-amd64"
|
||||
artifact(stagedWindowsAmd64Executable.singleFile) {
|
||||
classifier = null
|
||||
extension = "exe"
|
||||
builtBy(stagedWindowsAmd64Executable)
|
||||
}
|
||||
pom {
|
||||
name.set("pkl-cli-windows-amd64")
|
||||
url.set("https://github.com/apple/pkl/tree/main/pkl-cli")
|
||||
description.set("Native Pkl CLI executable for windows/amd64.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
sign(publishing.publications["javaExecutable"])
|
||||
sign(publishing.publications["linuxExecutableAarch64"])
|
||||
sign(publishing.publications["linuxExecutableAmd64"])
|
||||
sign(publishing.publications["macExecutableAarch64"])
|
||||
sign(publishing.publications["macExecutableAmd64"])
|
||||
sign(publishing.publications["alpineLinuxExecutableAmd64"])
|
||||
sign(publishing.publications["windowsExecutableAmd64"])
|
||||
} // endregion
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.cli.svm;
|
||||
|
||||
import org.graalvm.nativeimage.hosted.Feature;
|
||||
import org.pkl.core.runtime.BaseModule;
|
||||
|
||||
/**
|
||||
* This class is registered with native-image via a CLI option (see Gradle task `nativeExecutable`).
|
||||
*/
|
||||
@SuppressWarnings({"unused", "ResultOfMethodCallIgnored"})
|
||||
public final class InitFeature implements Feature {
|
||||
/**
|
||||
* Enforce that {@link BaseModule#getModule()}'s static initializer completes before depending
|
||||
* static initializers are invoked. This is necessary to avoid deadlocks in native-image's
|
||||
* multi-threaded execution of static initializers. It's not clear at this point if multi-threaded
|
||||
* initialization on the JVM could also deadlock, i.e., if this is a Pkl bug.
|
||||
*/
|
||||
public void duringSetup(DuringSetupAccess access) {
|
||||
BaseModule.getModule();
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.cli.svm;
|
||||
|
||||
import com.oracle.svm.core.annotate.Alias;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
|
||||
/**
|
||||
* native-image can't determine how calls to {@link sun.misc.Unsafe#arrayBaseOffset(Class)} affect
|
||||
* static fields in msgpack's {@code MessageBuffer}.
|
||||
*
|
||||
* <p>This informs the compiler which field to re-compute.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@TargetClass(className = "org.msgpack.core.buffer.MessageBuffer")
|
||||
final class MessagePackRecomputations {
|
||||
@Alias
|
||||
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.ArrayBaseOffset, declClass = byte[].class)
|
||||
static int ARRAY_BYTE_BASE_OFFSET;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.cli.svm;
|
||||
|
||||
import com.oracle.svm.core.annotate.Alias;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import com.oracle.svm.truffle.TruffleFeature;
|
||||
import java.util.Map;
|
||||
import org.pkl.core.ast.builder.AstBuilder;
|
||||
|
||||
/**
|
||||
* Workaround to prevent the native-image build error "Detected a started Thread in the image
|
||||
* heap.". The cause of this error is the use of {@link org.graalvm.polyglot.Context} in the
|
||||
* (intentionally) statically reachable class {@link org.pkl.core.runtime.StdLibModule}.
|
||||
*
|
||||
* <p>A cleaner solution would be to have a separate {@link AstBuilder} for stdlib modules that
|
||||
* produces a fully initialized module object without executing any Truffle nodes.
|
||||
*
|
||||
* <p>This class is automatically discovered by native-image; no registration is required.
|
||||
*/
|
||||
@SuppressWarnings({"unused", "ClassName"})
|
||||
@TargetClass(
|
||||
className = "com.oracle.truffle.polyglot.PolyglotContextImpl",
|
||||
onlyWith = {TruffleFeature.IsEnabled.class})
|
||||
public final class PolyglotContextImplTarget {
|
||||
@Alias
|
||||
@RecomputeFieldValue(kind = Kind.NewInstance, declClassName = "java.util.HashMap")
|
||||
public Map<?, ?> threads;
|
||||
|
||||
@Alias
|
||||
@RecomputeFieldValue(kind = Kind.Reset)
|
||||
public WeakAssumedValueTarget singleThreadValue;
|
||||
|
||||
@Alias
|
||||
@RecomputeFieldValue(kind = Kind.Reset)
|
||||
public PolyglotThreadInfoTarget cachedThreadInfo;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.cli.svm;
|
||||
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import com.oracle.svm.truffle.TruffleFeature;
|
||||
|
||||
/** Makes non-public class PolyglotThreadInfo usable above. */
|
||||
@TargetClass(
|
||||
className = "com.oracle.truffle.polyglot.PolyglotThreadInfo",
|
||||
onlyWith = {TruffleFeature.IsEnabled.class})
|
||||
public final class PolyglotThreadInfoTarget {}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.cli.svm;
|
||||
|
||||
import com.oracle.svm.core.annotate.Alias;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
||||
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import com.oracle.svm.truffle.TruffleFeature;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@TargetClass(
|
||||
className = "com.oracle.truffle.api.impl.ThreadLocalHandshake",
|
||||
onlyWith = {TruffleFeature.IsEnabled.class})
|
||||
public final class ThreadLocalHandshakeTarget {
|
||||
@Alias
|
||||
@RecomputeFieldValue(kind = Kind.NewInstance, declClassName = "java.util.HashMap")
|
||||
static Map<?, ?> SAFEPOINTS;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.cli.svm;
|
||||
|
||||
import com.oracle.svm.core.annotate.TargetClass;
|
||||
import com.oracle.svm.truffle.TruffleFeature;
|
||||
|
||||
/** Makes non-public class WeakAssumedValue usable. */
|
||||
@TargetClass(
|
||||
className = "com.oracle.truffle.polyglot.WeakAssumedValue",
|
||||
onlyWith = {TruffleFeature.IsEnabled.class})
|
||||
public final class WeakAssumedValueTarget {}
|
||||
Reference in New Issue
Block a user