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-09-05 15:49:56 +00:00
|
|
|
PATH_PARAMS=-p:/code/vendor/nimcrypto -p:/code/vendor/stint -p:/code/vendor/nim-stew/
|
2019-08-26 13:00:17 +00:00
|
|
|
# Use NLVM
|
2019-08-27 11:47:13 +00:00
|
|
|
DOCKER_NLVM=docker run -e HOME='/tmp/' --user $(user_id):$(user_id) -w /code/ -v $(pwd):/code/ jacqueswww/nlvm
|
2019-08-26 13:00:17 +00:00
|
|
|
DOCKER_NLVM_C=$(DOCKER_NLVM) $(PATH_PARAMS) c
|
2019-09-02 19:13:01 +00:00
|
|
|
NLVM_WAMS32_FLAGS= --nlvm.target=wasm32 --gc:none -l:--no-entry -l:--allow-undefined -d:clang -d:release
|
2019-08-26 13:00:17 +00:00
|
|
|
DOCKER_NLVM_C=$(DOCKER_NLVM) $(PATH_PARAMS) $(NLVM_WAMS32_FLAGS) c
|
|
|
|
# Use nim + clang
|
2019-08-27 11:15:19 +00:00
|
|
|
DOCKER_NIM_CLANG=docker run -e HOME='/tmp/' --user $(user_id):$(user_id) -w /code/ -v $(pwd):/code/ --entrypoint="/usr/bin/nim" jacqueswww/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"
|
2019-09-02 19:13:01 +00:00
|
|
|
DOCKER_NIM_CLANG_FLAGS=$(DOCKER_NIM_CLANG_PASS_FLAGS) --os:standalone --cpu:i386 --cc:clang --gc:none --nomain -d:release
|
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
|
|
|
|
|
2019-08-27 11:47:13 +00:00
|
|
|
ifdef USE_NLVM
|
2019-08-26 18:16:15 +00:00
|
|
|
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-27 11:15:19 +00:00
|
|
|
.PHONY: get-nimclang-docker
|
|
|
|
get-nimclang-docker:
|
|
|
|
docker pull docker.io/jacqueswww/nimclang
|
|
|
|
|
2019-08-16 16:30:11 +00:00
|
|
|
.PHONY: get-wabt
|
|
|
|
get-wabt:
|
2019-09-02 19:13:01 +00:00
|
|
|
rm -rf tools/wabt
|
|
|
|
./tools/get_wabt.sh
|
2019-08-16 16:30:11 +00:00
|
|
|
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
|
2019-09-02 19:13:01 +00:00
|
|
|
git submodule update --init
|
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-09-13 10:37:24 +00:00
|
|
|
$(WASM32_NIMC) --out:examples/king_of_the_hill.wasm examples/king_of_the_hill.nim
|
|
|
|
$(POSTPROCESS) examples/king_of_the_hill.wasm
|
2019-08-20 13:50:52 +00:00
|
|
|
|
2019-08-26 18:16:15 +00:00
|
|
|
.PHONY: examples
|
|
|
|
examples: king_of_the_hill
|
2019-11-06 13:55:57 +00:00
|
|
|
$(WASM32_NIMC) --out:examples/registry.wasm examples/registry.nim
|
|
|
|
$(POSTPROCESS) examples/registry.wasm
|
|
|
|
$(WASM32_NIMC) --out:examples/balances.wasm examples/balances.nim
|
|
|
|
$(POSTPROCESS) examples/balances.wasm
|
|
|
|
$(WASM32_NIMC) --out:examples/erc20.wasm examples/erc20.nim
|
|
|
|
$(POSTPROCESS) examples/erc20.wasm
|
|
|
|
$(WASM32_NIMC) --out:examples/default_func.wasm examples/default_func.nim
|
|
|
|
$(POSTPROCESS) examples/default_func.wasm
|
2019-12-04 18:39:05 +00:00
|
|
|
|
2019-12-06 15:39:48 +00:00
|
|
|
|
2019-12-04 18:39:05 +00:00
|
|
|
.PHONY: ee-examples
|
|
|
|
ee-examples:
|
|
|
|
$(WASM32_NIMC) --out:examples/ee/helloworld.wasm examples/ee/helloworld.nim
|
2019-12-19 11:36:25 +00:00
|
|
|
$(WASM32_NIMC) --out:examples/ee/block_echo.wasm examples/ee/block_echo.nim
|
2019-12-06 15:39:48 +00:00
|
|
|
|
|
|
|
.PHONY: test-ee
|
|
|
|
test-ee: ee-examples
|
|
|
|
cd tests/ee/; \
|
|
|
|
./test.sh
|
2019-12-20 22:37:40 +00:00
|
|
|
|
|
|
|
.PHONY: substrate-examples
|
|
|
|
substrate-examples:
|
|
|
|
$(WASM32_NIMC) --out:examples/substrate/hello_world.wasm examples/substrate/hello_world.nim
|
|
|
|
|
|
|
|
.PHONY: test-substrate
|
|
|
|
test-substrate: substrate-examples
|
|
|
|
cd tests/substrate; \
|
|
|
|
SUBSTRATE_PATH="${HOME}/.cargo/bin/substrate" ./test.sh
|