17 Commits

Author SHA1 Message Date
Dan Chao
8bd738ec0b Prepare 0.28.2 release 2025-04-17 08:27:51 -07:00
Daniel Chao
7569b96088 Add release notes for 0.28.2 (#1042) 2025-04-17 08:24:33 -07:00
Daniel Chao
ad131b5543 Adjust installation docs (#1010) 2025-04-16 21:17:58 -07:00
Pedro Piñera Buendía
640cc129db Document how to install pkl with Mise (#982) 2025-04-16 21:17:53 -07:00
Daniel Chao
1d14a750a5 Fix incorrect substring (#1028)
The relative path should be based off the module name prefix, not the
package name.
2025-04-16 21:09:18 -07:00
Jeroen Soeters
6a1d56bb4d Do not crash, but suggest '--multiple-file-output-path' when specifying a directory as output file (#1038)
When specifying a directory instead of a file for the output, pkl won't crash anymore, but instead output an error message, suggesting --multiple-file-output-path.
2025-04-16 21:09:12 -07:00
Kushal Pisavadia
0902cbc628 Build with m2pro.large instances, not macos.m1.large.gen1 (#1020)
* Update `com.circleci.v2` to `1.5.0` and `pkl.impl.circleci` to `1.2.0`

See:
- https://github.com/apple/pkl-pantry/pull/103
- https://github.com/apple/pkl-project-commons/pull/7

* Build with `m2pro.large` instances, not `macos.m1.large.gen1`
2025-04-16 21:09:03 -07:00
Daniel Chao
7717b702b2 Add optimization for generator bodies that don't introduce new members (#1013)
If a generator object literal doesn't add any object members, we
can simply use the parent in its place.

Co-authored-by: Kushal Pisavadia <kushi.p@gmail.com>
2025-04-16 21:08:55 -07:00
mbvissers
c5c0c20caa Fix typo in evolution-and-roadmap.adoc (#1031) 2025-04-01 11:55:39 -07:00
Dan Chao
fc1114fd2e Remove resources/ directory from executable dir 2025-03-03 09:44:24 -08:00
Dan Chao
2b24d2838c Run spotless apply 2025-03-03 09:23:27 -08:00
Dan Chao
917d110e46 Prepare 0.28.1 release 2025-03-03 09:16:48 -08:00
Daniel Chao
11cc9b96bd Add release notes for 0.28.1 (#1003) 2025-03-03 09:16:24 -08:00
Daniel Chao
ab9a231341 Allow native-image flags to be passed through from Gradle properties (#1001)
Allow other build environments (e.g. homebrew) to configure the native-image build without requiring source code changes.
2025-03-03 09:02:57 -08:00
Daniel Chao
cf18ce3d65 Fix shadow jar logic (#998)
Fix an incorrect relocation setting.

Also, add tests to start the shadow jar, and also to test the shadow jar settings.
2025-03-03 09:02:52 -08:00
Daniel Chao
a225258ebf Make Truffle use fallback runtime in Gradle plugin (#995)
Using native libraries in Gradle plugins is problematic; this adds some flags that causes Truffle to use a fallback runtime that avoids loading native libraries.
2025-03-03 09:02:46 -08:00
Daniel Chao
393d939a2c Add Kotlin version bump to breaking changes (#987) 2025-02-26 14:06:43 -08:00
48 changed files with 381 additions and 72 deletions

View File

@@ -14,7 +14,7 @@
// limitations under the License.
//===----------------------------------------------------------------------===//
// File gets rendered to .circleci/config.yml via git hook.
amends "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.circleci@1.1.1#/PklCI.pkl"
amends "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.circleci@1.2.0#/PklCI.pkl"
import "jobs/BuildNativeJob.pkl"
import "jobs/GradleCheckJob.pkl"
@@ -148,6 +148,8 @@ jobs {
command = #"""
# exclude build_artifacts.txt from publish
rm -f pkl-cli/build/executable/*.build_artifacts.txt
find pkl-cli/build/executable/* -type d | xargs rm -rf
rm -f pkl-cli/build/executable/resources
gh release create "${CIRCLE_TAG}" \
--title "${CIRCLE_TAG}" \
--target "${CIRCLE_SHA1}" \

View File

@@ -34,7 +34,7 @@ jobs:
environment:
LANG: en_US.UTF-8
JAVA_HOME: /Users/distiller/jdk/Contents/Home
resource_class: macos.m1.large.gen1
resource_class: m2pro.large
macos:
xcode: 15.3.0
pkl-cli-linux-amd64-release:
@@ -142,7 +142,7 @@ jobs:
environment:
LANG: en_US.UTF-8
JAVA_HOME: /Users/distiller/jdk/Contents/Home
resource_class: macos.m1.large.gen1
resource_class: m2pro.large
macos:
xcode: 15.3.0
pkl-cli-linux-aarch64-release:
@@ -347,7 +347,7 @@ jobs:
environment:
LANG: en_US.UTF-8
JAVA_HOME: /Users/distiller/jdk/Contents/Home
resource_class: macos.m1.large.gen1
resource_class: m2pro.large
macos:
xcode: 15.3.0
pkl-cli-linux-amd64-snapshot:
@@ -455,7 +455,7 @@ jobs:
environment:
LANG: en_US.UTF-8
JAVA_HOME: /Users/distiller/jdk/Contents/Home
resource_class: macos.m1.large.gen1
resource_class: m2pro.large
macos:
xcode: 15.3.0
pkl-cli-linux-aarch64-snapshot:
@@ -735,6 +735,8 @@ jobs:
command: |-
# exclude build_artifacts.txt from publish
rm -f pkl-cli/build/executable/*.build_artifacts.txt
find pkl-cli/build/executable/* -type d | xargs rm -rf
rm -f pkl-cli/build/executable/resources
gh release create "${CIRCLE_TAG}" \
--title "${CIRCLE_TAG}" \
--target "${CIRCLE_SHA1}" \

View File

@@ -16,7 +16,7 @@
/// Builds the native `pkl` CLI
extends "GradleJob.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.1.2#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.5.0#/Config.pkl"
/// The architecture to use
arch: "amd64"|"aarch64"
@@ -158,7 +158,7 @@ job {
macos {
xcode = "15.3.0"
}
resource_class = "macos.m1.large.gen1"
resource_class = "m2pro.large"
environment {
["JAVA_HOME"] = "/Users/distiller/jdk/Contents/Home"
}

View File

@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
extends "GradleJob.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.1.2#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.5.0#/Config.pkl"
local self = this

View File

@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
extends "GradleJob.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.1.2#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.5.0#/Config.pkl"
steps {
new Config.RunStep {

View File

@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
abstract module GradleJob
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.1.2#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.5.0#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3#/URI.pkl"
/// Whether this is a release build or not.

View File

@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
extends "GradleJob.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.1.2#/Config.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/com.circleci.v2@1.5.0#/Config.pkl"
name: String = command

View File

@@ -42,20 +42,20 @@ val relocations =
"org.organicdesign.fp." to "org.pkl.thirdparty.paguro.",
"org.snakeyaml.engine." to "org.pkl.thirdparty.snakeyaml.engine.",
"org.msgpack." to "org.pkl.thirdparty.msgpack.",
"org.w3c.dom." to "org.pkl.thirdparty.w3c.dom",
"org.w3c.dom." to "org.pkl.thirdparty.w3c.dom.",
"com.oracle.svm.core." to "org.pkl.thirdparty.svm.",
// pkl-cli dependencies
"org.jline." to "org.pkl.thirdparty.jline.",
"com.github.ajalt.clikt." to "org.pkl.thirdparty.clikt.",
"com.github.ajalt.colormath" to "org.pkl.thirdparty.colormath.",
"com.github.ajalt.mordant" to "org.pkl.thirdparty.mordant",
"com.sun.jna" to "org.pkl.thirdparty.jna",
"com.github.ajalt.colormath." to "org.pkl.thirdparty.colormath.",
"com.github.ajalt.mordant." to "org.pkl.thirdparty.mordant.",
"com.sun.jna." to "org.pkl.thirdparty.jna.",
"kotlin." to "org.pkl.thirdparty.kotlin.",
"kotlinx." to "org.pkl.thirdparty.kotlinx.",
"org.intellij." to "org.pkl.thirdparty.intellij.",
"org.fusesource.jansi." to "org.pkl.thirdparty.jansi",
"org.fusesource.hawtjni." to "org.pkl.thirdparty.hawtjni",
"org.fusesource.jansi." to "org.pkl.thirdparty.jansi.",
"org.fusesource.hawtjni." to "org.pkl.thirdparty.hawtjni.",
// pkl-doc dependencies
"org.commonmark." to "org.pkl.thirdparty.commonmark.",
@@ -71,6 +71,19 @@ val relocations =
"com.squareup.kotlinpoet." to "org.pkl.thirdparty.kotlinpoet.",
)
for ((key, value) in relocations) {
if (!key.endsWith(".")) {
throw GradleException(
"Invalid relocation `\"$key\" to \"$value\"`: `$key` should end with a dot"
)
}
if (!value.endsWith(".")) {
throw GradleException(
"Invalid relocation `\"$key\" to \"$value\"`: `$value` should end with a dot"
)
}
}
val nonRelocations = listOf("com/oracle/truffle/", "org/graalvm/")
tasks.shadowJar {

View File

@@ -1,6 +1,6 @@
name: main
title: Main Project
version: 0.28.0
version: 0.28.2
prerelease: false
nav:
- nav.adoc

View File

@@ -7,7 +7,7 @@
Sometimes, a change to Pkl is large enough that it makes sense to create a proposal for the change so that it can be discussed in detail and vetted.
Pkl has a process for managing such designs in a repository called {uri-pkl-evolution}[Pkl Evolutiuon].
Pkl has a process for managing such designs in a repository called {uri-pkl-evolution}[Pkl Evolution].
== Roadmap
@@ -17,4 +17,4 @@ The roadmap describes estimates.
The Pkl team aims to cut a release in February, June, and October of each year.
If an item is not complete by the release cutoff date, the roadmap item may be bumped to the next release.
Additionally, as priorities change, it is possible that items can be moved around, or backlogged.
Additionally, as priorities change, it is possible that items can be moved around or backlogged.

View File

@@ -3,7 +3,7 @@
// the following attributes must be updated immediately before a release
// pkl version corresponding to current git commit without -dev suffix or git hash
:pkl-version-no-suffix: 0.28.0
:pkl-version-no-suffix: 0.28.2
// tells whether pkl version corresponding to current git commit
// is a release version (:is-release-version: '') or dev version (:!is-release-version:)
:is-release-version: ''

View File

@@ -1,6 +1,7 @@
= CLI
include::ROOT:partial$component-attributes.adoc[]
:uri-homebrew: https://brew.sh
:uri-mise: https://mise.jdx.dev
:uri-sonatype-snapshot-download: https://s01.oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.pkl-lang&v={pkl-artifact-version}
:uri-pkl-macos-amd64-download: {uri-sonatype-snapshot-download}&a=pkl-cli-macos-amd64&e=bin
@@ -84,6 +85,29 @@ ifndef::is-release-version[]
For instructions, switch to a release version of this page.
endif::[]
[[mise]]
=== Mise
On macOS, Linux, and Windows, release versions can be installed with {uri-mise}[Mise].
ifdef::is-release-version[]
To install Pkl, run:
[source,shell]
[subs="+attributes"]
----
# Install and activate Pkl globally
mise use -g pkl@{pkl-version}
# Install and activate Pkl locally
mise use pkl@{pkl-version}
----
endif::[]
ifndef::is-release-version[]
For instructions, switch to a release version of this page.
endif::[]
[[download]]
=== Download

View File

@@ -1,6 +1,6 @@
= Pkl 0.28 Release Notes
:version: 0.28
:version-minor: 0.28.0
:version-minor: 0.28.2
:release-date: February 26th, 2025
include::ROOT:partial$component-attributes.adoc[]
@@ -256,6 +256,10 @@ foo { ...bar...baz } // Syntax error
The minimum Gradle version for the xref:main:pkl-gradle:index.adoc[Gradle Plugin] has been bumped to 8.2 (https://github.com/apple/pkl/pull/901[#901]).
=== Minimum Kotlin version bump
For users of Pkl's Kotlin libraries, the minimum Kotlin version has been bumped to 2.0 (https://github.com/apple/pkl/pull/900[#900]).
=== Java/Kotlin API breaking changes
Breaking changes have been made to the Java/Kotlin APIs (https://github.com/apple/pkl/pull/748[#748], https://github.com/apple/pkl/pull/749[#749], https://github.com/apple/pkl/pull/776[#776], https://github.com/apple/pkl/pull/793[#793], https://github.com/apple/pkl/pull/808[#808], https://github.com/apple/pkl/pull/810[#810]).
@@ -337,7 +341,6 @@ For users that use both Pkl and other Truffle languages, this means that their v
* Documentation improvements (https://github.com/apple/pkl/pull/792[#792], https://github.com/apple/pkl/pull/846[#846], https://github.com/apple/pkl/pull/860[#860], https://github.com/apple/pkl/pull/892[#892], https://github.com/apple/pkl/pull/921[#921], https://github.com/apple/pkl/pull/937[#937], https://github.com/apple/pkl/pull/943[#943], https://github.com/apple/pkl/pull/944[#944], https://github.com/apple/pkl/pull/955[#955], https://github.com/apple/pkl/pull/956[#956], https://github.com/apple/pkl/pull/973[#973]).
* The repository now requires Java 21 or higher to build (https://github.com/apple/pkl/pull/876[#876]).
* Enable multi-jdk testing via `-DmultiJdkTesting=true` flag when building Pkl (https://github.com/apple/pkl/pull/876[#876]).
* Pkl's version of Kotlin has been upgraded to 2.0 (https://github.com/apple/pkl/pull/900[#900]).
* Allow setting commit id via `-DcommitId` flag when building Pkl (https://github.com/apple/pkl/pull/954[#954]).
== Bugs fixed [small]#🐜#

View File

@@ -1,6 +1,43 @@
= Changelog
include::ROOT:partial$component-attributes.adoc[]
[[release-0.28.2]]
== 0.28.2 (2025-04-17)
=== Fixes
* Adds an optimization when object bodies with generators produce no members (https://github.com/apple/pkl/pull/1013[#1013]).
* Fixes a runtime crash when `--output-path` points to a directory (https://github.com/apple/pkl/pull/1038[#1038]).
* Fixes a bug that sometimes causes pkl-doc to crash (https://github.com/apple/pkl/pull/1028[#1028]).
=== Miscellaneous
* Documentation improvements (https://github.com/apple/pkl/pull/982[#982], https://github.com/apple/pkl/pull/1010[#1010], https://github.com/apple/pkl/pull/1031[#1031]).
* CI improvements (https://github.com/apple/pkl/pull/1020[#1020]).
=== Contributors ❤️
Thank you to all the contributors for this release!
* https://github.com/JeroenSoeters[@JeroenSoeters]
* https://github.com/KushalP[@KushalP]
* https://github.com/mbvissers[@mbvissers]
* https://github.com/pepicrft[@pepicrft]
[[release-0.28.1]]
== 0.28.1 (2025-03-03)
=== Fixes
* Fixes an issue where Pkl Gradle tasks can possibly fail with `java.lang.UnsatisfiedLinkError` (https://github.com/apple/pkl/pull/995[#995]).
* Fixes an issue where the artifacts pkl-tools and pkl-config-java-all fail with `java.lang.ClassFormatError` (https://github.com/apple/pkl/pull/998[#998]).
=== Changes
* Adds the ability to configure `native-image` build with Gradle system properties (https://github.com/apple/pkl/pull/1001[#1001]).
+
Now, any system property starting with `"pkl.native"` will have that prefix stripped, and the rest passed as CLI arguments to `native-image`. For example, the native-image resource cache can be configured by passing Gradle flag `-Dpkl.native-Dpolyglot.engine.userResourceCache=/my/cache/dir`.
[[release-0.28.0]]
== 0.28.0 (2025-02-26)

View File

@@ -1,7 +1,7 @@
# suppress inspection "UnusedProperty" for whole file
group=org.pkl-lang
version=0.28.0
version=0.28.2
# google-java-format requires jdk.compiler exports
org.gradle.jvmargs= \

View File

@@ -2,15 +2,15 @@
"catalogs": {},
"aliases": {
"pkl": {
"script-ref": "org.pkl-lang:pkl-cli-java:0.28.0",
"script-ref": "org.pkl-lang:pkl-cli-java:0.28.2",
"java-agents": []
},
"pkl-codegen-java": {
"script-ref": "org.pkl-lang:pkl-codegen-java:0.28.0",
"script-ref": "org.pkl-lang:pkl-codegen-java:0.28.2",
"java-agents": []
},
"pkl-codegen-kotlin": {
"script-ref": "org.pkl-lang:pkl-codegen-kotlin:0.28.0",
"script-ref": "org.pkl-lang:pkl-codegen-kotlin:0.28.2",
"java-agents": []
}
},

View File

@@ -237,6 +237,16 @@ fun Exec.configureExecutable(
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/
@@ -294,6 +304,7 @@ fun Exec.configureExecutable(
// tools.
addAll(environment.keys.filter { it.startsWith("HOMEBREW_") }.map { "-E$it" })
addAll(extraArgs)
addAll(extraArgsFromProperties)
}
}
)

View File

@@ -19,6 +19,7 @@ import java.io.File
import java.io.Reader
import java.io.Writer
import java.net.URI
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardOpenOption
import kotlin.io.path.createParentDirectories
@@ -152,6 +153,12 @@ constructor(
for ((moduleUri, outputFile) in outputFiles) {
val moduleSource = toModuleSource(moduleUri, consoleReader)
val output = evaluator.evaluateExpressionString(moduleSource, options.expression)
if (Files.isDirectory(outputFile)) {
throw CliException(
"Output file `$outputFile` is a directory. " +
"Did you mean `--multiple-file-output-path`?"
)
}
outputFile.createParentDirectories()
if (!writtenFiles.contains(outputFile)) {
// write file even if output is empty to overwrite output from previous runs

View File

@@ -725,6 +725,39 @@ result = someLib.x
assertThat(output).endsWith("\n")
}
@Test
fun `file output throws if output file is a directory`() {
val sourceFiles =
listOf(
writePklFile(
"test.pkl",
"""
name = "test"
output {
files {
["\(name).txt"] {
text = "test"
}
}
}
"""
.trimIndent(),
)
)
val err =
assertThrows<CliException> {
evalToFiles(
CliEvaluatorOptions(
CliBaseOptions(sourceModules = sourceFiles),
outputPath = tempDir.toString(),
)
)
}
assertThat(err)
.hasMessageContaining("Output file `$tempDir` is a directory. ")
.hasMessageContaining("Did you mean `--multiple-file-output-path`?")
}
@Test
fun `multiple file output writes multiple files to the provided directory`() {
val contents =

View File

@@ -73,6 +73,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
@Specialization(guards = "checkObjectCannotHaveParameters()")
protected VmDynamic evalDynamic(VirtualFrame frame, VmDynamic parent) {
var data = executeChildren(frame, parent, parent.getLength());
if (data.hasNoMembers()) {
return parent;
}
var result = new VmDynamic(frame.materialize(), parent, data.members(), data.length());
return data.storeGeneratorFrames(result);
}
@@ -81,6 +84,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
protected VmTyped evalTyped(VirtualFrame frame, VmTyped parent) {
VmUtils.checkIsInstantiable(parent.getVmClass(), getParentNode());
var data = executeChildren(frame, parent, 0);
if (data.hasNoMembers()) {
return parent;
}
assert data.hasNoGeneratorFrames();
return new VmTyped(frame.materialize(), parent, parent.getVmClass(), data.members());
}
@@ -88,6 +94,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
@Specialization(guards = "checkListingCannotHaveParameters()")
protected VmListing evalListing(VirtualFrame frame, VmListing parent) {
var data = executeChildren(frame, parent, parent.getLength());
if (data.hasNoMembers()) {
return parent;
}
var result = new VmListing(frame.materialize(), parent, data.members(), data.length());
return data.storeGeneratorFrames(result);
}
@@ -95,6 +104,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
@Specialization(guards = "checkMappingCannotHaveParameters()")
protected VmMapping evalMapping(VirtualFrame frame, VmMapping parent) {
var data = executeChildren(frame, parent, 0);
if (data.hasNoMembers()) {
return parent;
}
var result = new VmMapping(frame.materialize(), parent, data.members());
return data.storeGeneratorFrames(result);
}
@@ -118,6 +130,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
@Specialization(guards = {"parent == getDynamicClass()", "checkObjectCannotHaveParameters()"})
protected VmDynamic evalDynamicClass(VirtualFrame frame, VmClass parent) {
var data = executeChildren(frame, parent, 0);
if (data.hasNoMembers()) {
return VmDynamic.empty();
}
var result =
new VmDynamic(frame.materialize(), parent.getPrototype(), data.members(), data.length());
return data.storeGeneratorFrames(result);
@@ -126,6 +141,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
@Specialization(guards = {"parent == getMappingClass()", "checkMappingCannotHaveParameters()"})
protected VmMapping evalMappingClass(VirtualFrame frame, VmClass parent) {
var data = executeChildren(frame, parent, 0);
if (data.hasNoMembers()) {
return VmMapping.empty();
}
var result = new VmMapping(frame.materialize(), parent.getPrototype(), data.members());
return data.storeGeneratorFrames(result);
}
@@ -133,6 +151,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
@Specialization(guards = {"parent == getListingClass()", "checkListingCannotHaveParameters()"})
protected VmListing evalListingClass(VirtualFrame frame, VmClass parent) {
var data = executeChildren(frame, parent, 0);
if (data.hasNoMembers()) {
return VmListing.empty();
}
var result =
new VmListing(frame.materialize(), parent.getPrototype(), data.members(), data.length());
return data.storeGeneratorFrames(result);
@@ -142,6 +163,9 @@ public abstract class GeneratorObjectLiteralNode extends ObjectLiteralNode {
protected VmTyped evalTypedObjectClass(VirtualFrame frame, VmClass parent) {
VmUtils.checkIsInstantiable(parent, getParentNode());
var data = executeChildren(frame, parent, 0);
if (data.hasNoMembers()) {
return parent.getPrototype();
}
assert data.hasNoGeneratorFrames();
return new VmTyped(frame.materialize(), parent.getPrototype(), parent, data.members());
}

View File

@@ -55,6 +55,10 @@ public final class ObjectData {
return length;
}
boolean hasNoMembers() {
return members.isEmpty();
}
boolean hasNoGeneratorFrames() {
return generatorFrames.isEmpty();
}

View File

@@ -33,7 +33,7 @@ import org.pkl.core.util.Nullable;
@TruffleLanguage.Registration(
id = "pkl",
name = "Pkl",
version = "0.28.0",
version = "0.28.2",
characterMimeTypes = VmLanguage.MIME_TYPE,
contextPolicy = ContextPolicy.SHARED)
public final class VmLanguage extends TruffleLanguage<VmContext> {

View File

@@ -0,0 +1,46 @@
// should only result in one trace in the output; generator object literals that don't add any
// members should be optimized away.
res1 {
prop = trace("hello")
}
res2 = (res1) {
when (false) {
prop2 = 2
}
}
res3 = (res1) {
for (_ in List()) {
"hello"
}
}
res4 = (res1) {
...List()
}
res5 = (res1) {
when (true) {
} else {
prop3 = 3
}
}
res6 = (Dynamic) {
when (true) {}
}
res7 = (Mapping) {
when (true) {}
}
class Person {}
res8 = (Person) {
when (true) {}
}
res9 = (Listing) {
when (true) {}
}

View File

@@ -0,0 +1,20 @@
res1 {
prop = "hello"
}
res2 {
prop = "hello"
}
res3 {
prop = "hello"
}
res4 {
prop = "hello"
}
res5 {
prop = "hello"
}
res6 {}
res7 {}
res8 {}
res9 {}
pkl: TRACE: "hello" = "hello" (file:///$snippetsDir/input/generators/generatorNoMembers.pkl)

View File

@@ -414,7 +414,9 @@ private fun findTypesUsedBy(
enclosingPackage.name,
enclosingPackage.uri,
enclosingPackage.version,
enclosingType.moduleName.substring(enclosingPackage.name.length + 1).replace('.', '/'),
enclosingType.moduleName
.substring(enclosingPackage.moduleNamePrefix.length)
.replace('.', '/'),
PClassInfo.MODULE_CLASS_NAME,
)
)

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* 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.
@@ -49,6 +49,11 @@ import org.pkl.core.util.Nullable;
import org.pkl.gradle.utils.PluginUtils;
public abstract class BasePklTask extends DefaultTask {
private static final String TRUFFLE_USE_FALLBACK_RUNTIME_FLAG = "truffle.UseFallbackRuntime";
private static final String POLYGLOT_WARN_INTERPRETER_ONLY_FLAG =
"polyglot.engine.WarnInterpreterOnly";
@Input
public abstract ListProperty<String> getAllowedModules();
@@ -137,9 +142,26 @@ public abstract class BasePklTask extends DefaultTask {
@Optional
public abstract ListProperty<String> getHttpNoProxy();
/**
* There are issues with using native libraries in Gradle plugins. As a workaround for now, make
* Truffle use an un-optimized runtime.
*
* @see <a
* href="https://discuss.gradle.org/t/loading-a-native-library-in-a-gradle-plugin/44854">https://discuss.gradle.org/t/loading-a-native-library-in-a-gradle-plugin/44854</a>
* @see <a
* href="https://github.com/apple/pkl/issues/988">https://github.com/apple/pkl/issues/988</a>
*/
// TODO: Remove this workaround when ugprading to Truffle 24.2+ (Truffle automatically falls back
// in this scenario).
protected void withFallbackTruffleRuntime(Runnable task) {
System.setProperty(TRUFFLE_USE_FALLBACK_RUNTIME_FLAG, "true");
System.setProperty(POLYGLOT_WARN_INTERPRETER_ONLY_FLAG, "false");
task.run();
}
@TaskAction
public void runTask() {
doRunTask();
withFallbackTruffleRuntime(this::doRunTask);
}
protected abstract void doRunTask();

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* 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.
@@ -133,7 +133,7 @@ public abstract class ModulesTask extends BasePklTask {
if (getCliBaseOptions().getNormalizedSourceModules().isEmpty()) {
throw new InvalidUserDataException("No source modules specified.");
}
doRunTask();
withFallbackTruffleRuntime(this::doRunTask);
}
@Internal

View File

@@ -15,6 +15,8 @@
*/
import java.nio.charset.StandardCharsets
import java.util.*
import kotlin.io.path.createDirectories
import kotlin.io.path.writeText
plugins {
pklAllProjects
@@ -65,6 +67,63 @@ val javadocJar by
tasks.shadowJar { archiveBaseName.set("pkl-tools-all") }
private fun Exec.configureTestStartFatJar(launcher: Provider<JavaLauncher>) {
dependsOn(tasks.shadowJar)
group = "verification"
// placeholder output to satisfy up-to-date check
val outputFile = layout.buildDirectory.file("testStartFatJar/${name}.txt")
outputs.file(outputFile)
inputs.files(tasks.shadowJar)
executable = launcher.get().executablePath.asFile.absolutePath
argumentProviders.add(
CommandLineArgumentProvider {
buildList {
add("-cp")
add(tasks.shadowJar.get().outputs.files.singleFile.absolutePath)
add("org.pkl.cli.Main")
add("eval")
add("-x")
add("1 + 1")
add("pkl:base")
}
}
)
doLast {
outputFile.get().asFile.toPath().let { file ->
file.parent.createDirectories()
file.writeText("OK")
}
}
}
val testStartFatJar by
tasks.registering(Exec::class) { configureTestStartFatJar(buildInfo.javaTestLauncher) }
tasks.validateFatJar { dependsOn(testStartFatJar) }
for (jdkTarget in buildInfo.jdkTestRange) {
if (buildInfo.jdkToolchainVersion == jdkTarget) {
tasks.register("testStartFatJarJdk${jdkTarget.asInt()}") {
group = "verification"
description = "alias for testStartFatJar"
dependsOn(testStartFatJar)
}
} else {
val task =
tasks.register("testStartFatJarJdk${jdkTarget.asInt()}", Exec::class) {
val launcher = project.javaToolchains.launcherFor { languageVersion = jdkTarget }
configureTestStartFatJar(launcher)
}
if (buildInfo.multiJdkTesting) {
tasks.validateFatJar { dependsOn(task) }
}
}
}
publishing {
publications {
named<MavenPublication>("fatJar") {

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -36,7 +36,7 @@
///
/// Warning: Although this module is ready for initial use,
/// benchmark results may be inaccurate or inconsistent.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.Benchmark
import "pkl:platform" as _platform

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -63,7 +63,7 @@
/// @Deprecated { message = "Use `com.example.Birds.Parrot` instead" }
/// amends "pkl:PackageInfo"
/// ```
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.DocPackageInfo
import "pkl:reflect"

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -31,7 +31,7 @@
///
/// title = "Title displayed in the header of each page"
/// ```
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.DocsiteInfo
import "pkl:reflect"

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// Common settings for Pkl's own evaluator.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
@Since { version = "0.26.0" }
module pkl.EvaluatorSettings

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -64,7 +64,7 @@
/// value = project
/// }
/// ```
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.Project
import "pkl:EvaluatorSettings" as EvaluatorSettingsModule

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -19,7 +19,7 @@
/// These tools differentiate from [pkl:reflect][reflect] in that they parse Pkl modules, but do not
/// execute any code within these modules.
@Since { version = "0.27.0" }
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.analyze
// used by doc comments

View File

@@ -17,7 +17,7 @@
/// Fundamental properties, methods, and classes for writing Pkl programs.
///
/// Members of this module are automatically available in every Pkl module.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.base
import "pkl:jsonnet"

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// A JSON parser.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.json
/// A JSON parser.

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// A [Jsonnet](https://jsonnet.org) renderer.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.jsonnet
/// Constructs an [ImportStr].

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -18,7 +18,7 @@
///
/// Note that some mathematical functions, such as `sign()`, `abs()`, and `round()`,
/// are directly defined in classes [Number], [Int], and [Float].
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.math
/// The minimum [Int] value: `-9223372036854775808`.

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// Information about the platform that the current program runs on.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.platform
/// The platform that the current program runs on.

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -16,7 +16,7 @@
/// A renderer for [Protocol Buffers](https://developers.google.com/protocol-buffers).
/// Note: This module is _experimental_ and not ready for production use.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.protobuf
import "pkl:reflect"

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -26,7 +26,7 @@
/// - Documentation generators (such as *Pkldoc*)
/// - Code generators (such as *pkl-codegen-java* and *pkl-codegen-kotlin*)
/// - Domain-specific schema validators
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.reflect
import "pkl:base"

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// Information about the Pkl release that the current program runs on.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.release
import "pkl:semver"

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// Parsing, comparison, and manipulation of [semantic version](https://semver.org/spec/v2.0.0.html) numbers.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.semver
/// Tells whether [version] is a valid semantic version number.

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -19,7 +19,7 @@
/// Every settings file must amend this module.
/// Unless CLI commands and build tool plugins are explicitly configured with a settings file,
/// they will use `~/.pkl/settings.pkl` or the defaults specified in this module.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.settings
import "pkl:EvaluatorSettings"

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// Utilities for generating shell scripts.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.shell
/// Escapes [str] by enclosing it in single quotes.

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -18,7 +18,7 @@
///
/// To write tests, amend this module and define [facts] or [examples] (or both).
/// To run tests, evaluate the amended module.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
open module pkl.test
/// Named groups of boolean expressions that are expected to evaluate to [true].

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// An XML renderer.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.xml
/// Renders values as XML.

View File

@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// 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.
@@ -15,7 +15,7 @@
//===----------------------------------------------------------------------===//
/// A YAML 1.2 compliant YAML parser.
@ModuleInfo { minPklVersion = "0.28.0" }
@ModuleInfo { minPklVersion = "0.28.2" }
module pkl.yaml
/// A YAML parser.