summaryrefslogtreecommitdiff
path: root/README
blob: 3c094f8bea6ce4bfc3f290de32223e053b7786d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Project Blackbird
=================

Make Fermyon Spin WebAssembly Modules run on NGINX Unit.

The repository will contain some exploratory tools.

Quickstart
==========

Clone the spin repository

$ git clone https://github.com/fermyon/spin.git

Build the wasm module.

$ cd spin/examples/wasi-http-rust
$ cargo build --target wasm32-wasi

Grab the Wasmtime C API

$ wget -O- https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.0/wasmtime-v13.0.0-x86_64-linux-c-api.tar.xz | tar -xvf -

Clone this repository

$ git clone git://git.digital-domain.net/project_blackbird.git

Build it

$ cd project_blackbird/c/wasmtime-wasi-http
$ make WASMTIME_C_API=/path/to/wasmtime-c-api WASM_MODULE=/path/to/spin/examples/wasi-http-rust/target/wasm32-wasi/debug/wasi_http_rust.wasm

Run it

$ ./wasmtime-wasi-http
Initializing...
Loading binary...
Compiling module...
Setting function imports...
    [poll2::poll-oneoff]
    [streams2::read]
    [streams2::blocking-read]
    [streams2::subscribe-to-input-stream]
    [streams2::write]
    [streams2::blocking-write]
    [streams2::subscribe-to-output-stream]
    [default-outgoing-HTTP2::handle]
    [types2::new-fields]
    [types2::fields-entries]
    [types2::finish-incoming-stream]
    [types2::finish-outgoing-stream]
    [types2::incoming-request-method]
    [types2::incoming-request-path-with-query]
    [types2::incoming-request-headers]
    [types2::incoming-request-consume]
    [types2::new-outgoing-request]
    [types2::outgoing-request-write]
    [types2::set-response-outparam]
    [types2::incoming-response-status]
    [types2::incoming-response-headers]
    [types2::incoming-response-consume]
    [types2::new-outgoing-response]
    [types2::outgoing-response-write]
    [types2::future-incoming-response-get]
    [types2::listen-to-future-incoming-response]
Initialising WASI...
Instantiating module...
Getting function exports...
    [HTTP#handle]
    [cabi_realloc]
Shutting down...
Done.


Component Model
===============

You can play with the component model under rust/hello_world

This requires some new tools

   - https://github.com/bytecodealliance/wit-bindgen
   - https://github.com/bytecodealliance/wasm-tools

 You can use the pre-built packages, once downloaded and untar'd, edit

   rust/hello_world/component/Makefile

 and adjust the paths for the above tools.

 To build the component with make you may need to specify where the WASI
 sysroot is

   $ make WASI_SYSROOT=/path/to/wasi-sysroot

You can then build the Rust runtime under rust/hello_world with

  $ cargo build

after a while (sheesh) it should finish... then you can run it with

  $ target/debug/hello_world

it won't actually print anything, but also shouldn't give an error.