Skip to content

Commit

Permalink
Merge branch 'master' into trace-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Jun 9, 2020
2 parents d492084 + ee9da72 commit 87a7f11
Show file tree
Hide file tree
Showing 48 changed files with 1,842 additions and 396 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ jobs:
- run: make test
- name: Build and Test C API
run: |
make capi
make build-capi
make test-capi-cranelift
if: matrix.os != 'windows-latest'
- name: Build C API on Windows
run: make capi
run: make build-capi
if: matrix.os == 'windows-latest'
- name: Build Wasmer binary
run: |
make build-wasmer
# TODO: build wapm
# make build-wapm
make package
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
**/target
**/*.rs.bk
/artifacts
.DS_Store
.idea
**/.vscode
install/
capi/
api-docs/
api-docs-repo/
/.cargo_home/
/package/
/dist/
/wapm-cli/

# Generated by tests on Android
/avd
Expand Down
33 changes: 17 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ rustc_version = "0.2"
anyhow = "1.0"
blake3 = "0.3"
criterion = "0.3"
lazy_static = "1.4"
test-utils = { path = "tests/lib/test-utils" }
wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }

Expand Down
192 changes: 142 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# uname only works in *Unix like systems
ifneq ($(OS), Windows_NT)
ARCH := $(shell uname -m)
UNAME_S := $(shell uname -s)
ARCH := $(shell uname -m)
UNAME_S := $(shell uname -s)
else
# We can assume, if in windows it will likely be in x86_64
ARCH := x86_64
UNAME_S :=
# We can assume, if in windows it will likely be in x86_64
ARCH := x86_64
UNAME_S :=
endif

compilers :=
Expand All @@ -16,38 +16,38 @@ compilers :=
RUST_VERSION := $(shell rustc -V)

ifneq (, $(findstring nightly,$(RUST_VERSION)))
# Singlepass doesn't work yet on Windows
ifneq ($(OS), Windows_NT)
compilers += singlepass
endif
# Singlepass doesn't work yet on Windows
ifneq ($(OS), Windows_NT)
compilers += singlepass
endif
endif

ifeq ($(ARCH), x86_64)
# In X64, Cranelift is enabled
compilers += cranelift
# LLVM could be enabled if not in Windows
ifneq ($(OS), Windows_NT)
# Autodetect LLVM from llvm-config
ifneq (, $(shell which llvm-config))
LLVM_VERSION := $(shell llvm-config --version)
# If findstring is not empty, then it have found the value
ifneq (, $(findstring 10,$(LLVM_VERSION)))
compilers += llvm
endif
else
ifneq (, $(shell which llvm-config-10))
compilers += llvm
endif
endif
endif
# In X64, Cranelift is enabled
compilers += cranelift
# LLVM could be enabled if not in Windows
ifneq ($(OS), Windows_NT)
# Autodetect LLVM from llvm-config
ifneq (, $(shell which llvm-config))
LLVM_VERSION := $(shell llvm-config --version)
# If findstring is not empty, then it have found the value
ifneq (, $(findstring 10,$(LLVM_VERSION)))
compilers += llvm
endif
else
ifneq (, $(shell which llvm-config-10))
compilers += llvm
endif
endif
endif
endif

compilers := $(filter-out ,$(compilers))

ifneq ($(OS), Windows_NT)
bold := $(shell tput bold)
green := $(shell tput setaf 2)
reset := $(shell tput sgr0)
bold := $(shell tput bold)
green := $(shell tput setaf 2)
reset := $(shell tput sgr0)
endif


Expand All @@ -57,8 +57,9 @@ compiler_features_spaced := $(foreach compiler,$(compilers),$(compiler))
compiler_features := --features "$(compiler_features_spaced)"


tests-spec-update-testsuite:
git subtree pull --prefix tests/wast/spec https://github.com/WebAssembly/testsuite.git master --squash
############
# Building #
############

test:
cargo test --release $(compiler_features)
Expand All @@ -70,44 +71,135 @@ check-bench:
cargo check --benches --features "jit" $(compiler_features)

release:
build-wasmer:
cargo build --release $(compiler_features)

doc:
cargo doc --all-features --document-private-items
WAPM_VERSION = v0.5.0
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"

doc-local:
cargo doc --all-features --document-private-items --no-deps
build-docs:
cargo doc --release --all-features --document-private-items --no-deps

RUSTFLAGS := "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects" # TODO: add `-D missing-docs`
lint:
cargo fmt --all -- --check
RUSTFLAGS=${RUSTFLAGS} cargo clippy $(compiler_features)
build-docs-capi:
cd lib/c-api/ && doxygen doxyfile

capi-singlepass:
# We use cranelift as the default backend for the capi for now
build-capi: build-capi-cranelift

build-capi-singlepass:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi

capi-cranelift:
build-capi-cranelift:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi

capi-llvm:
build-capi-llvm:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi

# We use cranelift as the default backend for the capi for now
capi: capi-cranelift

test-capi-singlepass: capi-singlepass
###########
# Testing #
###########

