diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 930dfed..482959c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/bindgen-test.sh b/bindgen-test.sh index 5eeb6c1..c1e9a9e 100644 --- a/bindgen-test.sh +++ b/bindgen-test.sh @@ -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 ;; diff --git a/template/build.zig.ejs b/template/build.zig.ejs index 77d6e66..919f468 100644 --- a/template/build.zig.ejs +++ b/template/build.zig.ejs @@ -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"); <% } -%> diff --git a/template/build.zig.zon.ejs b/template/build.zig.zon.ejs index 85e0e9a..141c5f7 100644 --- a/template/build.zig.zon.ejs +++ b/template/build.zig.zon.ejs @@ -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", @@ -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 = .{ diff --git a/template/prepare.sh b/template/prepare.sh new file mode 100755 index 0000000..f31746a --- /dev/null +++ b/template/prepare.sh @@ -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" diff --git a/template/xtp.toml.ejs b/template/xtp.toml.ejs index 713d6b7..520714c 100644 --- a/template/xtp.toml.ejs +++ b/template/xtp.toml.ejs @@ -15,4 +15,4 @@ build = "zig build" format = "zig fmt ." # xtp plugin init runs this script before running the format script -prepare = "" \ No newline at end of file +prepare = "bash prepare.sh" diff --git a/tests/test.sh b/tests/test.sh index 96e554a..f9e2745 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -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