Skip to content

Commit

Permalink
Try #2010:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Jan 12, 2021
2 parents 1b49fe8 + f0c7f5b commit f2e4622
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,28 @@ jobs:
run: |
make build-wapm
if: needs.setup.outputs.DOING_RELEASE == '1'
- name: Install Nightly Rust for Headless
uses: actions-rs/toolchain@v1
with:
toolchain: 'nightly-2020-12-22'
target: ${{ matrix.target }}
override: true
components: "rust-src"
#if: needs.setup.outputs.DOING_RELEASE == '1'
- name: Build Minimal Wasmer Headless
run: |
echo "\n[profile.release]
opt-level = 'z'
debug = false
debug-assertions = false
overflow-checks = false
lto = true
panic = 'abort'
incremental = false
codegen-units = 1
rpath = false" >> Cargo.toml
make build-wasmer-headless-minimal
#if: needs.setup.outputs.DOING_RELEASE == '1'
- name: Copy target binaries
run: |
mkdir -p target/release
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ endif
# Using filter as a logical OR
# https://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
use_system_ffi =
cross_compiling_to_mac_aarch64 =
ifneq (,$(filter $(ARCH),aarch64 arm64))
test_compilers_engines += cranelift-jit
ifneq (, $(findstring llvm,$(compilers)))
Expand All @@ -62,6 +63,7 @@ ifneq (,$(filter $(ARCH),aarch64 arm64))
# if we are in macos arm64, we use the system libffi for the capi
ifeq ($(UNAME_S), Darwin)
use_system_ffi = yes
cross_compiling_to_mac_aarch64 = yes
endif
endif

Expand Down Expand Up @@ -121,7 +123,7 @@ build-wasmer-debug:
build-wasmer-headless-minimal:
HOST_TARGET=$$(rustup show | grep 'Default host: ' | cut -d':' -f2 | tr -d ' ') ;\
echo $$HOST_TARGET ;\
xargo build -v --target $$HOST_TARGET --release --manifest-path=lib/cli/Cargo.toml --no-default-features --features disable-all-logging,native,wasi ;\
RUSTFLAGS="-C panic=abort" xargo build -v --target $$HOST_TARGET --release --manifest-path=lib/cli/Cargo.toml --no-default-features --features headless-minimal ;\
strip target/$$HOST_TARGET/release/wasmer

WAPM_VERSION = master # v0.5.0
Expand Down Expand Up @@ -326,6 +328,18 @@ ifeq ($(UNAME_S), Darwin)
endif
endif

package-minimal-headless-wasmer:
ifdef cross_compiling_to_mac_aarch64
if [ -f "target/aarch64-apple-darwin/release/wasmer" ]; then \
cp target/aarch64-apple-darwin/release/wasmer package/bin/wasmer-headless ;\
fi
else
HOST_TARGET=$$(rustup show | grep 'Default host: ' | cut -d':' -f2 | tr -d ' ') ;\
if [ -f "target/$$HOST_TARGET/release/wasmer" ]; then \
cp target/$$HOST_TARGET/release/wasmer package/bin/wasmer-headless ;\
fi
endif

package-wasmer:
mkdir -p "package/bin"
ifeq ($(OS), Windows_NT)
Expand Down Expand Up @@ -369,7 +383,7 @@ package-docs: build-docs build-docs-capi
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=rust/wasmer_vm/index.html">' > package/docs/index.html
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=wasmer_vm/index.html">' > package/docs/crates/index.html

package: package-wapm package-wasmer package-capi
package: package-wapm package-wasmer package-minimal-headless-wasmer package-capi

distribution: package
cp LICENSE package/LICENSE
Expand Down
2 changes: 2 additions & 0 deletions Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dependencies]
std = {default-features=false, features=["panic_immediate_abort"]}
2 changes: 2 additions & 0 deletions lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ llvm = [
]
debug = ["fern", "log", "wasmer-wasi/logging"]
disable-all-logging = ["wasmer-wasi/disable-all-logging"]
headless = []
headless-minimal = ["headless", "disable-all-logging", "wasi", "native", "jit"]
19 changes: 17 additions & 2 deletions lib/cli/src/bin/wasmer.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
use anyhow::Result;
#[cfg(feature = "compiler")]
use wasmer_cli::commands::Compile;
#[cfg(all(feature = "object-file", feature = "compiler"))]
use wasmer_cli::commands::CreateExe;
#[cfg(feature = "wast")]
use wasmer_cli::commands::Wast;
use wasmer_cli::commands::{Cache, Compile, Config, Inspect, Run, SelfUpdate, Validate};
use wasmer_cli::commands::{Cache, Config, Inspect, Run, SelfUpdate, Validate};
use wasmer_cli::error::PrettyError;

use structopt::{clap::ErrorKind, StructOpt};

#[derive(Debug, StructOpt)]
#[structopt(name = "wasmer", about = "WebAssembly standalone runtime.", author)]
#[cfg_attr(
not(feature = "headless"),
structopt(name = "wasmer", about = "WebAssembly standalone runtime.", author)
)]
#[cfg_attr(
feature = "headless",
structopt(
name = "wasmer-headless",
about = "Headless WebAssembly standalone runtime.",
author
)
)]
/// The options for the wasmer Command Line Interface
enum WasmerCLIOptions {
/// Run a WebAssembly file. Formats accepted: wasm, wat
Expand All @@ -25,6 +38,7 @@ enum WasmerCLIOptions {
Validate(Validate),

/// Compile a WebAssembly binary
#[cfg(feature = "compiler")]
#[structopt(name = "compile")]
Compile(Compile),

Expand Down Expand Up @@ -59,6 +73,7 @@ impl WasmerCLIOptions {
Self::SelfUpdate(options) => options.execute(),
Self::Cache(cache) => cache.execute(),
Self::Validate(validate) => validate.execute(),
#[cfg(feature = "compiler")]
Self::Compile(compile) => compile.execute(),
#[cfg(all(feature = "object-file", feature = "compiler"))]
Self::CreateExe(create_exe) => create_exe.execute(),
Expand Down
5 changes: 4 additions & 1 deletion lib/cli/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! The commands available in the Wasmer binary.
mod cache;
#[cfg(feature = "compiler")]
mod compile;
mod config;
#[cfg(all(feature = "object-file", feature = "compiler"))]
Expand All @@ -11,8 +12,10 @@ mod validate;
#[cfg(feature = "wast")]
mod wast;

#[cfg(feature = "compiler")]
pub use compile::*;
#[cfg(all(feature = "object-file", feature = "compiler"))]
pub use create_exe::*;
#[cfg(feature = "wast")]
pub use wast::*;
pub use {cache::*, compile::*, config::*, inspect::*, run::*, self_update::*, validate::*};
pub use {cache::*, config::*, inspect::*, run::*, self_update::*, validate::*};

0 comments on commit f2e4622

Please sign in to comment.