Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
npm run build

- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
uses: mlugg/setup-zig@v2
with:
version: 0.13.0
version: 0.14.0

- name: Check Zig Version
run: zig version
Expand Down
5 changes: 3 additions & 2 deletions bindgen-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ case $1 in
# Using ../../bundle so we test the bindgen template
PLUGIN_NAME=exampleplugin
echo "generating initial plugin code in '$(pwd)/$PLUGIN_NAME'..."
xtp plugin init --schema-file schema.yaml --template ../../bundle --path $PLUGIN_NAME --name $PLUGIN_NAME --feature stub-with-code-samples
xtp plugin init --schema-file schema.yaml --template ../../bundle --path $PLUGIN_NAME --name $PLUGIN_NAME --feature stub-with-code-samples --app my-app-id
echo "building '$PLUGIN_NAME'..."
xtp plugin build --path $PLUGIN_NAME
# xtp plugin build --path $PLUGIN_NAME
cd $PLUGIN_NAME && zig build && cd ..
echo "testing '$PLUGIN_NAME'..."
xtp plugin test $PLUGIN_NAME/zig-out/bin/plugin.wasm --with test.wasm --mock-host mock.wasm
;;
Expand Down
2 changes: 1 addition & 1 deletion template/build.zig.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{
.default_target = .{ .abi = .musl, .os_tag = BUILD_TARGET_OS, .cpu_arch = .wasm32 },
});
const pdk_module = b.dependency("extism-pdk", .{ .target = target, .optimize = optimize }).module("extism-pdk");
const pdk_module = b.dependency("extism_pdk", .{ .target = target, .optimize = optimize }).module("extism-pdk");
<% if(JSON.stringify(schema).includes("date-time")) { -%>
const datetime_module = b.dependency("datetime", .{ .target = target, .optimize = optimize }).module("datetime");
<% } -%>
Expand Down
9 changes: 5 additions & 4 deletions template/build.zig.zon.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.{
.name = "<%- project.name %>",
.name = .<%- project.name %>,
.fingerprint = 0x0000000000000000,
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.0.0",
Expand All @@ -15,9 +16,9 @@
// Once all dependencies are fetched, `zig build` no longer requires
// internet connectivity.
.dependencies = .{
.@"extism-pdk" = .{
.url = "https://github.com/extism/zig-pdk/archive/refs/tags/v1.3.0.tar.gz",
.hash = "1220d21f918a4e96d7ccea385d7609d97c39430d027997f82121e3fbae273e4d4c06",
.@"extism_pdk" = .{
.url = "https://github.com/extism/zig-pdk/archive/refs/heads/main.tar.gz",
.hash = "1220682ba11bf3e5470f6c508a77e272c020a89af8971ba579f82b8acb6b7f040229",
},
<% if(JSON.stringify(schema).includes("date-time")) { -%>
.datetime = .{
Expand Down
10 changes: 10 additions & 0 deletions template/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Extract the last hex value using grep with a regular expression
# The pattern looks for 0x followed by hexadecimal digits at the end of the string
fingerprint=$(zig build 2>&1 | grep -o '0x[0-9a-f]\+$')
echo "Fingerprint: $fingerprint"
# Replace the fingerprint in the generated code
sed "s/\.fingerprint = 0x0000000000000000,/\.fingerprint = $fingerprint,/" "build.zig.zon" > "build.zig.zon.tmp"
rm "build.zig.zon"
mv "build.zig.zon.tmp" "build.zig.zon"
2 changes: 1 addition & 1 deletion template/xtp.toml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ build = "zig build"
format = "zig fmt ."

# xtp plugin init runs this script before running the format script
prepare = ""
prepare = "bash prepare.sh"
5 changes: 3 additions & 2 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ cd tests
for file in ./schemas/*.yaml; do
echo "Generating and testing $file..."
rm -rf output
xtp plugin init --schema-file $file --template ../bundle --path output -y --feature stub-with-code-samples --name output
xtp plugin init --schema-file $file --template ../bundle --path output -y --feature stub-with-code-samples --name output --app my-app-id --extension-point my-extension-point-id
cd output
xtp plugin build
# xtp plugin build
zig build
cd ..
done