50b731f1b7
Derivative of Redox OS (https://www.redox-os.org) adding: - AMD GPU driver (amdgpu) via LinuxKPI compat layer - ext4 filesystem support (ext4d scheme daemon) - ACPI fixes for AMD bare metal (x2APIC, DMAR, IVRS, MCFG) - Custom branding (hostname, os-release, boot identity) Build system is full upstream Redox with RBOS overlay in local/. Patches for kernel, base, and relibc are symlinked from local/patches/ and protected from make clean/distclean. Custom recipes live in local/recipes/ with symlinks into the recipes/ search path. Build: make all CONFIG_NAME=redbear-full Sync: ./local/scripts/sync-upstream.sh
61 lines
1.7 KiB
Rust
61 lines
1.7 KiB
Rust
use std::env;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
const LIB_NAME: &str = "libamdgpu_dc_redox.so";
|
|
const ENV_HINTS: &[&str] = &[
|
|
"AMDGPU_DC_LIB_DIR",
|
|
"COOKBOOK_STAGE",
|
|
"REDOX_SYSROOT",
|
|
"SYSROOT",
|
|
"TARGET_SYSROOT",
|
|
];
|
|
|
|
fn push_candidate_dirs(candidates: &mut Vec<PathBuf>, base: &Path) {
|
|
candidates.push(base.to_path_buf());
|
|
candidates.push(base.join("usr/lib/redox/drivers"));
|
|
candidates.push(base.join("lib"));
|
|
candidates.push(base.join("usr/lib"));
|
|
}
|
|
|
|
fn register_candidate_watch(path: &Path) {
|
|
println!("cargo:rerun-if-changed={}", path.display());
|
|
}
|
|
|
|
fn find_amdgpu_dc_library(manifest_dir: &Path) -> Option<PathBuf> {
|
|
let mut candidates = Vec::new();
|
|
|
|
for key in ENV_HINTS {
|
|
println!("cargo:rerun-if-env-changed={key}");
|
|
if let Some(value) = env::var_os(key) {
|
|
push_candidate_dirs(&mut candidates, Path::new(&value));
|
|
}
|
|
}
|
|
|
|
push_candidate_dirs(&mut candidates, &manifest_dir.join("../amdgpu"));
|
|
push_candidate_dirs(&mut candidates, &manifest_dir.join("../amdgpu/stage"));
|
|
|
|
for dir in candidates {
|
|
register_candidate_watch(&dir.join(LIB_NAME));
|
|
if dir.join(LIB_NAME).exists() {
|
|
return Some(dir);
|
|
}
|
|
}
|
|
|
|
None
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rustc-check-cfg=cfg(no_amdgpu_c)");
|
|
|
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("missing manifest dir"));
|
|
|
|
if let Some(dir) = find_amdgpu_dc_library(&manifest_dir) {
|
|
println!("cargo:rustc-link-search=native={}", dir.display());
|
|
println!("cargo:rustc-link-lib=amdgpu_dc_redox");
|
|
println!("cargo:rustc-link-lib=pthread");
|
|
println!("cargo:rustc-link-lib=m");
|
|
} else {
|
|
println!("cargo:rustc-cfg=no_amdgpu_c");
|
|
}
|
|
}
|