Introduce C library for Pkl (#1238)

This uses native-image to generate a C library for Pkl.
This generated library from native-image is wrapped with our own library,
in `pkl.h`.

This produces a static and a dynamic library for each os/arch variant
that Pkl currently supports.

Co-authored-by: Kushal Pisavadia <kushal.p@apple.com>
Co-authored-by: Jen Basch <jbasch94@gmail.com>
Co-authored-by: Islon Scherer <i_desouzascherer@apple.com>
This commit is contained in:
Daniel Chao
2026-07-25 04:15:26 +00:00
committed by GitHub
co-authored by Kushal Pisavadia Jen Basch Islon Scherer
parent 175e2b6273
commit 67df676359
51 changed files with 4982 additions and 349 deletions
+15 -5
View File
@@ -1,7 +1,6 @@
extends "GradleJob.pkl"
import "@gha/catalog.pkl"
import "@gha/context.pkl"
/// Whether to link to musl. Otherwise, links to glibc.
musl: Boolean(implies(module.os == "linux")) = false
@@ -9,6 +8,11 @@ musl: Boolean(implies(module.os == "linux")) = false
/// The Gradle project under which to generate the executable
project: String
/// Path pattern for artifact uploads (glob passed to actions/upload-artifact)
buildDir: String = "\(project)*/build/executable/**/*"
local needsCCompiler = project == "libpkl"
extraGradleArgs {
when (musl) {
"-Dpkl.musl=true"
@@ -40,22 +44,28 @@ steps {
run = #"git status || git config --system --add safe.directory "$GITHUB_WORKSPACE""#
}
}
when (needsCCompiler && os == "windows") {
new {
name = "Set up MSVC"
uses = "ilammy/msvc-dev-cmd@v1"
}
}
new {
name = "gradle buildNative"
shell = "bash"
run = "./gradlew \(module.gradleArgs) \(project):buildNative"
}
(catalog.`actions/upload-artifact@v5`) {
name = "Upload executable artifacts"
name = "Upload built artifacts"
with {
name =
if (musl)
"executable-\(project)-alpine-\(module.os)-\(module.arch)"
"artifacts-\(project)-alpine-\(module.os)-\(module.arch)"
else
"executable-\(project)-\(module.os)-\(module.arch)"
"artifacts-\(project)-\(module.os)-\(module.arch)"
// Need to insert a wildcard to make actions/upload-artifact preserve the folder hierarchy.
// See https://github.com/actions/upload-artifact/issues/206
path = "\(project)*/build/executable/**/*"
path = module.buildDir
}
}
}