mirror of
https://github.com/remko/waforth
synced 2024-12-27 09:59:29 +01:00
waforthc: Add test target
This commit is contained in:
parent
2e06201c81
commit
b69323bb1f
4 changed files with 63 additions and 20 deletions
4
.github/workflows/build-waforthc.yml
vendored
4
.github/workflows/build-waforthc.yml
vendored
|
@ -15,5 +15,5 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./.github/actions/setup
|
||||
# - run: make -C src/standalone install-deps package
|
||||
# - run: make -C src/standalone check
|
||||
- run: make -C src/waforthc package
|
||||
- run: make -C src/waforthc check
|
||||
|
|
|
@ -71,9 +71,15 @@ package: waforth
|
|||
|
||||
endif
|
||||
endif
|
||||
CFLAGS:=-I$(WASMTIME_DIR)/include $(CFLAGS)
|
||||
CFLAGS:= -I$(WASMTIME_DIR)/include $(CFLAGS)
|
||||
LIBS:=$(WASMTIME_DIR)/lib/libwasmtime.a $(LIBS)
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS := $(CFLAGS) -g
|
||||
else
|
||||
CFLAGS := $(CFLAGS) -O2
|
||||
endif
|
||||
|
||||
################################################
|
||||
|
||||
BIN2H=../../scripts/bin2h
|
||||
|
@ -86,7 +92,7 @@ OBJECTS=main.o $(RESOURCE_OBJECTS)
|
|||
all: waforth
|
||||
|
||||
waforth: $(OBJECTS)
|
||||
$(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(LIBS)
|
||||
$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LDFLAGS) $(LIBS)
|
||||
|
||||
main.o: waforth_core.h
|
||||
|
||||
|
@ -114,4 +120,4 @@ check:
|
|||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -f waforth_core.wasm waforth_core.h $(OBJECTS) waforth *.tgz *.zip test.out
|
||||
-rm -f waforth_core.wasm waforth_core.h $(OBJECTS) waforth *.exe *.tgz *.zip test.out
|
||||
|
|
1
src/waforthc/.gitignore
vendored
1
src/waforthc/.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
/waforth_*.h
|
||||
/_waforth*
|
||||
/hello
|
||||
/waforth*.tgz
|
||||
|
|
|
@ -1,44 +1,67 @@
|
|||
ifeq ($(OS),Windows_NT)
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
VERSION?=$(shell cat ../../package.json | grep '"version"' | sed -e 's/.*:.*"\(.*\)".*/\1/')
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
package: waforthc
|
||||
7z a -tzip waforthc-v$(VERSION)-windows.zip waforthc.exe
|
||||
else # $(OS)
|
||||
ifeq (, $(shell which gtar))
|
||||
TAR := tar
|
||||
else
|
||||
# bsd-tar corrupts files on GitHub: https://github.com/actions/virtual-environments/issues/2619
|
||||
TAR := gtar
|
||||
endif
|
||||
UNAME_S=$(shell uname -s)
|
||||
UNAME_P=$(shell uname -p)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
ifeq ($(UNAME_P),arm)
|
||||
PACKAGE_SUFFIX=arm64-macos
|
||||
else
|
||||
PACKAGE_SUFFIX=x86_64-macos
|
||||
endif
|
||||
# FIXME: When new WABT 1.0.31 is released, we can update this to standard paths
|
||||
HOMEBREW_DIR = $(shell brew --prefix)
|
||||
WABT_INCLUDE_DIR := $(HOME)/Downloads/src/wabt/include
|
||||
WABT_LIB_DIR := $(HOME)/Downloads/src/wabt/build
|
||||
WABT_WASM2C_SRC_DIR = $(HOME)/Downloads/src/wabt/wasm2c
|
||||
# BOOST_INCLUDE_DIR := /opt/homebrew/include
|
||||
# BOOST_LIB_DIR := /opt/homebrew/lib
|
||||
BOOST_INCLUDE_DIR = /opt/homebrew/Cellar/boost/1.80.0/include
|
||||
BOOST_LIB_DIR := /opt/homebrew/Cellar/boost/1.80.0/lib
|
||||
BOOST_INCLUDE_DIR := $(HOMEBREW_DIR)/include
|
||||
BOOST_LIB_DIR := $(HOMEBREW_DIR)/lib
|
||||
LIBS := -mmacosx-version-min=13.0
|
||||
CXXFLAGS := -std=c++20
|
||||
else
|
||||
CXXFLAGS := -std=c++17
|
||||
else # $(UNAME_S)
|
||||
WABT_INCLUDE_DIR := /usr/local/wabt/include
|
||||
WABT_LIB_DIR := /usr/local/wabt/lib
|
||||
WABT_WASM2C_SRC_DIR = /usr/local/wasm2c
|
||||
BOOST_INCLUDE_DIR = /usr/include
|
||||
BOOST_LIB_DIR := /usr/lib/x86_64-linux-gnu
|
||||
endif
|
||||
PACKAGE_SUFFIX=x86_64-linux
|
||||
endif # $(UNAME_S)
|
||||
LIBS := -L$(WABT_LIB_DIR) -lwabt $(BOOST_LIB_DIR)/libboost_filesystem.a $(BOOST_LIB_DIR)/libboost_program_options.a $(LIBS)
|
||||
CXXFLAGS := $(CXXFLAGS) -g
|
||||
endif
|
||||
package: waforthc
|
||||
$(TAR) czf waforthc-v$(VERSION)-$(PACKAGE_SUFFIX).tgz waforthc
|
||||
endif # $(OS)
|
||||
|
||||
CPPFLAGS := -g \
|
||||
-I$(WABT_INCLUDE_DIR) \
|
||||
-I$(BOOST_INCLUDE_DIR)
|
||||
CPPFLAGS := -I$(WABT_INCLUDE_DIR) -I$(BOOST_INCLUDE_DIR)
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CXXFLAGS := $(CXXFLAGS) -g
|
||||
else
|
||||
CXXFLAGS := $(CXXFLAGS) -O2
|
||||
endif
|
||||
|
||||
BIN2H=../../scripts/bin2h
|
||||
WAT2WASM=wat2wasm
|
||||
WAT2WASM_FLAGS=--debug-names
|
||||
|
||||
CPPFLAGS:=-DVERSION='"$(VERSION)"' $(CPPFLAGS)
|
||||
|
||||
OBJECTS := waforthc.o
|
||||
|
||||
all: waforthc
|
||||
|
||||
waforthc: $(OBJECTS)
|
||||
$(CXX) -o $@ $^ $(LIBS)
|
||||
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
waforthc.o: waforth_core.h waforth_rt.h waforth_wabt_wasm-rt-impl_c.h waforth_wabt_wasm-rt-impl_h.h waforth_wabt_wasm-rt_h.h
|
||||
|
||||
|
@ -63,5 +86,18 @@ waforth_wabt_wasm-rt_h.h: $(WABT_WASM2C_SRC_DIR)/wasm-rt.h
|
|||
waforth_core.wasm: ../waforth.wat
|
||||
$(WAT2WASM) $(WAT2WASM_FLAGS) -o $@ $<
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
-rm -f test test.out
|
||||
./waforthc -o test --init=SAY_HELLO ../examples/hello.fs | tee test.out
|
||||
grep -q "Hello, Forth" test.out
|
||||
./test | tee test.out
|
||||
grep -q "Hello, Forth" test.out
|
||||
-rm -f test test.out
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf waforthc waforth_core.wasm waforth_core.h waforth_rt.h waforth_wabt_wasm-rt-impl_c.h waforth_wabt_wasm-rt-impl_c.h waforth_wabt_wasm-rt_h.h waforth_wabt_wasm-rt-impl_h.h waforth *.o _waforth*
|
||||
-rm -rf waforthc *.exe *.o *.tgz *.zip \
|
||||
waforth_core.wasm waforth_core.h \
|
||||
waforth_rt.h \
|
||||
waforth_wabt_wasm-rt-impl_c.h waforth_wabt_wasm-rt-impl_c.h waforth_wabt_wasm-rt_h.h waforth_wabt_wasm-rt-impl_h.h
|
Loading…
Reference in a new issue