test:
cargo test --release $(compiler_features)

test-capi-singlepass: build-capi-singlepass
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi
--no-default-features --features singlepass,wasi

test-capi-cranelift: capi-cranelift
test-capi-cranelift: build-capi-cranelift
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi -- --nocapture --test-threads=1
--no-default-features --features cranelift,wasi -- --nocapture --test-threads=1

test-capi-llvm: capi-llvm
test-capi-llvm: build-capi-llvm
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi
--no-default-features --features llvm,wasi

test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-emscripten

#############
# Packaging #
#############

package-wasmer:
mkdir -p "package/bin"
ifeq ($(OS), Windows_NT)
cp target/release/wasmer.exe package/bin/
else
cp target/release/wasmer package/bin/
endif

# Comment out WAPM for now to speed up release process.
# cp ./wapm-cli/target/release/wapm package/bin/
# # Create the wax binary as symlink to wapm
# cd package/bin/ && ln -sf wapm wax && chmod +x wax

package-capi:
mkdir -p "package/include"
mkdir -p "package/lib"
cp lib/c-api/wasmer.h* package/include
cp lib/c-api/doc/index.md package/include/README.md
ifeq ($(OS), Windows_NT)
cp target/release/wasmer_c_api.dll package/lib
cp target/release/wasmer_c_api.lib package/lib
else
ifeq ($(UNAME_S), Darwin)
cp target/release/libwasmer_c_api.dylib package/lib/libwasmer.dylib
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a
# Fix the rpath for the dylib
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib
else
cp target/release/libwasmer_c_api.so package/lib/libwasmer.so
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a
endif
endif

package-docs: build-docs build-docs-capi
mkdir -p "package/docs"
mkdir -p "package/docs/c"
cp -R target/doc package/docs/crates
cp -R lib/c-api/doc/html package/docs/c-api
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=rust/wasmer_runtime/index.html">' > package/docs/index.html
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=wasmer_runtime/index.html">' > package/docs/crates/index.html

package: package-wasmer package-capi
cp LICENSE package/LICENSE
cp ATTRIBUTIONS.md package/ATTRIBUTIONS
mkdir -p dist
ifeq ($(OS), Windows_NT)
iscc src/windows-installer/wasmer.iss
cp src/windows-installer/WasmerInstaller.exe dist/wasmer-windows.exe
else
cp LICENSE package/LICENSE
cp ATTRIBUTIONS.md package/ATTRIBUTIONS
tar -C package -zcvf wasmer.tar.gz bin lib include LICENSE ATTRIBUTIONS
cp ./wasmer.tar.gz ./dist/$(shell ./scripts/binary-name.sh)
endif

#################
# Miscellaneous #
#################

# Updates the spectests from the repo
update-testsuite:
git subtree pull --prefix tests/wast/spec https://github.com/WebAssembly/testsuite.git master --squash

RUSTFLAGS := "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects" # TODO: add `-D missing-docs`
lint:
cargo fmt --all -- --check
RUSTFLAGS=${RUSTFLAGS} cargo clippy $(compiler_features)

install-local: package
tar -C ~/.wasmer -zxvf wasmer.tar.gz

publish-docs:
git clone -b "gh-pages" --depth=1 https://wasmerbot:$(GITHUB_DOCS_TOKEN)@github.com/wasmerio/wasmer.git api-docs-repo
cp -R package/docs/* api-docs-repo/
cd api-docs-repo && git add index.html crates/* c-api/*
cd api-docs-repo && (git diff-index --quiet HEAD || git commit -m "Publishing GitHub Pages")
# cd api-docs-repo && git push origin gh-pages
2 changes: 1 addition & 1 deletion lib/api/src/externals/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl std::fmt::Debug for Function {
}
}

/// This trait is one that all dynamic funcitons must fulfill.
/// This trait is one that all dynamic functions must fulfill.
trait VMDynamicFunction {
fn call(&self, args: &[Val]) -> Result<Vec<Val>, RuntimeError>;
fn function_type(&self) -> &FunctionType;
Expand Down
4 changes: 2 additions & 2 deletions lib/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ pub use crate::types::{
};
pub use crate::types::{Val as Value, ValType as Type};

pub use target_lexicon::{Architecture, OperatingSystem, Triple, HOST};
pub use target_lexicon::{Architecture, CallingConvention, OperatingSystem, Triple, HOST};
pub use wasm_common::{Bytes, Pages, ValueType, WasmExternType, WasmTypeList};
#[cfg(feature = "compiler")]
pub use wasmer_compiler::CompilerConfig;
pub use wasmer_compiler::{Features, Target};
pub use wasmer_compiler::{CpuFeature, Features, Target};
pub use wasmer_engine::{
ChainableNamedResolver, DeserializeError, Engine, InstantiationError, LinkError, NamedResolver,
NamedResolverChain, Resolver, RuntimeError, SerializeError,
Expand Down
Loading

0 comments on commit 87a7f11

Please sign in to comment.