wasmer/Makefile

433 lines
15 KiB
Makefile
Raw Normal View History

.PHONY: spectests emtests clean build install lint precommit docs examples
2018-10-23 23:54:07 +02:00
2020-04-16 13:26:24 -07:00
# uname only works in *Unix like systems
ifneq ($(OS), Windows_NT)
ARCH := $(shell uname -m)
UNAME_S := $(shell uname -s)
else
2020-04-16 13:26:24 -07:00
# We can assume, if in windows it will likely be in x86_64
ARCH := x86_64
UNAME_S :=
endif
2020-04-15 16:31:05 -07:00
backends :=
2020-04-16 15:33:48 -07:00
# Singlepass is enabled
RUST_VERSION := $(shell rustc -V)
ifneq (, $(findstring nightly,$(RUST_VERSION)))
# Singlepass doesn't work yet on Windows
ifneq ($(OS), Windows_NT)
backends += singlepass
2020-04-16 15:33:48 -07:00
endif
endif
2020-04-15 16:31:05 -07:00
ifeq ($(ARCH), x86_64)
# In X64, Cranelift is enabled
backends += cranelift
# LLVM could be enabled if not in Windows
2020-04-15 16:31:05 -07:00
ifneq ($(OS), Windows_NT)
# Autodetect LLVM from llvm-config
2020-04-16 17:44:25 -07:00
ifneq (, $(shell which llvm-config))
LLVM_VERSION := $(shell llvm-config --version)
# If findstring is not empty, then it have found the value
ifneq (, $(findstring 8,$(LLVM_VERSION))$(findstring 9,$(LLVM_VERSION)))
backends += llvm
endif
else
2020-04-16 17:44:25 -07:00
ifneq (, $(shell which llvm-config-8))
backends += llvm
endif
endif
2020-04-15 16:31:05 -07:00
endif
endif
backends := $(filter-out ,$(backends))
2020-04-15 16:35:02 -07:00
ifneq ($(OS), Windows_NT)
bold := $(shell tput bold)
green := $(shell tput setaf 2)
reset := $(shell tput sgr0)
2020-04-15 16:35:02 -07:00
endif
2020-04-15 16:31:05 -07:00
2020-04-15 16:35:02 -07:00
$(info Available backends: $(bold)$(green)${backends}$(reset))
2020-04-15 16:31:05 -07:00
backend_features_spaced := $(foreach backend,$(backends),backend-$(backend))
backend_features := --features "$(backend_features_spaced)"
# $(info Cargo features ${backend_features})
2019-07-05 18:36:34 -07:00
# Generate files
generate-emtests:
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build --release \
&& echo "formatting" \
&& cargo fmt
2018-12-09 19:21:28 -08:00
# To generate WASI tests you'll need to have the correct versions of the Rust nightly
# toolchain installed, see `WasiVersion::get_compiler_toolchain` in
# `tests/generate-wasi-tests/src/wasi_version.rs`
#
# or run `make wasitests-setup-toolchain` or `make wasitests-setup-toolchain-all`
2019-08-09 15:40:04 +09:00
generate-wasitests: wasitests-setup
WASM_WASI_GENERATE_WASITESTS=1 cargo build --release -vv \
&& echo "formatting" \
&& cargo fmt
2019-05-17 12:09:31 -07:00
generate-wasitests-all: wasitests-setup
WASI_TEST_GENERATE_ALL=1 WASM_WASI_GENERATE_WASITESTS=1 cargo build --release -vv \
&& echo "formatting" \
&& cargo fmt
emtests-generate: generate-emtests
wasitests-generate: generate-wasitests
wasitests-setup-toolchain: wasitests-setup
2020-04-15 16:31:05 -07:00
WASM_WASI_SET_UP_TOOLCHAIN=1 cargo build --release -vv
wasitests-setup-toolchain-all: wasitests-setup
2020-04-15 16:31:05 -07:00
WASI_TEST_GENERATE_ALL=1 WASM_WASI_SET_UP_TOOLCHAIN=1 cargo build --release -vv
generate: generate-emtests generate-wasitests
2018-10-23 23:54:07 +02:00
2019-07-05 18:36:34 -07:00
# Spectests
spectests-singlepass:
cargo test singlepass::spec --release $(backend_features) -- --test-threads=1
2018-10-23 23:54:07 +02:00
2019-07-05 18:36:34 -07:00
spectests-cranelift:
2020-04-15 16:31:05 -07:00
cargo test cranelift::spec --release $(backend_features)
2019-01-18 12:20:13 -08:00
2019-07-05 18:36:34 -07:00
spectests-llvm:
2020-04-15 16:31:05 -07:00
cargo test llvm::spec --release $(backend_features) -- --test-threads=1
2020-04-03 16:27:49 -07:00
2020-04-15 16:31:05 -07:00
spectests:
cargo test spec --release $(backend_features) -- --test-threads=1
2019-04-11 15:00:02 -07:00
2019-07-05 18:36:34 -07:00
# Emscripten tests
emtests-singlepass:
cargo test singlepass::emscripten --release $(backend_features) -- --test-threads=1
2019-07-05 18:36:34 -07:00
emtests-cranelift:
2020-04-15 16:31:05 -07:00
cargo test cranelift::emscripten --release $(backend_features)
2019-07-05 18:36:34 -07:00
emtests-llvm:
2020-04-15 16:31:05 -07:00
cargo test llvm::emscripten --release $(backend_features) -- --test-threads=1
2019-07-05 18:36:34 -07:00
2020-04-15 16:31:05 -07:00
emtests-all:
cargo test emscripten --release $(backend_features) -- --test-threads=1
2020-04-15 16:31:05 -07:00
emtests: emtests-singlepass emtests-cranelift emtests-llvm
2019-04-11 15:00:02 -07:00
2018-11-13 10:28:50 -08:00
2019-07-05 18:36:34 -07:00
# Middleware tests
middleware-singlepass:
2020-04-16 14:16:23 -07:00
cargo test singlepass::middleware --release $(backend_features)
2019-03-18 01:13:04 +08:00
2019-07-05 18:36:34 -07:00
middleware-cranelift:
2020-04-16 14:16:23 -07:00
cargo test cranelift::middleware --release $(backend_features)
2019-07-05 18:36:34 -07:00
middleware-llvm:
2020-04-16 14:16:23 -07:00
cargo test llvm::middleware --release $(backend_features)
2019-04-10 17:15:47 -07:00
2019-07-05 18:36:34 -07:00
middleware: middleware-singlepass middleware-cranelift middleware-llvm
2019-03-18 01:13:04 +08:00
2019-05-17 12:09:31 -07:00
2019-07-05 18:36:34 -07:00
# Wasitests
2019-08-05 14:01:04 +09:00
wasitests-setup:
ifeq (,$(wildcard ./tests/wasi_test_resources/test_fs/temp))
rm -rf tests/wasi_test_resources/test_fs/temp
endif
mkdir -p tests/wasi_test_resources/test_fs/temp
2019-08-05 14:01:04 +09:00
wasitests-singlepass: wasitests-setup
2020-04-16 14:16:23 -07:00
cargo test singlepass::wasi --release $(backend_features) -- --test-threads=1
2019-08-05 14:01:04 +09:00
wasitests-cranelift: wasitests-setup
2020-04-16 14:26:12 -07:00
cargo test cranelift::wasi --release $(backend_features) -- --test-threads=1
2019-04-06 10:29:15 -07:00
2019-08-05 14:01:04 +09:00
wasitests-llvm: wasitests-setup
2020-04-16 14:16:23 -07:00
cargo test llvm::wasi --release $(backend_features) -- --test-threads=1
2020-04-15 16:31:05 -07:00
wasitests-all: wasitests-setup
cargo test wasi --release $(backend_features) -- --test-threads=1
2019-04-06 10:29:15 -07:00
wasitests-unit: wasitests-setup
cargo test --manifest-path lib/wasi/Cargo.toml --release
wasitests: wasitests-unit wasitests-singlepass wasitests-cranelift wasitests-llvm
2019-07-05 18:36:34 -07:00
# Backends
singlepass: wasitests-setup
cargo test -p wasmer-singlepass-backend --release
cargo test singlepass:: --release $(backend_features) -- --test-threads=1
2019-07-05 18:36:34 -07:00
cranelift: wasitests-setup
2019-07-05 18:57:30 -07:00
cargo test -p wasmer-clif-backend --release
cargo test cranelift:: --release $(backend_features)
2019-07-05 18:36:34 -07:00
llvm: wasitests-setup
2019-07-05 18:57:30 -07:00
cargo test -p wasmer-llvm-backend --release
cargo test llvm:: --release $(backend_features) -- --test-threads=1
2019-07-05 18:36:34 -07:00
# All tests
2019-12-12 16:38:58 -08:00
capi-singlepass:
cargo build --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi
2019-09-01 09:42:07 -07:00
2019-12-12 16:38:58 -08:00
capi-cranelift:
cargo build --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi
capi-llvm:
cargo build --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi
2019-12-16 18:06:37 -05:00
capi-emscripten:
cargo build --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,emscripten
2019-12-12 16:38:58 -08:00
# We use cranelift as the default backend for the capi for now
capi: capi-cranelift
test-capi-singlepass: capi-singlepass
cargo test --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi
test-capi-cranelift: capi-cranelift
cargo test --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi
test-capi-llvm: capi-llvm
cargo test --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi
2019-12-16 18:06:37 -05:00
test-capi-emscripten: capi-emscripten
cargo test --manifest-path lib/runtime-c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,emscripten
test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-emscripten
2019-07-05 19:55:03 -07:00
capi-test: test-capi
2019-09-01 09:42:07 -07:00
test-rest:
cargo test --release -p wasmer-interface-types
cargo test --release -p wasmer-runtime
cargo test --release -p wasmer-runtime-core
cargo test --release -p wasmer-wasi-experimental-io-devices
cargo test --release -p wasmer-win-exception-handler
# This doesn't work in windows, commented for now
# cargo test --release -p wasmer-kernel-loader
# cargo test --release -p kernel-net
2019-07-05 18:36:34 -07:00
2020-04-15 19:39:10 -07:00
test: $(backends) test-rest examples
2019-07-05 18:36:34 -07:00
test-android:
ci/run-docker.sh x86_64-linux-android --manifest-path=lib/singlepass-backend/Cargo.toml
2020-04-06 14:13:54 -07:00
ci/run-docker.sh x86_64-linux-android runtime_core
2019-07-05 18:36:34 -07:00
# Integration tests
integration-tests: release-clif examples
2019-07-05 18:36:34 -07:00
echo "Running Integration Tests"
./tests/integration_tests/lua/test.sh
./tests/integration_tests/nginx/test.sh
./tests/integration_tests/cowsay/test.sh
2019-07-05 18:36:34 -07:00
examples:
2020-04-15 19:34:25 -07:00
cargo build --release $(backend_features) --examples
2020-04-15 19:35:20 -07:00
test -f target/release/examples/callback && ./target/release/examples/callback || echo "skipping callback test"
test -f target/release/examples/plugin && ./target/release/examples/plugin || echo "skipping plugin test"
2019-07-05 18:36:34 -07:00
# Utils
lint:
2019-07-05 18:57:30 -07:00
cargo fmt --all -- --check
2019-07-05 18:36:34 -07:00
precommit: lint test
2019-07-06 22:05:45 -07:00
debug:
2020-04-15 16:31:05 -07:00
cargo build --release --features "debug trace"
2019-07-05 18:36:34 -07:00
install:
2019-07-05 19:55:03 -07:00
cargo install --path .
2019-04-06 10:29:15 -07:00
2019-08-10 11:11:54 -07:00
# Checks
check-bench-singlepass:
2020-04-15 16:31:05 -07:00
cargo check --benches --all singlepass \
2019-09-23 16:33:29 -07:00
--exclude wasmer-clif-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
2019-08-10 11:11:54 -07:00
check-bench-clif:
2020-04-15 16:31:05 -07:00
cargo check --benches --all cranelift \
--exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
2019-08-10 11:11:54 -07:00
check-bench-llvm:
2020-04-15 16:31:05 -07:00
cargo check --benches --all llvm \
2019-09-23 16:33:29 -07:00
--exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader
2019-08-10 11:11:54 -07:00
check-bench: check-bench-singlepass check-bench-llvm
check-kernel-net:
cargo check -p kernel-net --target=wasm32-wasi
# checks that require a nightly version of Rust
check-nightly: check-kernel-net
# TODO: We wanted `--workspace --exclude wasmer-runtime`, but can't due
# to https://github.com/rust-lang/cargo/issues/6745 .
NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-interface-types
RUNTIME_CHECK = cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features
2019-08-10 11:11:54 -07:00
check: check-bench
cargo check $(NOT_RUNTIME_CRATES)
cargo check --release $(NOT_RUNTIME_CRATES)
cargo check --all-features $(NOT_RUNTIME_CRATES)
cargo check --release --all-features $(NOT_RUNTIME_CRATES)
# wasmer-runtime doesn't work with all backends enabled at once.
#
# We test using manifest-path directly so as to disable the default.
# `--no-default-features` only disables the default features in the
# current package, not the package specified by `-p`. This is
# intentional.
#
# Test default features, test 'debug' feature only in non-release
# builds, test as many combined features as possible with each backend
# as default, and test a minimal set of features with only one backend
# at a time.
cargo check --manifest-path lib/runtime-core/Cargo.toml
cargo check --manifest-path lib/runtime/Cargo.toml
2020-01-07 16:10:36 +01:00
# Check some of the cases where deterministic execution could matter
cargo check --manifest-path lib/runtime/Cargo.toml --features "deterministic-execution"
cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \
--features=default-backend-singlepass,deterministic-execution
cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \
--features=default-backend-llvm,deterministic-execution
cargo check --release --manifest-path lib/runtime/Cargo.toml
$(RUNTIME_CHECK) \
--features=cranelift,cache,llvm,singlepass,default-backend-singlepass
2020-01-07 16:10:36 +01:00
$(RUNTIME_CHECK) --release \
--features=cranelift,cache,llvm,singlepass,default-backend-singlepass
$(RUNTIME_CHECK) \
--features=cranelift,cache,llvm,singlepass,default-backend-cranelift
2020-01-07 16:10:36 +01:00
$(RUNTIME_CHECK) --release \
--features=cranelift,cache,llvm,singlepass,default-backend-cranelift
$(RUNTIME_CHECK) \
--features=cranelift,cache,llvm,singlepass,default-backend-llvm
2020-01-07 16:10:36 +01:00
$(RUNTIME_CHECK) --release \
--features=cranelift,cache,llvm,singlepass,default-backend-llvm
$(RUNTIME_CHECK) \
--features=singlepass,default-backend-singlepass
2020-01-07 16:10:36 +01:00
$(RUNTIME_CHECK) --release \
--features=singlepass,default-backend-singlepass
$(RUNTIME_CHECK) \
--features=cranelift,default-backend-cranelift
2020-01-07 16:10:36 +01:00
$(RUNTIME_CHECK) --release \
--features=cranelift,default-backend-cranelift
$(RUNTIME_CHECK) \
--features=llvm,default-backend-llvm
2020-01-07 16:10:36 +01:00
$(RUNTIME_CHECK) --release \
--features=llvm,default-backend-llvm
--features=default-backend-singlepass,singlepass,cranelift,llvm,cache,deterministic-execution
2019-08-10 11:11:54 -07:00
# Release
2018-11-13 10:28:50 -08:00
release:
cargo build --release $(backend_features) --features experimental-io-devices,log/release_max_level_off
2019-07-05 18:36:34 -07:00
2020-01-29 01:07:55 +08:00
# Release with musl target
release-musl:
# backend-llvm is not included due to dependency on wabt.
# experimental-io-devices is not included due to missing x11-fb.
cargo build --release --target x86_64-unknown-linux-musl --features backend-singlepass,backend-cranelift,loader-kernel,log/release_max_level_off,wasi --no-default-features
2020-04-15 16:31:05 -07:00
# This way of releasing is deprecated, since backends are now detected
# automatically
release-clif: release
2019-07-08 11:30:04 -07:00
2020-04-15 16:31:05 -07:00
# This way of releasing is deprecated, since backends are now detected
# automatically
release-singlepass: release
2019-07-05 18:36:34 -07:00
2020-04-15 16:31:05 -07:00
# This way of releasing is deprecated, since backends are now detected
# automatically
release-llvm: release
2019-07-08 11:30:04 -07:00
2019-07-30 15:59:21 +09:00
bench-singlepass:
# NOTE this will run some benchmarks using clif; TODO: fix this
2020-04-15 16:31:05 -07:00
cargo bench --all singlepass \
2019-09-23 16:33:29 -07:00
--exclude wasmer-clif-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
2019-07-30 15:59:21 +09:00
bench-clif:
2020-04-15 16:31:05 -07:00
cargo bench --all cranelift \
--exclude wasmer-singlepass-backend --exclude wasmer-llvm-backend --exclude wasmer-kernel-loader
2019-07-30 15:59:21 +09:00
bench-llvm:
# NOTE this will run some benchmarks using clif; TODO: fix this
2020-04-15 16:31:05 -07:00
cargo bench --all llvm \
2019-09-23 16:33:29 -07:00
--exclude wasmer-singlepass-backend --exclude wasmer-clif-backend --exclude wasmer-kernel-loader
2018-11-13 10:28:50 -08:00
2020-02-20 11:59:44 -08:00
build-install-package:
# This command doesn't build the binary, just packages it
2019-07-05 18:36:34 -07:00
mkdir -p ./install/bin
cp ./wapm-cli/target/release/wapm ./install/bin/
cp ./target/release/wasmer ./install/bin/
2020-03-10 18:23:59 -07:00
# Create the wax binary as symlink to wapm
cd ./install/bin/ && ln -sf wapm wax && chmod +x wax
tar -C ./install -zcvf wasmer.tar.gz bin
2018-11-26 11:47:33 -08:00
2020-02-20 11:59:44 -08:00
build-capi-package:
# This command doesn't build the C-API, just packages it
2020-02-19 18:54:32 -08:00
mkdir -p ./capi/
mkdir -p ./capi/include
mkdir -p ./capi/lib
ifeq ($(OS), Windows_NT)
2020-02-19 21:39:10 -08:00
cp target/release/wasmer_runtime_c_api.dll ./capi/lib/wasmer.dll
cp target/release/wasmer_runtime_c_api.lib ./capi/lib/wasmer.lib
2020-02-19 18:54:32 -08:00
else
ifeq ($(UNAME_S), Darwin)
cp target/release/libwasmer_runtime_c_api.dylib ./capi/lib/libwasmer.dylib
2020-03-18 13:03:33 -07:00
cp target/release/libwasmer_runtime_c_api.a ./capi/lib/libwasmer.a
2020-02-19 18:54:32 -08:00
# Fix the rpath for the dylib
install_name_tool -id "@rpath/libwasmer.dylib" ./capi/lib/libwasmer.dylib
else
cp target/release/libwasmer_runtime_c_api.so ./capi/lib/libwasmer.so
cp target/release/libwasmer_runtime_c_api.a ./capi/lib/libwasmer.a
endif
endif
find target/release/build -name 'wasmer.h*' -exec cp {} ./capi/include ';'
cp LICENSE ./capi/LICENSE
2020-02-20 11:24:54 -08:00
cp lib/runtime-c-api/doc/index.md ./capi/README.md
2020-02-19 18:54:32 -08:00
tar -C ./capi -zcvf wasmer-c-api.tar.gz lib include README.md LICENSE
2020-03-10 21:38:17 -07:00
WAPM_VERSION = v0.5.0
2020-02-28 11:11:31 -08:00
build-wapm:
git clone --branch $(WAPM_VERSION) https://github.com/wasmerio/wapm-cli.git
cargo build --release --manifest-path wapm-cli/Cargo.toml --features "telemetry update-notifications"
2019-07-05 18:36:34 -07:00
# For installing the contents locally
do-install:
tar -C ~/.wasmer -zxvf wasmer.tar.gz
2019-05-05 12:17:10 -07:00
2018-11-13 10:28:50 -08:00
publish-release:
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/
# cargo install cargo-deps
# must install graphviz for `dot`
dep-graph:
cargo deps --optional-deps --filter wasmer-wasi wasmer-kernel-loader wasmer-llvm-backend wasmer-emscripten wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png
2020-02-20 11:24:54 -08:00
docs-capi:
2020-02-20 11:56:47 -08:00
cd lib/runtime-c-api/ && doxygen doxyfile
2020-02-20 11:24:54 -08:00
docs: docs-capi
2020-04-07 12:47:36 -07:00
cargo doc --release --features=backend-singlepass,backend-cranelift,backend-llvm,docs,wasi,managed --workspace --document-private-items --no-deps
2020-01-14 19:32:00 +01:00
mkdir -p api-docs
2020-01-15 11:04:00 +01:00
mkdir -p api-docs/c
2020-01-15 13:21:05 +01:00
cp -R target/doc api-docs/crates
2020-01-15 12:32:27 +01:00
cp -R lib/runtime-c-api/doc/html api-docs/c/runtime-c-api
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=rust/wasmer_runtime/index.html">' > api-docs/index.html
2020-01-15 13:21:05 +01:00
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=wasmer_runtime/index.html">' > api-docs/crates/index.html
2020-01-14 13:35:06 +01:00
docs-publish:
2020-01-15 11:01:22 +01:00
git clone -b "gh-pages" --depth=1 https://wasmerbot:$(GITHUB_DOCS_TOKEN)@github.com/wasmerio/wasmer.git api-docs-repo
2020-01-14 19:32:00 +01:00
cp -R api-docs/* api-docs-repo/
2020-01-15 13:21:05 +01:00
cd api-docs-repo && git add index.html crates/* c/*
cd api-docs-repo && (git diff-index --quiet HEAD || git commit -m "Publishing GitHub Pages")
2020-01-14 19:32:00 +01:00
cd api-docs-repo && git push origin gh-pages