mirror of
https://github.com/XunilGroup/XunilOS.git
synced 2026-06-02 14:44:26 +02:00
5f4154bd24
events and move parsing code to libxunil, and add mouse support again by using them, remove unneeded graphics and console output code, merge build files to a rust app builder, make framebuffer a driver and remove the graphics folder, add shell as an app in VFS
52 lines
1.9 KiB
Rust
52 lines
1.9 KiB
Rust
use std::env;
|
|
use std::fs;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
let arch = std::env::var("TARGET")
|
|
.unwrap_or_else(|_| {
|
|
std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "x86_64".to_string())
|
|
})
|
|
.split('-')
|
|
.next()
|
|
.unwrap()
|
|
.to_string();
|
|
|
|
let timer_frequency_hz = env::var("TIMER_FREQUENCY_HZ").unwrap_or_else(|_| "1000".to_string());
|
|
let karch = env::var("KARCH").unwrap_or_else(|_| arch.clone());
|
|
|
|
let out_dir = PathBuf::from("src");
|
|
fs::write(
|
|
out_dir.join("config.rs"),
|
|
format!(
|
|
"pub const TIMER_FREQUENCY_HZ: usize = {timer_frequency_hz};\n\
|
|
pub const KARCH: &str = \"{karch}\";"
|
|
),
|
|
)
|
|
.unwrap();
|
|
|
|
let out_dir = out_dir.join("driver").join("io").join("fs");
|
|
|
|
fs::write(
|
|
out_dir.join("assets.rs"),
|
|
format!(
|
|
"pub static INIT_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/init\");\n\
|
|
pub static DOOM_WAD: &[u8] = include_bytes!(\"../../../../../assets/doom1.wad\");\n\
|
|
pub static DOOM_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/doomgeneric\");\n\
|
|
pub static HELLOWORLD_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/helloworld.elf\");\n\
|
|
pub static BADAPPLE_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/badapple\");\n\
|
|
pub static SHELL_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/shell\");"
|
|
),
|
|
)
|
|
.unwrap();
|
|
|
|
println!("cargo:rerun-if-env-changed=KARCH");
|
|
println!("cargo:rerun-if-env-changed=TIMER_FREQUENCY_HZ");
|
|
println!("cargo:rerun-if-env-changed=OUTPUT");
|
|
|
|
// Tell cargo to pass the linker script to the linker..
|
|
println!("cargo:rustc-link-arg=-Tlinker-{arch}.ld");
|
|
// ..and to re-run if it changes.
|
|
println!("cargo:rerun-if-changed=linker-{arch}.ld");
|
|
}
|