diff options
Diffstat (limited to '')
-rw-r--r-- | rust/hello_world/component/.gitignore | 1 | ||||
-rw-r--r-- | rust/hello_world/component/Makefile | 27 | ||||
-rw-r--r-- | rust/hello_world/component/my-component.c | 14 |
3 files changed, 42 insertions, 0 deletions
diff --git a/rust/hello_world/component/.gitignore b/rust/hello_world/component/.gitignore new file mode 100644 index 0000000..5e4f2b2 --- /dev/null +++ b/rust/hello_world/component/.gitignore @@ -0,0 +1 @@ +hello_world* diff --git a/rust/hello_world/component/Makefile b/rust/hello_world/component/Makefile new file mode 100644 index 0000000..a7f3f85 --- /dev/null +++ b/rust/hello_world/component/Makefile @@ -0,0 +1,27 @@ +# Look for wasi-sysroot in some common places, falling back +# to provided WASI_SYSROOT +ifneq ("$(wildcard /usr/wasm32-wasi)", "") + # Fedora + WASI_SYSROOT ?= /usr/wasm32-wasi +else ifneq ("$(wildcard /usr/local/share/wasi-sysroot)", "") + # FreeBSD + WASI_SYSROOT ?= /usr/local/share/wasi-sysroot +endif + +export WASI_SYSROOT + +CC = clang +CFLAGS = -Wall -Wextra --target=wasm32-wasi --sysroot=$(WASI_SYSROOT) +LDFLAGS = -Wl,--no-entry -mexec-model=reactor --rtlib=compiler-rt + +all: hello_world.wasm + +bindgen: + /home/andrew/src/c/wasm/wit-bindgen-v0.13.0-x86_64-linux/wit-bindgen c ../wit + +hello_world.wasm: bindgen my-component.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ hello_world.c hello_world_component_type.o my-component.c + /home/andrew/src/c/wasm/wasm-tools-1.0.48-x86_64-linux/wasm-tools component new hello_world.wasm -o hello_world-component.wasm + +clean: + rm -f hello_world* diff --git a/rust/hello_world/component/my-component.c b/rust/hello_world/component/my-component.c new file mode 100644 index 0000000..fe09975 --- /dev/null +++ b/rust/hello_world/component/my-component.c @@ -0,0 +1,14 @@ +/* + * my-component.c + */ + +#include "hello_world.h" + +void hello_world_greet(void) +{ + hello_world_string_t my_string; + + hello_world_string_set(&my_string, "Hello, world!"); + + hello_world_name(&my_string); +} |