File: build.rs

package info (click to toggle)
rust-wasmtime 26.0.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 48,492 kB
  • sloc: ansic: 4,003; sh: 561; javascript: 542; cpp: 254; asm: 175; ml: 96; makefile: 55
file content (45 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::env;
use std::process::Command;

// WASMTIME_FEATURE_LIST
const FEATURES: &[&str] = &[
    "ASYNC",
    "PROFILING",
    "CACHE",
    "PARALLEL_COMPILATION",
    "WASI",
    "LOGGING",
    "DISABLE_LOGGING",
    "COREDUMP",
    "ADDR2LINE",
    "DEMANGLE",
    "THREADS",
    "GC",
    "CRANELIFT",
    "WINCH",
];
// ... if you add a line above this be sure to change the other locations
// marked WASMTIME_FEATURE_LIST

fn main() {
    println!("cargo:rerun-if-changed=cmake/features.cmake");
    println!("cargo:rerun-if-changed=cmake/install-headers.cmake");
    println!("cargo:rerun-if-changed=include");

    let out_dir = std::env::var("OUT_DIR").unwrap();
    let mut cmake = Command::new("cmake");
    cmake.arg("-DWASMTIME_DISABLE_ALL_FEATURES=ON");
    cmake.arg(format!("-DCMAKE_INSTALL_PREFIX={out_dir}"));
    for f in FEATURES {
        if env::var_os(format!("CARGO_FEATURE_{f}")).is_some() {
            cmake.arg(format!("-DWASMTIME_FEATURE_{f}=ON"));
        }
    }

    cmake.arg("-P").arg("cmake/install-headers.cmake");

    let status = cmake.status().expect("failed to spawn `cmake`");
    assert!(status.success());

    println!("cargo:include={out_dir}/include");
}