Skip to content

Commit

Permalink
Update CI and makefile template
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaAmora committed Apr 20, 2022
1 parent e8445d3 commit f8ed513
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ jobs:
path: |
4orth
./porth/std/core.porth
wasm4.porth
w4std.porth
./std/wasm4.porth
./std/w4std.porth
- name: Test html Bundle
run: ./w4 bundle ./example/tictactoe.wasm --title "Ultimate Tic Tac Toe" --html index.html
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
TAG: ${{ steps.get_version.outputs.tag }}
run: |
mv 4orth porth/
mv wasm4.porth porth/std
mv w4std.porth porth/std
mv std/wasm4.porth porth/std
mv std/w4std.porth porth/std
cd porth
zip -r ../"4oth-${TAG}-linux".zip *
Expand Down
38 changes: 16 additions & 22 deletions example/Template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,37 @@ $(error Download Wabt (https://github.com/WebAssembly/wabt) and set $$WABT_PATH)
endif

4ORTH = 4orth
4ORTH_PATH = $(shell command -v $(4ORTH))

ifeq (, $(shell command -v $(4ORTH)))
ifeq (, $(4ORTH_PATH))
$(error Download 4orth (https://github.com/FrankWPA/4orth) and add it to $$PATH)
endif

4ORTH_PATH = $(shell command -v $(4ORTH))
4ORTH_DIR = $(shell dirname -- "$(4ORTH_PATH)")
4ORTH_FLAGS = -I $(4ORTH_DIR) -I $(4ORTH_DIR)/std
4ORTH_COMMAND := com -s
4ORTH_ARGS = com -s

ifndef _4ORTH
4ORTH_STD = $(shell dirname -- "$(4ORTH_PATH)")/std
4ORTH_ARGS := -I $(4ORTH_STD) $(4ORTH_ARGS)
endif

ifeq ($(b), 1)
4ORTH_COMMAND := $(4ORTH_COMMAND) -b
4ORTH_ARGS := $(4ORTH_ARGS) -b
endif

ifeq ($(r), 1)
4ORTH_COMMAND := $(4ORTH_COMMAND) -r
4ORTH_ARGS := $(4ORTH_ARGS) -r
endif

# Optional dependency from binaryen for smaller builds
WASM_OPT = wasm-opt
WASM_OPT_FLAGS = -Oz

ifeq ($(opt), 1)
ifneq ($(DEBUG), 1)
ifeq (, $(shell command -v $(WASM_OPT)))
$(error Using the subcommand -opt requires $(WASM_OPT) from binaryen)
$(info Tip: $(WASM_OPT) was not found. Install it from binaryen for smaller builds!)
else
4ORTH_ARGS := $(4ORTH_ARGS) -opt
endif
endif
4ORTH_COMMAND := $(4ORTH_COMMAND) -opt
endif

ifeq ($(OS), Windows_NT)
$(error 4orth compiler only supports Linux)
Expand All @@ -45,21 +48,12 @@ all: build/cart.wasm
.PHONY: build/cart.wasm
build/cart.wasm: main.porth
@$(MKDIR_BUILD)
$(4ORTH) $(4ORTH_FLAGS) $(4ORTH_COMMAND) $<
$(4ORTH) $(4ORTH_ARGS) $<
mv main.wat build/cart.wat
mv main.wasm build/cart.wasm
ifeq ($(b), 1)
mv main build/cart
endif
ifneq ($(opt), 1)
ifneq ($(DEBUG), 1)
ifeq (, $(shell command -v $(WASM_OPT)))
@echo Tip: $(WASM_OPT) was not found. Install it from binaryen for smaller builds!
else
$(WASM_OPT) $(WASM_OPT_FLAGS) $@ -o $@
endif
endif
endif

.PHONY: clean
clean:
Expand Down

0 comments on commit f8ed513

Please sign in to comment.