Commit Graph

421 Commits

Author SHA1 Message Date
Dan Chao
fc1114fd2e Remove resources/ directory from executable dir 0.28.1 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
Islon Scherer
52c2b29a04 change version to 0.28.0 2025-02-26 17:09:14 +01:00
Daniel Chao
cf889246fd Add release notes for 0.28 (#978)
Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-02-26 07:52:21 -08:00
Daniel Chao
fcce5c7e11 Replace dead links to ANTLR parser grammar (#973) 2025-02-21 08:26:49 -08:00
odenix
52a86d3f32 Untangle external reader code (#776)
- move the following classes into package externalreader:
  - ExternalModuleResolver
  - ExternalResourceResolver
  - MessageTransportModuleResolver (renamed to ExternalModuleResolverImpl, made package-private)
  - MessageTransportResourceResolver (renamed to ExternalResourceResolverImpl, made package-private)
- replace interface ExternalModuleResolver.Spec with record ExternalModuleReaderSpec
- replace interface ExternalResourceResolver.Spec with record ExternalResourceReaderSpec
- translate between messaging.ResourceReaderSpec and ExternalResourceReaderSpec (eliminates dependency from messaging on higher layer)
- translate between messaging.ResourceResolverSpec and ExternalResourceResolverSpec (eliminates dependency from messaging on higher layer)
- add ServerMessages.ExternalReader and translate between this message component and the PklEvaluatorSettings.ExternalReader API
- add ServerMessages.Proxy and translate between this message component and the PklEvaluatorSettings.Proxy API
- change type of CreateEvaluatorRequest.allowedModules/allowedResources from List<Pattern>? to List<String>?
  - removes a lot of code
  - should not need to create a Pattern object to send a message
- deprecate method evaluatorSettings.PklEvaluatorSettings.Proxy.create()
  - only seems useful internally, inlined

Co-authored-by: Dan Chao <dan.chao@apple.com>
2025-02-20 22:38:51 -08:00
Daniel Chao
31c80e792e Ensure findOrAddAuxiliarySlot is not called during compilation (#969)
Fixes an issue that is preventing the native executable from building
2025-02-20 08:09:22 -08:00
Artem Yarmoliuk
50cfb1c962 Bump clikt to 5.0.3 (#947)
This bumps Clikt from version 3 to version 5, which, among other things, improves
the help text formatting with colors.

Also: 
* Add `--version` flag to pkldoc, pkl-codegen-java, pkl-codegen-kotlin
* Add help text to pkldoc, pkl-codegen-java, pkl-codegen-kotlin
2025-02-19 15:18:02 -08:00
Daniel Chao
643c6f5a76 Execute typechecks eagerly when within a constraint (#964)
This changes the language to check all types eagerly when within a type constraint.

This addresses two regressions in the language:

1. Type constraints are too relaxed (listing/mapping parameters may not be checked)
2. Failing type constraints hide members that were forced during execution of the constraint
2025-02-19 12:51:52 -08:00
Daniel Chao
227f0637fc Rename package ast to syntax (#968) 2025-02-19 10:57:41 -08:00
Vladimir Matveev
baa34a6dd1 Added support for an alternative current dir mode in pkldoc (#824)
Some systems have trouble with handling symlinks, which breaks the current directory links created by Pkldoc. In this PR, we add an alternative mode which creates a full copy of the latest published version contents in the current directory instead.

Co-authored-by: Dan Chao <dan.chao@apple.com>
2025-02-19 08:52:32 -08:00
Islon Scherer
2ffd201172 move handling of strings to parser (#962) 2025-02-19 17:19:48 +01:00
Daniel Chao
ee23a8c3f4 Make CliktCommands classes (#963)
Missed these three classes.

This prevents the AOT compiler from statically initializing CLI argument
default values (like working dir).
2025-02-18 08:29:59 -08:00
Daniel Chao
28b128f86f Run spotless formatting (#958)
When we updated spotless's Java and Kotlin formatter, we changed the underlying
formatting rules.
However, due to spotless ratcheting, these formatting changes don't get applied unless a file
gets touched in a commit.

To avoid future PRs introducing lines of change that aren't related to the intention of the PR,
this is a one-time format of all files.
2025-02-17 07:36:43 -08:00
Islon Scherer
d270829ed3 fix calculation of spans in parser (#957) 2025-02-15 12:11:55 +01:00
Michael Case
350b71a634 Fix incorrect glob example (#956)
Correct glob docs and use realistic file extensions.
2025-02-14 13:31:04 -08:00
Daniel Chao
28df90527b Add docs for various keywords (#955) 2025-02-14 13:30:22 -08:00
Daniel Chao
eabfcdd333 Allow -DcommitId flag when building Pkl (#954)
This is to allow building Pkl in environments that don't have access
to git.
2025-02-14 09:36:47 -08:00
Daniel Chao
1a4f9ee72e Improve handling of errors when analysis fails (#948)
Modules that cannot be loaded for one reason or another now cause a Pkl Exception,
with the offending import highlighted as part of the stack trace.
2025-02-13 14:00:48 -08:00
Daniel Chao
65cf3237b7 Add parser benchmarks (#953)
The current benchmark is not too useful now that we have a linear parser.

This changes the benchmarks to parse the standard library, and also the language snippet tests.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-02-13 11:22:31 -08:00
Daniel Chao
d00d0ba79f Update dependencies (#938) 2025-02-13 10:19:24 -08:00
Josh B
f56b1bb84f Test and document supercalls using the same method/property name (#943) 2025-02-12 21:10:37 -08:00
Islon Scherer
b526902bf0 Replace ANTLR with hand-rolled parser (#917)
Co-authored-by: Kushal Pisavadia <kushi.p@gmail.com>
Co-authored-by: Daniel Chao <daniel.h.chao@gmail.com>
2025-02-12 18:11:00 +01:00
Daniel Chao
7c3f8ad261 Improve documentation about Set/Map ordering (#944)
The language reference and stdlib are both slightly incorrect;
maps and sets are ordered when iterated on, but unordered in terms of
equality.
2025-02-12 06:43:51 -08:00
Daniel Chao
7ed710c226 Make commands classes instead of objects (#946)
Making these classes caused native-image to statically initialize
them at build time, which included CLI argument default values
(like working dir).

This turns them back into classes.

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
2025-02-11 06:38:19 -08:00
Josh B
ad99e4a7f7 Correctly set allowed modules/resoures when external reader scheme contain regex control characters (#941) 2025-02-07 14:03:40 -08:00
Daniel Chao
e85e888f92 [docs] Add documetation about release/evolution/roadmap (#937) 2025-02-05 11:24:41 -08:00
Daniel Chao
3b6fbdff15 Remove usages of VmFunction#apply(Object) (#936)
These call sites should use `ApplyVmFunction1Node` instead.
2025-02-05 09:18:42 -08:00
Daniel Chao
9784cd7265 Turn CLI commands into objects, self register subcommands (#935)
Usages of `RootCommand` no longer need to initialize a new instance, nor register subcommands.
2025-02-05 09:18:23 -08:00
Daniel Chao
aadcccd0fc Run a simple eval script (#928)
Execute `1 + 1` instead of eval'ing `circleci.pkl` (might cause
spurious failures due to requirement on network connection).
2025-02-04 07:21:57 -08:00
Daniel Chao
9075ca0729 Fix native gvm ci (#930)
* Update GraalVM checksum
* Fix: download JDK on macOS

Signed-off-by: Sam Gammon <sam@elide.dev>
Co-authored-by: Sam Gammon <sam@elide.dev>
2025-02-04 07:21:42 -08:00
Sam Gammon
5e12dfb200 fix: upgrade ci jobs to jdk 21 (#926)
Signed-off-by: Sam Gammon <sam@elide.dev>
2025-02-03 17:17:07 -08:00
Sam Gammon
408242a44c Upgrade GraalVM and Truffle, set up multi-JDK testing, bump development Java to 21 (#876)
This updates the GraalVM and Truffle libraries to 2024.1.2.

This also updates the build logic to compile Java sources using Java 21, due to some compile-only dependencies within GraalVM/Truffle using class file version 65. However, the produced artifact is still compatible with Java 17.

This also changes the Gradle build logic to use toolchains, and to test the Java libraries with JDK 17 and 21.

One consequence of this change is that Truffle is no longer shaded within the fat jars.

feat: support for jvm21+ toolchain
feat: support for gradle toolchains
feat: pass -PnativeArch=native to build with -march=native
test: multi-jdk testing support
test: support for jvm-test-suite plugin
test: add tasks to run jpkl eval on multiple jdks
test: make jdk exec tests respect multi-jdk flags and ranges
fix: remove mrjar classes at >jvm17 from fatjars
fix: use jdk21 to run the tests (needed for Unsafe.ensureInitialized)
fix: truffle svm dependency is required after graalvm 24.0.0
fix: warnings for gvm flag usage, renamed truffle svm macro
fix: build with --add-modules=jdk.unsupported where needed
fix: don't use gu tool for modern graalvm versions
fix: catch Throwable instead of deprecated-for-removal ThreadDeath
chore: buildinfo changes for JVM targets, toolchains
chore: enforce testing at exactly jdk21
chore: enforce build tooling at jdk21+
chore: bump graalvm/truffle libs → 24.1.2
chore: toolchains for buildSrc

Signed-off-by: Sam Gammon <sam@elide.dev>
2025-02-03 14:57:40 -08:00
Stanley Cheung
8cfd2357c6 Fix typo in tutorial part 2 (#921) 2025-01-31 07:53:22 -08:00
Sam Gammon
3fa935b390 fix: downstream native-image builds (#914)
SVM (SubstrateVM) compile configuration classes
must be included within the `cli` jar to prevent
downstream `native-image` builds from failing.

Fat JARs cannot be used with `native-image`, so
these classes can still safely be excluded here.

Fixes and closes apple/pkl#907

Signed-off-by: Sam Gammon <sam@elide.dev>
2025-01-29 20:31:05 -08:00
Kushal Pisavadia
aa8a0f18e8 Simplify inputs for javadocJar (#916)
Also, rename `dummy` to `placeholder`
2025-01-29 09:46:39 -08:00
Daniel Chao
3815a0206b Optimization: execute const object bodies and typechecks only once (#915)
If the object member is const, it only needs to be executed once, and all children in the prototype chain can use its cached value.

There is a possible other optimization here, not included in this PR: we can avoid adding these values to the child object's cachedMembers.
2025-01-29 07:19:55 -08:00
odenix
90df0662af Overhaul implementation of for-generators (#844)
Motivation:
* fix known bugs and limitations of for-generators
* improve code health by removing complex workarounds

Changes:
* simplify AstBuilder code related to for-generators
  * track for-generators via `SymbolTable.enterForGenerator()`
  * add `RestoreForBindingsNode` during initial AST construction
    instead of calling `MemberNode.replaceBody()` later on
  * simplify some unnecessarily complex code
* remove workarounds and band-aids such as:
  * `isInIterable`
  * `executeAndSetEagerly`
  * adding dummy slots in `AmendFunctionNode`
* overhaul implementation of for-generators
  * store keys and values of for-generator iterations in regular instead of auxiliary frame slots
    * set them via `TypeNode.executeAndSet()`
    * `ResolveVariableNode` no longer needs to search auxiliary slots
    * `Read(Enclosing)AuxiliarySlot` is no longer needed
  * at the start of each for-generator iteration, create a new `VirtualFrame`
    that is a copy of the current frame (arguments + slots)
    and stores the iteration key and value in additional slots.
  * execute for-generator iteration with the newly created frame
    * `childNode.execute(newFrame)`
    * Pkl objects created during the iteration will materialize this frame
  * store newly created frames in `owner.extraStorage`
    if their for-generator slots may be accessed when a generated member is executed
    * resolving variable names to for-generator variables at parse time would make this analysis more precise
  * when a generated member is executed,
	  * retrieve the corresponding frame stored in `owner.extraStorage`
	  * copy the retrieved frame's for-generator slots into slots of the current frame

Result:
* for-generators are implemented in a correct, reasonably simple, and reasonably efficient way
  * complexity is fully contained within package `generator` and `AstBuilder`
* for-generator keys and values can be accessed from all nested scopes:
  * key and value expressions of generated members
  * condition expressions of nested when-generators
  * iterable expressions of nested for-generators
* for-generator keys and values can be accessed from within objects created by the expressions listed above
* sibling for-generators can use the same key/value variable names
* parent/child for-generators can use the same key/value variable names
* fixes https://github.com/apple/pkl/issues/741
2025-01-28 14:06:42 -08:00
Kushal Pisavadia
11169d6691 Upgrade gradle to 8.12.1 (from 8.12) and fix some build warnings (#910)
Build warning fixes:

* Return `tasks.register` as `tasks.create` is deprecated
* Use property accessor `.files` instead of function `.files()`
2025-01-27 15:01:19 -08:00
Daniel Chao
5dc672731d Bump minimum Gradle version to 8.2 (#901)
The Kotlin 2.0 version upgrade made us incompatible with Gradle 8.1.

Given that it is now over 1.5 years old, this drops support for it, and
raises the minimum version to 8.2.
2025-01-27 10:04:31 -08:00
odenix
258eda8630 Update Kotlin to 2.0 (#900)
- update Kotlin from 1.7.10 to 2.0.21
  - Kotlin 1.6 dependencies in Gradle lock files are expected because kotlinc,
    which is also used by some tests, internally uses some 1.6 dependencies
    for backwards compatibility reasons.
- update kotlinx-html and kotlinx-serialization
- adapt Kotlin code where necessary
- use Kotlin stdlib Path APIs where possible
- fix IntelliJ Kotlin inspection warnings
- reformat code with `./gradlew spotlessApply`
  - ktfmt adds lots of trailing commas
- Add workaround to fix IntelliJ "unresolved reference" errors
2025-01-23 14:41:59 -08:00
Daniel Chao
cdd6d52642 Only run Gradle compatibility tests against minimum and maximum release (#898)
Currently, we run against every release version, which is taking 20
minutes to run in CI, and this will grow as Gradle creates more
releases.

This limits the amount of Gradle versions being tested against;
theoretically, only testing against the minimum version and the maximum
version should ensure that we are compatible with every version in the
range.
2025-01-22 14:08:45 -08:00
Daniel Chao
29049ac437 Import release notes for 0.27.2 (#897) 2025-01-22 09:36:48 -08:00
Daniel Chao
2a9b10097d Revert "Upgrade Kotlin to 1.7.21 (#887)" (#896)
This reverts commit 273d1219a6.
2025-01-22 08:33:06 -08:00