rcss_bundler/
lib.rs

1#[cfg(feature = "full")]
2pub mod full;
3use std::{
4    ffi::OsStr,
5    os::unix::ffi::OsStrExt,
6    path::{Path, PathBuf},
7};
8
9#[cfg(feature = "full")]
10pub use full::*;
11
12pub const MANIFEST_PATH_CONFIG: &str = "rcss-bundler-root.path";
13
14pub fn save_root_manifest_path(root_manifest: &Path) {
15    let mut file: PathBuf = std::env::var("OUT_DIR")
16        .expect("$OUT_DIR should exist.")
17        .into();
18    file.push(MANIFEST_PATH_CONFIG);
19    std::fs::write(file, root_manifest.as_os_str().as_bytes())
20        .expect("Failed to write root manifest path");
21}
22
23pub fn load_root_manifest_path(path_to_out: &Path) -> Option<PathBuf> {
24    let file = path_to_out.join(MANIFEST_PATH_CONFIG);
25    if file.exists() {
26        let path = std::fs::read(file).expect("Failed to read root manifest path");
27        let os_str = OsStr::from_bytes(&path);
28        let path: &Path = os_str.as_ref();
29        Some(path.into())
30    } else {
31        None
32    }
33}