Update dependencies. Use Clap 3.0.0-beta2 instead of StructOpt

This commit is contained in:
Syrus Akbary
2021-03-03 21:47:49 -08:00
parent 1ee7b4a07f
commit 392f50a1af
21 changed files with 301 additions and 330 deletions

View File

@@ -2,39 +2,39 @@
use crate::store::{CompilerOptions, EngineType};
use anyhow::{Context, Result};
use clap::Clap;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
use structopt::StructOpt;
use wasmer::*;
const WASMER_MAIN_C_SOURCE: &[u8] = include_bytes!("wasmer_create_exe_main.c");
#[derive(Debug, StructOpt)]
#[derive(Debug, Clap)]
/// The options for the `wasmer create-exe` subcommand
pub struct CreateExe {
/// Input file
#[structopt(name = "FILE", parse(from_os_str))]
#[clap(name = "FILE", parse(from_os_str))]
path: PathBuf,
/// Output file
#[structopt(name = "OUTPUT PATH", short = "o", parse(from_os_str))]
#[clap(name = "OUTPUT PATH", short = 'o', parse(from_os_str))]
output: PathBuf,
/// Compilation Target triple
#[structopt(long = "target")]
#[clap(long = "target")]
target_triple: Option<Triple>,
#[structopt(flatten)]
#[clap(flatten)]
compiler: CompilerOptions,
#[structopt(short = "m", multiple = true)]
#[clap(short = 'm', multiple = true)]
cpu_features: Vec<CpuFeature>,
/// Additional libraries to link against.
/// This is useful for fixing linker errors that may occur on some systems.
#[structopt(short = "l", multiple = true)]
#[clap(short = 'l', multiple = true)]
libraries: Vec<String>,
}
@@ -148,20 +148,14 @@ fn generate_header(header_file_src: &[u8]) -> anyhow::Result<()> {
.open(&header_file_path)?;
use std::io::Write;
header.write_all(header_file_src)?;
header.write(header_file_src)?;
Ok(())
}
fn get_wasmer_dir() -> anyhow::Result<PathBuf> {
Ok(PathBuf::from(
env::var("WASMER_DIR")
.or_else(|e| {
option_env!("WASMER_INSTALL_PREFIX")
.map(str::to_string)
.ok_or(e)
})
.context("Trying to read env var `WASMER_DIR`")?,
env::var("WASMER_DIR").context("Trying to read env var `WASMER_DIR`")?,
))
}
@@ -285,13 +279,9 @@ impl LinkCode {
command
};
// Add libraries required per platform.
// We need userenv, sockets (Ws2_32), advapi32 for some system calls and bcrypt for random numbers.
// We need userenv, sockets (Ws2_32), and advapi32 to call a system call (for random numbers I think).
#[cfg(windows)]
let command = command
.arg("-luserenv")
.arg("-lWs2_32")
.arg("-ladvapi32")
.arg("-lbcrypt");
let command = command.arg("-luserenv").arg("-lWs2_32").arg("-ladvapi32");
// On unix we need dlopen-related symbols, libmath for a few things, and pthreads.
#[cfg(not(windows))]
let command = command.arg("-ldl").arg("-lm").arg("-pthread");