Giter VIP home page Giter VIP logo

zpin's People

Contributors

ethanholz avatar tensorush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zpin's Issues

Recommendation to vendor the C headers and source into the repo

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!

Full example of standalone build

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.)

Additional information

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.