mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 14:20:35 +01:00
[PR #1026] [MERGED] C library for Pkl #857
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/1026
Author: @KushalP
Created: 3/18/2025
Status: ✅ Merged
Merged: 5/28/2025
Merged by: @bioball
Base:
c-library← Head:c-library-for-pkl📝 Commits (10+)
84f9cfbC library for Pkldc85b52Rename toLibPklLibrary6876907Removelibprefix from.hand.cfiles5a9e685Add doxygen-style comments topkl.hfilee44e441Move pointer next to variable namef0c4176Add TODO comment to clean this up once on a feature-branchb09abffAdd@SuppressWarnings("unused")annotation toLibPklclass6102e45MoveLibPklconstructor between fields and methods1996964Addpackage-info.javafororg.pkl.libpklpackage30c1a46Propagate paramhandlerContextso users can trace messages📊 Changes
17 files changed (+1919 additions, -3 deletions)
View changed files
📝
buildSrc/src/main/kotlin/NativeImageBuild.kt(+5 -1)📝
gradle/libs.versions.toml(+1 -0)➕
libpkl/gradle.lockfile(+81 -0)➕
libpkl/libpkl.gradle.kts(+316 -0)➕
libpkl/src/main/c/pkl.c(+86 -0)➕
libpkl/src/main/c/pkl.h(+52 -0)➕
libpkl/src/main/java/org/pkl/libpkl/LibPkl.java(+96 -0)➕
libpkl/src/main/java/org/pkl/libpkl/LibPklLogger.java(+29 -0)➕
libpkl/src/main/java/org/pkl/libpkl/NativeInputStream.java(+46 -0)➕
libpkl/src/main/java/org/pkl/libpkl/NativeTransport.java(+70 -0)➕
libpkl/src/main/java/org/pkl/libpkl/package-info.java(+4 -0)➕
libpkl/src/test/kotlin/org/pkl/libpkl/JNATestClient.kt(+112 -0)➕
libpkl/src/test/kotlin/org/pkl/libpkl/LibPklLibrary.kt(+37 -0)➕
libpkl/src/test/kotlin/org/pkl/libpkl/MessagePackDebugRenderer.kt(+107 -0)➕
libpkl/src/test/kotlin/org/pkl/libpkl/NativeTest.kt(+873 -0)📝
pkl-core/src/main/java/org/pkl/core/messaging/MessageTransports.java(+2 -2)📝
settings.gradle.kts(+2 -0)📄 Description
This introduces native C bindings for Pkl.
Dynamic Library
Using
org.graalvm.nativeimageand thenative-imagebinary weproduce a dynamic library (for each OS/Arch variant) that provides a
way to initialise itself with a
graal_isolatethread_t.Methods are annotated with
@CEntryPointand exported.This change results in an architecture and OS-specific directory being
created which now produces the headers for our shared library
functions:
libpklThe produced
libpkldynamic library wraps the GraalVM C interfaceinto something that is future-friendly for the needs of a Pkl
integrator. It exports an interface which aligns with SPICE-0015[1].
JNA
Testing of the produced
libpkldynamic library is done using JavaNative Access[2] for ease. We provide an
interfacein Kotlin whichJNA transposes against the
libpkldynamic library discoverable atthe path that is discoverable with
jna.library.path.Load in
projects.pklCommonsClito deal withUnsupportedFeatureExceptionThis is to deal with the following error:
[1] https://github.com/apple/pkl-evolution/pull/16
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.