Skip to content
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,46 @@ TARGET = clayterm.wasm
SRC = src/module.c

CFLAGS = --target=wasm32 -nostdlib -O2 \
-ffunction-sections -fdata-sections \
-mbulk-memory \
-DCLAY_IMPLEMENTATION -DCLAY_WASM \
-Isrc -I.

EXPORTS = \
-Wl,--export=__heap_base \
-Wl,--export=clayterm_size \
-Wl,--export=init \
-Wl,--export=reduce \
-Wl,--export=output \
-Wl,--export=length \
-Wl,--export=measure \
-Wl,--export=Clay_SetPointerState \
-Wl,--export=pointer_over_count \
-Wl,--export=pointer_over_id_string_length \
-Wl,--export=pointer_over_id_string_ptr \
-Wl,--export=get_element_bounds \
-Wl,--export=error_count \
-Wl,--export=error_type \
-Wl,--export=error_message_length \
-Wl,--export=error_message_ptr \
-Wl,--export=input_size \
-Wl,--export=input_init \
-Wl,--export=input_scan \
-Wl,--export=input_count \
-Wl,--export=input_event \
-Wl,--export=input_delay

LDFLAGS = -Wl,--no-entry \
-Wl,--import-memory \
-Wl,--stack-first \
-Wl,--export-all \
-Wl,--strip-all \
-Wl,--gc-sections \
-Wl,--undefined=Clay__MeasureText \
-Wl,--undefined=Clay__QueryScrollOffset
-Wl,--undefined=Clay__QueryScrollOffset \
$(EXPORTS)

all: $(TARGET) wasm.ts
@echo "Built $(TARGET) ($$(wc -c < $(TARGET)) bytes)"
@echo "Built $(TARGET) ($$(wc -c < $(TARGET)) bytes raw, $$(gzip -c $(TARGET) | wc -c) bytes gzip)"

DEPS = $(wildcard src/*.c src/*.h)

Expand Down
6 changes: 3 additions & 3 deletions tasks/build-npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ await build({
typeCheck: false,
compilerOptions: {
lib: ["ESNext"],
target: "ES2020",
sourceMap: true,
},
skipSourceOutput: true,
package: {
name: "clayterm",
version,
Expand All @@ -37,9 +36,10 @@ await build({
url: "https://github.com/thefrontside/clayterm/issues",
},
engines: {
node: ">= 16",
node: ">= 22",
},
sideEffects: false,
Comment thread
natemoo-re marked this conversation as resolved.
type: "module",
},
});

Expand Down
Loading