Skip to content

Commit

Permalink
make the Makefiles a bit more robust
Browse files Browse the repository at this point in the history
- Escape "." character in `sed` regex
- Ensure that %.wasm target fails cleanly (i.e. without generating the target file) if `wasm-tools` fails

Signed-off-by: Joel Dice <[email protected]>
  • Loading branch information
dicej committed Feb 12, 2024
1 parent cc62fa8 commit a5065e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ bindings: $(BINDING_WORK_DIR)/wasi-cli $(BINDING_WORK_DIR)/wit-bindgen
./wasi-cli/wit && \
mv preview2.h ../../libc-bottom-half/headers/public/wasi/ && \
mv preview2_component_type.o ../../libc-bottom-half/sources && \
sed 's_#include "preview2.h"_#include "wasi/preview2.h"_' \
sed 's_#include "preview2\.h"_#include "wasi/preview2.h"_' \
< preview2.c \
> ../../libc-bottom-half/sources/preview2.c && \
rm preview2.c
Expand Down
7 changes: 5 additions & 2 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ build: download $(WASMS)

$(WASMS): | $(OBJDIRS)
$(OBJDIR)/%.wasm: $(OBJDIR)/%.wasm.o $(INFRA_WASM_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
$(CC) $(CFLAGS) $(LDFLAGS) -o tmp.wasm $^
ifeq ($(TARGET_TRIPLE), wasm32-wasi-preview2)
$(WASM_TOOLS) component new --adapt $(ADAPTER) $@ -o $@
$(WASM_TOOLS) component new --adapt $(ADAPTER) tmp.wasm -o $@
rm tmp.wasm
else
mv tmp.wasm $@
endif

$(WASM_OBJS): $(LIBC_TEST)/src/common/test.h | $(OBJDIRS)
Expand Down

0 comments on commit a5065e6

Please sign in to comment.