MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / main

Function main

crates/openshell-driver-vm/build.rs:12–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10use std::{env, fs};
11
12fn main() {
13 println!("cargo:rerun-if-env-changed=OPENSHELL_VM_RUNTIME_COMPRESSED_DIR");
14
15 if let Ok(dir) = env::var("OPENSHELL_VM_RUNTIME_COMPRESSED_DIR") {
16 println!("cargo:rerun-if-changed={dir}");
17 for name in &[
18 "libkrun.so.zst",
19 "libkrunfw.so.5.zst",
20 "libkrun.dylib.zst",
21 "libkrunfw.5.dylib.zst",
22 "gvproxy.zst",
23 "openshell-sandbox.zst",
24 "umoci.zst",
25 ] {
26 println!("cargo:rerun-if-changed={dir}/{name}");
27 }
28 }
29
30 let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR not set"));
31 let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
32 let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
33
34 let (libkrun_name, libkrunfw_name) = match target_os.as_str() {
35 "macos" => ("libkrun.dylib", "libkrunfw.5.dylib"),
36 "linux" => ("libkrun.so", "libkrunfw.so.5"),
37 _ => {
38 println!("cargo:warning=VM runtime not available for {target_os}-{target_arch}");
39 generate_stub_resources(
40 &out_dir,
41 &["libkrun", "libkrunfw", "openshell-sandbox.zst", "umoci.zst"],
42 );
43 return;
44 }
45 };
46
47 let compressed_dir = if let Ok(dir) = env::var("OPENSHELL_VM_RUNTIME_COMPRESSED_DIR") {
48 PathBuf::from(dir)
49 } else {
50 println!("cargo:warning=OPENSHELL_VM_RUNTIME_COMPRESSED_DIR not set");
51 println!("cargo:warning=Run: mise run vm:setup && mise run vm:supervisor");
52 generate_stub_resources(
53 &out_dir,
54 &[
55 &format!("{libkrun_name}.zst"),
56 &format!("{libkrunfw_name}.zst"),
57 "gvproxy.zst",
58 "openshell-sandbox.zst",
59 "umoci.zst",
60 ],
61 );
62 return;
63 };
64
65 if !compressed_dir.is_dir() {
66 println!(
67 "cargo:warning=Compressed runtime dir not found: {}",
68 compressed_dir.display()
69 );

Callers

nothing calls this directly

Calls 4

generate_stub_resourcesFunction · 0.85
existsMethod · 0.80
lenMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected