tensorush / zpin Goto Github PK
View Code? Open in Web Editor NEWZig Spin SDK.
Home Page: https://tensorush.github.io/zpin/
License: MIT License
Zig Spin SDK.
Home Page: https://tensorush.github.io/zpin/
License: MIT License
One big issue I find with packaging project is that the build is also responsible for generating the source and headers from WIT files. However, this is not done by any of the upstream SDKs. For example:
By vendoring the code, this would not require that end-users to have wit-bindgen
installed and would be much easier to consume from Zig. Is this something this project would be interested in doing?
I would love to leverage this project in zig-fermyon-router over WAGI, but not having this packaged makes this difficult to do. I am interested in helping to contribute changes to make this happen as well!
Kia ora @tensorush, I'm excited to see this and try it out! Unfortunately I stumbled at a pretty early fence and wondered if you could advise.
I created a build.zig.zon
as you described, and a build.zig
although I had to expand it a bit from the README. I think I followed the repo's build.zig
but might have got something wrong. (Details of both below.) My src/main.zig
is copied exactly from examples/http-in
in this repo. It builds and produces a .wasm
output, and spin up
runs, but the Wasm module traps when I curl it.
Is it possible to get a full example of using the Zig Spin SDK from a codebase outside the SDK itself please? (I'm happy to send a PR once I get something working... I'm just a bit stuck for now.)
Zig version: 0.12.0
Spin version: local build from current source
Host OS: Ubuntu 22.04 (on WSL)
Build command: zig build
My build.zig.zon
:
.{
.name = "example",
.version = "0.0.1",
.dependencies = .{
.spin = .{
.url = "https://github.com/tensorush/zig-spin/archive/refs/tags/v0.7.0.tar.gz",
.hash = "12206d63934cce31aa5d8a4d5c7fd52643b537cda89af057bb6ccae232d17cb31ad5",
},
},
.paths = .{
"src/",
"build.zig",
"build.zig.zon",
},
}
My build.zig
(which is where I'm guessing I went wrong):
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .wasi,
});
const exe = b.addExecutable(.{
.name = "example",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
});
const spin_dep = b.dependency("spin", .{});
const spin_mod = spin_dep.module("spin");
exe.root_module.addImport("spin", spin_mod);
b.installArtifact(exe);
}
The trap error that Spin prints:
ERROR spin_trigger_http: Error processing request: error while executing at wasm backtrace:
0: 0x9b57 - <unknown>!spin_http_handle_http_request
1: 0x2178 - <unknown>!__wasm_export_spin_http_handle_http_request
2: 0x3fbcb - wit-component:adapter:wasi_snapshot_preview1!fermyon:spin/inbound-http#handle-request
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
Caused by:
wasm trap: uninitialized element
(This makes me wonder if main
has not run and set spin.http.HANDLER
but I'm not sure if that's right or why it would be.)
Thanks for your help!
Provide deinit()
user functions to easily free memory allocated by this library.
Transition to wit-bindgen
master to be fully competitive with the Spin's default Rust implementation.
As the first step, this will require updating WIT files to these ones.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.