Skip to content

Commit

Permalink
test webasm
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Jan 1, 2025
1 parent 38e3909 commit 093feee
Show file tree
Hide file tree
Showing 5 changed files with 3,647 additions and 4 deletions.
12 changes: 8 additions & 4 deletions build-webassembly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ OUTPUT_BASE="salam-wa"
EDITOR_DIR="../Salam-Editor/"

MEMORY_FLAGS="-s ALLOW_MEMORY_GROWTH=1"
RUNTIME_FLAGS="-s EXIT_RUNTIME=0 -s NO_EXIT_RUNTIME=1"
COMMON_FLAGS="-s EXPORTED_RUNTIME_METHODS=['callMain'] -s TOTAL_STACK=8388608" # 8MB (8 * 1024 * 1024)
# RUNTIME_FLAGS="-s EXIT_RUNTIME=0 -s NO_EXIT_RUNTIME=1"
# RUNTIME_FLAGS="-s NO_EXIT_RUNTIME=1"
# RUNTIME_FLAGS="-s EXIT_RUNTIME=0"
RUNTIME_FLAGS="-s NO_EXIT_RUNTIME=1"
COMMON_FLAGS="-s EXPORTED_RUNTIME_METHODS=['callMain'] -s EXPORTED_FUNCTIONS=['_main'] -s TOTAL_STACK=8388608"

sources=(
"src/log.c"
Expand Down Expand Up @@ -49,14 +52,15 @@ else
echo "Debug mode not enabled."
fi

echo "${sources[@]} -o ${OUTPUT_BASE}.html ${MEMORY_FLAGS} ${RUNTIME_FLAGS} ${COMMON_FLAGS} ${DEBUG_FLAGS}"

echo "Compiling C files to WebAssembly..."
emcc "${sources[@]}" -o ${OUTPUT_BASE}.html \
${MEMORY_FLAGS} \
${RUNTIME_FLAGS} \
${COMMON_FLAGS} \
${DEBUG_FLAGS} \
# -s EXPORTED_FUNCTIONS="['_main']"
# -v\
# -v

if [ $? -eq 0 ]; then
echo "Compilation successful. Output files:"
Expand Down
5 changes: 5 additions & 0 deletions src/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main(int argc, char **argv) {
printf("Hello, WebAssembly!\n");
return 0;
}
Loading

0 comments on commit 093feee

Please sign in to comment.