MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / main

Function main

cranelift/codegen/build.rs:26–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24use std::time::Instant;
25
26fn main() {
27 let start_time = Instant::now();
28
29 let out_dir = env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set");
30 let out_dir = std::path::Path::new(&out_dir);
31 let target_triple = env::var("TARGET").expect("The TARGET environment variable must be set");
32
33 let all_arch = env::var("CARGO_FEATURE_ALL_ARCH").is_ok();
34 let all_native_arch = env::var("CARGO_FEATURE_ALL_NATIVE_ARCH").is_ok();
35
36 let mut isas = meta::isa::Isa::all()
37 .iter()
38 .cloned()
39 .filter(|isa| {
40 let env_key = match isa {
41 meta::isa::Isa::Pulley32 | meta::isa::Isa::Pulley64 => {
42 "CARGO_FEATURE_PULLEY".to_string()
43 }
44 _ => format!("CARGO_FEATURE_{}", isa.to_string().to_uppercase()),
45 };
46 all_arch || env::var(env_key).is_ok()
47 })
48 .collect::<Vec<_>>();
49
50 // Don't require host isa if under 'all-arch' feature.
51 let host_isa = env::var("CARGO_FEATURE_HOST_ARCH").is_ok() && !all_native_arch;
52
53 if isas.is_empty() || host_isa {
54 // Try to match native target.
55 let target_name = target_triple.split('-').next().unwrap();
56 if let Ok(isa) = meta::isa_from_arch(&target_name) {
57 println!("cargo:rustc-cfg=feature=\"{isa}\"");
58 isas.push(isa);
59 }
60 }
61
62 let cur_dir = env::current_dir().expect("Can't access current working directory");
63 let crate_dir = cur_dir.as_path();
64
65 println!("cargo:rerun-if-changed=build.rs");
66 println!("cargo:rerun-if-env-changed=ISLE_SOURCE_DIR");
67
68 let isle_dir = if let Ok(path) = std::env::var("ISLE_SOURCE_DIR") {
69 // This will canonicalize any relative path in terms of the
70 // crate root, and will take any absolute path as overriding the
71 // `crate_dir`.
72 crate_dir.join(&path)
73 } else {
74 out_dir.into()
75 };
76
77 std::fs::create_dir_all(&isle_dir).expect("Could not create ISLE source directory");
78
79 if let Err(err) = meta::generate(&isas, &out_dir, &isle_dir) {
80 eprintln!("Error: {err}");
81 process::exit(1);
82 }
83

Callers

nothing calls this directly

Calls 15

isa_from_archFunction · 0.85
build_isleFunction · 0.85
is_okMethod · 0.80
splitMethod · 0.80
newFunction · 0.50
generateFunction · 0.50
writeFunction · 0.50
expectMethod · 0.45
iterMethod · 0.45
to_stringMethod · 0.45
is_emptyMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected