2019-09-20 18:15:10 -04:00
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use std::env;
|
|
|
|
use std::io::Result;
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
|
build_phinit()?;
|
2023-01-27 16:38:08 -05:00
|
|
|
build_kernel()?;
|
|
|
|
build_sommelier()?;
|
2019-09-21 20:46:02 -04:00
|
|
|
// Rerun build.rs upon making or pulling in new commits
|
|
|
|
println!("cargo:rerun-if-changed=.git/refs/heads/master");
|
2023-01-27 16:38:08 -05:00
|
|
|
println!("cargo:rerun-if-changed=ph-init/src");
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
2019-09-20 18:15:10 -04:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn build_phinit() -> Result<()> {
|
2019-09-21 20:46:02 -04:00
|
|
|
let _dir = ChdirTo::path("ph-init");
|
|
|
|
|
|
|
|
Command::new("cargo")
|
|
|
|
.arg("build")
|
|
|
|
.arg("--release")
|
|
|
|
.status()?;
|
|
|
|
|
|
|
|
Command::new("strip")
|
|
|
|
.arg("target/release/ph-init")
|
|
|
|
.status()?;
|
|
|
|
|
2019-09-20 18:15:10 -04:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-01-27 16:38:08 -05:00
|
|
|
fn build_kernel() -> Result<()> {
|
|
|
|
Command::new("make")
|
|
|
|
.arg("-C")
|
|
|
|
.arg("kernel")
|
|
|
|
.status()?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn build_sommelier() -> Result<()> {
|
|
|
|
Command::new("meson")
|
|
|
|
.arg("setup")
|
|
|
|
.arg("-Dxwayland_path=/usr/bin/Xwayland")
|
|
|
|
.arg("-Dxwayland_gl_driver_path=")
|
|
|
|
.arg("-Dwith_tests=false")
|
|
|
|
.arg("sommelier/build")
|
|
|
|
.arg("sommelier")
|
|
|
|
.status()?;
|
|
|
|
|
|
|
|
Command::new("meson")
|
|
|
|
.arg("compile")
|
|
|
|
.arg("-C")
|
|
|
|
.arg("sommelier/build")
|
|
|
|
.status()?;
|
2019-09-21 20:46:02 -04:00
|
|
|
Ok(())
|
2019-09-20 18:15:10 -04:00
|
|
|
}
|
|
|
|
|
2019-09-21 20:46:02 -04:00
|
|
|
struct ChdirTo {
|
|
|
|
saved: PathBuf,
|
2019-09-20 18:15:10 -04:00
|
|
|
}
|
|
|
|
|
2019-09-21 20:46:02 -04:00
|
|
|
impl ChdirTo {
|
|
|
|
fn path<P: AsRef<Path>>(directory: P) -> ChdirTo {
|
|
|
|
let saved = env::current_dir()
|
|
|
|
.expect("current_dir()");
|
|
|
|
env::set_current_dir(directory.as_ref())
|
|
|
|
.expect("set_current_dir()");
|
|
|
|
ChdirTo { saved }
|
|
|
|
}
|
2019-09-20 18:15:10 -04:00
|
|
|
}
|
|
|
|
|
2019-09-21 20:46:02 -04:00
|
|
|
impl Drop for ChdirTo {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
env::set_current_dir(&self.saved)
|
|
|
|
.expect("restore current dir");
|
|
|
|
}
|
|
|
|
}
|
2019-09-20 18:15:10 -04:00
|
|
|
|