@@ -12,7 +12,7 @@ OUTPUT_DIR=$(realpath $OUTPUT_DIR)
12
12
13
13
if [ -f " /.dockerenv" ] || grep -q docker /proc/1/cgroup; then
14
14
# running in a container so use the installed wasi-sdk as the devcontainer has this installed
15
- for FILENAME in $( find . -name ' *.c' )
15
+ for FILENAME in $( find . -name ' *.c' -not -path ' ./components/* ' )
16
16
do
17
17
echo Building ${FILENAME}
18
18
# Build the wasm file with wasi-libc for wasmtime
@@ -23,6 +23,29 @@ if [ -f "/.dockerenv" ] || grep -q docker /proc/1/cgroup; then
23
23
cargo run -p hyperlight-wasm-aot compile ${OUTPUT_DIR} /${FILENAME% .* } -wasi-libc.wasm ${OUTPUT_DIR} /${FILENAME% .* } .aot
24
24
cp ${OUTPUT_DIR} /${FILENAME% .* } .aot ${OUTPUT_DIR} /${FILENAME% .* } .wasm
25
25
done
26
+
27
+ for WIT_FILE in ${PWD} /components/* .wit; do
28
+ COMPONENT_NAME=$( basename ${WIT_FILE} .wit)
29
+ echo Building component: ${COMPONENT_NAME}
30
+
31
+ # Generate bindings for the component
32
+ wit-bindgen c ${WIT_FILE} --out-dir ${PWD} /components/bindings
33
+
34
+ # Build the wasm file with wasi-libc for wasmtime
35
+ /opt/wasi-sdk/bin/wasm32-wasip2-clang \
36
+ -ffunction-sections -mexec-model=reactor -O3 -z stack-size=4096 \
37
+ -Wl,--initial-memory=65536 -Wl,--export=__data_end -Wl,--export=__heap_base,--export=malloc,--export=free,--export=__wasm_call_ctors \
38
+ -Wl,--strip-all,--no-entry -Wl,--allow-undefined -Wl,--gc-sections \
39
+ -o ${OUTPUT_DIR} /${COMPONENT_NAME} -p2.wasm \
40
+ ${PWD} /components/${COMPONENT_NAME} .c \
41
+ ${PWD} /components/bindings/${COMPONENT_NAME} .c \
42
+ ${PWD} /components/bindings/${COMPONENT_NAME} _component_type.o
43
+
44
+ # Build AOT for Wasmtime
45
+ cargo run -p hyperlight-wasm-aot compile --component ${OUTPUT_DIR} /${COMPONENT_NAME} -p2.wasm ${OUTPUT_DIR} /${COMPONENT_NAME} .aot
46
+ cp ${OUTPUT_DIR} /${COMPONENT_NAME} .aot ${OUTPUT_DIR} /${COMPONENT_NAME} .wasm
47
+ done
48
+
26
49
else
27
50
# not running in a container so use the docker image to build the wasm files
28
51
echo Building docker image that has Wasm sdk. Should be quick if preivoulsy built and no changes to dockerfile.
0 commit comments