#!/bin/bash

mkdir c-components-playground
cd c-components-playground

wget https://github.com/bytecodealliance/wasm-tools/releases/download/wasm-tools-1.0.40/wasm-tools-1.0.40-x86_64-linux.tar.gz
tar -zxf ./wasm-tools-1.0.40-x86_64-linux.tar.gz

wget https://github.com/bytecodealliance/wit-bindgen/releases/download/wit-bindgen-cli-0.11.0/wit-bindgen-v0.11.0-x86_64-linux.tar.gz
tar -zxf ./wit-bindgen-v0.11.0-x86_64-linux.tar.gz

wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz
tar -zxf ./wasi-sdk-20.0-linux.tar.gz

git clone https://github.com/Kylebrown9/wasmcon2023

mkdir gen
cd gen

../wit-bindgen-v0.11.0-x86_64-linux/wit-bindgen c ../wasmcon2023/wit/greeter.wit --world proxy-greeter

../wasi-sdk-20.0/bin/clang \
    proxy_greeter.c component.c \
    proxy_greeter_component_type.o \
    -o greet-module.c.wasm -mexec-model=reactor
