wasmer_compiler_cli/
common.rs

1//! Common module with common used structures across different
2//! commands.
3use crate::VERSION;
4use clap::Parser;
5use std::env;
6use std::path::PathBuf;
7
8#[derive(Debug, Parser, Clone, Default)]
9/// The WebAssembly features that can be passed through the
10/// Command Line args.
11pub struct WasmFeatures {
12    /// Enable support for the SIMD proposal.
13    #[clap(long = "enable-simd")]
14    pub simd: bool,
15
16    /// Enable support for the threads proposal.
17    #[clap(long = "enable-threads")]
18    pub threads: bool,
19
20    /// Enable support for the reference types proposal.
21    #[clap(long = "enable-reference-types")]
22    pub reference_types: bool,
23
24    /// Enable support for the multi value proposal.
25    #[clap(long = "enable-multi-value")]
26    pub multi_value: bool,
27
28    /// Enable support for the bulk memory proposal.
29    #[clap(long = "enable-bulk-memory")]
30    pub bulk_memory: bool,
31
32    /// Enable support for all pre-standard proposals.
33    #[clap(long = "enable-all")]
34    pub all: bool,
35}
36
37/// Get the cache dir
38pub fn get_cache_dir() -> PathBuf {
39    match env::var("WASMER_CACHE_DIR") {
40        Ok(dir) => {
41            let mut path = PathBuf::from(dir);
42            path.push(VERSION);
43            path
44        }
45        Err(_) => {
46            // We use a temporal directory for saving cache files
47            let mut temp_dir = env::temp_dir();
48            temp_dir.push("wasmer");
49            temp_dir.push(VERSION);
50            temp_dir
51        }
52    }
53}