2019-08-26 13:00:17 +00:00
|
|
|
user_id :=$(shell id -u $(shell whoami))
|
2019-08-20 13:37:44 +00:00
|
|
|
pwd=$(shell pwd)
|
2019-08-20 13:50:52 +00:00
|
|
|
POSTPROCESS=tools/eth_postprocess.sh
|
2019-08-26 13:00:17 +00:00
|
|
|
PATH_PARAMS=-p:/code/vendors/nimcrypto -p:/code/vendors/stint -p:/code/vendors/nim-stew/
|
|
|
|
# Use NLVM
|
|
|
|
DOCKER_NLVM=docker -w /code/ -v $(pwd):/code/ jacqueswww/nlvm
|
|
|
|
DOCKER_NLVM_C=$(DOCKER_NLVM) $(PATH_PARAMS) c
|
2019-08-20 13:50:52 +00:00
|
|
|
NLVM_WAMS32_FLAGS= --nlvm.target=wasm32 --gc:none -l:--no-entry -l:--allow-undefined -d:clang
|
2019-08-26 13:00:17 +00:00
|
|
|
DOCKER_NLVM_C=$(DOCKER_NLVM) $(PATH_PARAMS) $(NLVM_WAMS32_FLAGS) c
|
|
|
|
# Use nim + clang
|
2019-08-26 18:16:15 +00:00
|
|
|
DOCKER_NIM_CLANG=docker run -e HOME='/tmp/' --user $(user_id):$(user_id) -w /code/ -v $(pwd):/code/ --entrypoint="/usr/bin/nim" nimclang --verbosity:2
|
2019-08-26 13:00:17 +00:00
|
|
|
DOCKER_NIM_CLANG_PASS_FLAGS = --passC:"--target=wasm32-unknown-unknown-wasm" \
|
|
|
|
--passL:"--target=wasm32-unknown-unknown-wasm" --passC:"-I./include" --clang.options.linker:"-nostdlib -Wl,--no-entry,--allow-undefined,--strip-all,--export-dynamic"
|
|
|
|
DOCKER_NIM_CLANG_FLAGS=$(DOCKER_NIM_CLANG_PASS_FLAGS) --os:standalone --cpu:i386 --cc:clang --gc:none --nomain
|
2019-08-26 18:16:15 +00:00
|
|
|
DOCKER_NIM_CLANG_C=$(DOCKER_NIM_CLANG) --cc:clang $(PATH_PARAMS) c
|
|
|
|
DOCKER_NIM_CLANG_WASM32_C=$(DOCKER_NIM_CLANG) $(DOCKER_NIM_CLANG_FLAGS) $(PATH_PARAMS) c
|
|
|
|
|
|
|
|
ifdef USE_NLVM:
|
|
|
|
NIMC=$(DOCKER_NLVM_C)
|
|
|
|
WASM32_NIMC=$(DOCKER_NLVM_C)
|
|
|
|
else
|
|
|
|
NIMC=$(DOCKER_NIM_CLANG_C)
|
|
|
|
WASM32_NIMC=$(DOCKER_NIM_CLANG_WASM32_C)
|
|
|
|
endif
|
2019-08-01 12:51:01 +00:00
|
|
|
|
2019-08-21 13:42:25 +00:00
|
|
|
.PHONY: all
|
2019-08-26 18:16:15 +00:00
|
|
|
all: tools examples
|
2019-08-21 13:42:25 +00:00
|
|
|
|
2019-08-16 16:30:11 +00:00
|
|
|
.PHONY: get-nlvm-docker
|
|
|
|
get-nlvm-docker:
|
2019-08-21 13:42:25 +00:00
|
|
|
docker pull docker.io/jacqueswww/nlvm
|
2019-08-01 12:51:01 +00:00
|
|
|
|
2019-08-16 16:30:11 +00:00
|
|
|
.PHONY: get-wabt
|
|
|
|
get-wabt:
|
|
|
|
"./tools/get_wabt.sh"
|
|
|
|
mv wabt tools/
|
|
|
|
|
|
|
|
.PHONY: tools
|
2019-08-01 12:51:01 +00:00
|
|
|
tools:
|
2019-08-26 18:16:15 +00:00
|
|
|
$(NIMC) -d:release --out:tools/k256_sig tools/k256_sig.nim
|
|
|
|
$(NIMC) -d:release --out:tools/abi_gen tools/abi_gen.nim
|
2019-08-01 12:51:01 +00:00
|
|
|
|
2019-08-16 16:30:11 +00:00
|
|
|
.PHONY: clean
|
2019-08-01 12:51:01 +00:00
|
|
|
clean:
|
|
|
|
rm -f *.wasm *.ll *.wat
|
|
|
|
|
2019-08-20 13:37:44 +00:00
|
|
|
.PHONY: get-nlvm examples
|
|
|
|
get-nlvm-appimage:
|
|
|
|
curl -L https://github.com/arnetheduck/nlvm/releases/download/continuous/nlvm-x86_64.AppImage -o tools/nlvm
|
|
|
|
chmod +x tools/nlvm
|
|
|
|
|
|
|
|
.PHONY: vendors
|
|
|
|
vendors:
|
|
|
|
cd vendors
|
|
|
|
git submodule update
|
2019-08-01 12:51:01 +00:00
|
|
|
|
2019-08-20 13:50:52 +00:00
|
|
|
.PHONY: king_of_the_hill
|
|
|
|
king_of_the_hill:
|
2019-08-26 18:16:15 +00:00
|
|
|
$(WASM32_NIMC) examples/king_of_the_hill.nim
|
2019-08-20 13:50:52 +00:00
|
|
|
$(POSTPROCESS) examples/king_of_the_hill.wasm
|
|
|
|
|
2019-08-26 18:16:15 +00:00
|
|
|
.PHONY: examples
|
|
|
|
examples: king_of_the_hill
|