Skip to content

Commit 2e5c599

Browse files
Rev to wasi-http 0.2.0 (#10)
* Update for wasi-http 0.2.0 * Rename files to match version
1 parent facd418 commit 2e5c599

File tree

8 files changed

+107
-106
lines changed

8 files changed

+107
-106
lines changed

.devcontainer/devcontainer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"PATH": "${containerEnv:PATH}:/usr/local/lib/wasi-sdk-20.0/bin:/usr/local/lib"
66
},
77
"features": {
8-
"devwasm.azurecr.io/dev-wasm/dev-wasm-feature/wasmtime-wasi:0.0.14": {
8+
"devwasm.azurecr.io/dev-wasm/dev-wasm-feature/wasmtime-wasi:0.0.15": {
99
"version": "20",
10-
"wasmtime_version": "v15.0.1",
11-
"wit_version": "0.16.0"
10+
"wasmtime_version": "v18.0.2",
11+
"wit_version": "0.19.2"
1212

1313
},
1414
"ghcr.io/devcontainers/features/common-utils": {}

Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
cc := /usr/local/lib/wasi-sdk-20.0/bin/clang
1+
sdk := /usr/local/lib/wasi-sdk-20.0
2+
cc := ${sdk}/bin/clang
3+
cpp := ${sdk}/bin/clang++
24

35
.phony: all clean
46

57
default: all
68

79
main.wasm: main.c
8-
clang -o main.wasm main.c
10+
${cc} -o main.wasm main.c
911

1012
run_c: main.wasm
1113
wasmtime --dir . main.wasm
1214

1315
main-cc.wasm: main.cc
14-
clang++ -o main-cc.wasm main.cc
16+
${cpp} -o main-cc.wasm main.cc
1517

1618
run_cc: main-cc.wasm
1719
wasmtime --dir . main-cc.wasm

http/Makefile

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ client.o : client.c
1919
libwasihttp.a: ${lib_objs}
2020
${ar} cr libwasihttp.a ${lib_objs}
2121

22-
wasi-http: ; git clone https://github.com/WebAssembly/wasi-http; cd wasi-http; git checkout v0.2.0-rc-2023-11-10 ; cp ../client.wit wit/client.wit; cd ../
22+
wasi-http: ; git clone https://github.com/WebAssembly/wasi-http; cd wasi-http; git checkout v0.2.0; cp ../client.wit wit/client.wit; cd ../
2323

2424
gen: wasi-http ; wit-bindgen c ./wasi-http/wit -w client
2525

2626
main.wasm: gen main.o libwasihttp.a; ${cc} main.o -L. -lwasihttp -o main.wasm
2727

28-
main_2023_11_10.embed.wasm: main.wasm ; wasm-tools component embed ./wasi-http/wit main.wasm -o main_2023_11_10.embed.wasm -w client
28+
main_0_2_0.embed.wasm: main.wasm ; wasm-tools component embed ./wasi-http/wit main.wasm -o main_0_2_0.embed.wasm -w client
2929

30-
wasi_snapshot_preview1.reactor.wasm: ; wget https://github.com/bytecodealliance/wasmtime/releases/download/v15.0.1/wasi_snapshot_preview1.reactor.wasm
30+
wasi_snapshot_preview1.reactor.wasm: ; wget https://github.com/bytecodealliance/wasmtime/releases/download/v18.0.2/wasi_snapshot_preview1.reactor.wasm
3131

32-
main_2023_11_10.component.wasm: main_2023_11_10.embed.wasm wasi_snapshot_preview1.reactor.wasm; wasm-tools component new main_2023_11_10.embed.wasm -o main_2023_11_10.component.wasm --adapt wasi_snapshot_preview1.reactor.wasm
32+
main_0_2_0.component.wasm: main_0_2_0.embed.wasm wasi_snapshot_preview1.reactor.wasm; wasm-tools component new main_0_2_0.embed.wasm -o main_0_2_0.component.wasm --adapt wasi_snapshot_preview1.reactor.wasm
3333

3434
clean: ; rm -f client.c client_component_type.o client.h proxy.h proxy.c *.wasm *.a; rm -rf wasi-http
3535

36-
run: main_2023_11_10.component.wasm ; wasmtime -S http --wasm component-model main_2023_11_10.component.wasm
36+
run: main_0_2_0.component.wasm ; wasmtime -S http --wasm component-model main_0_2_0.component.wasm
3737

3838
server.wasm: gen server.o libwasihttp.a; ${cc} server.o -L. -lwasihttp -o server.wasm
3939

40-
server_2023_11_10.embed.wasm: server.wasm ; wasm-tools component embed ./wasi-http/wit server.wasm -o server_2023_11_10.embed.wasm -w proxy
40+
server_0_2_0.embed.wasm: server.wasm ; wasm-tools component embed ./wasi-http/wit server.wasm -o server_0_2_0.embed.wasm -w proxy
4141

42-
server_2023_11_10.component.wasm: server_2023_11_10.embed.wasm wasi_snapshot_preview1.reactor.wasm; wasm-tools component new server_2023_11_10.embed.wasm -o server_2023_11_10.component.wasm --adapt wasi_snapshot_preview1.reactor.wasm
42+
server_0_2_0.component.wasm: server_0_2_0.embed.wasm wasi_snapshot_preview1.reactor.wasm; wasm-tools component new server_0_2_0.embed.wasm -o server_0_2_0.component.wasm --adapt wasi_snapshot_preview1.reactor.wasm
4343

44-
run-server: server_2023_11_10.component.wasm ; wasmtime serve server_2023_11_10.component.wasm
44+
run-server: server_0_2_0.component.wasm ; wasmtime serve -Scommon server_0_2_0.component.wasm

http/client.wit

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// This is a slightly modified version of the wasi-http world to include the
22
// wasi::cli/run package as an export, since otherwise the code isn't runnable
3-
package wasi:http@0.2.0-rc-2023-11-10;
3+
package wasi:http@0.2.0;
44

55
/// The `wasi:http/client` world captures what is needed to perform
66
/// HTTP client calls.
77
world client {
88
/// Clients have standard output and error streams which are expected to
99
/// terminate in a developer-facing console provided by the host.
10-
import wasi:cli/stdout@0.2.0-rc-2023-11-10;
11-
import wasi:cli/stderr@0.2.0-rc-2023-11-10;
10+
import wasi:cli/stdout@0.2.0;
11+
import wasi:cli/stderr@0.2.0;
1212

1313
/// TODO: this is a temporary workaround until component tooling is able to
1414
/// gracefully handle the absence of stdin. Hosts must return an eof stream
1515
/// for this import, which is what wasi-libc + tooling will do automatically
1616
/// when this import is properly removed.
17-
import wasi:cli/stdin@0.2.0-rc-2023-11-10;
17+
import wasi:cli/stdin@0.2.0;
1818

1919
/// This is the default handler to use when user code simply wants to make an
2020
/// HTTP request (e.g., via `fetch()`).
@@ -27,5 +27,5 @@ world client {
2727
export incoming-handler;
2828

2929
// The 'main' hook for the CLI
30-
export wasi:cli/run@0.2.0-rc-2023-11-10;
30+
export wasi:cli/run@0.2.0;
3131
}

http/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ int main() {
3232
}
3333

3434
// The wasm component hook for the 'main'
35-
bool exports_wasi_cli_0_2_0_rc_2023_11_10_run_run() {
35+
bool exports_wasi_cli_run_run() {
3636
return !main();
3737
}

http/server.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ int main() {
1212
}
1313

1414
// This is hack and doesn't actually do anything for this server
15-
bool exports_wasi_cli_0_2_0_rc_2023_11_10_run_run() {
15+
bool exports_wasi_cli_run_run() {
1616
return !main();
1717
}

0 commit comments

Comments
 (0)