Build everything with cargo
This commit is contained in:
parent
3b168d5db5
commit
d6b9667740
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,6 @@
|
|||||||
pH
|
pH
|
||||||
|
*.iml
|
||||||
|
.idea/
|
||||||
|
target/
|
||||||
|
sommelier/
|
||||||
|
|
||||||
|
@ -4,14 +4,6 @@ version = "0.1.0"
|
|||||||
authors = ["Bruce Leidl <bruce@subgraph.com>"]
|
authors = ["Bruce Leidl <bruce@subgraph.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name="pH"
|
|
||||||
path="src/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name="ph-init"
|
|
||||||
path="src/init/main.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder="1.0.0"
|
byteorder="1.0.0"
|
||||||
libc = "*"
|
libc = "*"
|
||||||
|
29
Makefile
29
Makefile
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
RUST_BUILD_RELEASE = rust/target/release
|
|
||||||
|
|
||||||
RUST_PH = $(RUST_BUILD_RELEASE)/pH
|
|
||||||
|
|
||||||
CARGO = cargo
|
|
||||||
CARGO_OPTS = --manifest-path rust/Cargo.toml --release
|
|
||||||
|
|
||||||
KERNEL = kernel/ph_linux
|
|
||||||
|
|
||||||
CP = cp
|
|
||||||
|
|
||||||
.PHONY: all clean $(RUST_PH)
|
|
||||||
|
|
||||||
all: pH $(KERNEL)
|
|
||||||
|
|
||||||
$(KERNEL):
|
|
||||||
$(MAKE) -C kernel/
|
|
||||||
|
|
||||||
pH: $(RUST_PH)
|
|
||||||
$(CP) $(RUST_PH) pH
|
|
||||||
|
|
||||||
$(RUST_PH):
|
|
||||||
$(CARGO) build --bins $(CARGO_OPTS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f pH
|
|
||||||
$(CARGO) clean $(CARGO_OPTS)
|
|
||||||
|
|
45
build.rs
Normal file
45
build.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::env;
|
||||||
|
use std::io::Result;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
build_phinit()?;
|
||||||
|
run_simple_make("sommelier")?;
|
||||||
|
run_simple_make("kernel")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_phinit() -> Result<()> {
|
||||||
|
run_command_in_directory(
|
||||||
|
"ph-init",
|
||||||
|
"cargo",
|
||||||
|
&["build", "--release"]
|
||||||
|
)?;
|
||||||
|
run_command_in_directory(
|
||||||
|
"ph-init",
|
||||||
|
"strip",
|
||||||
|
&["target/release/ph-init"]
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_simple_make<P: AsRef<Path>>(directory: P) -> Result<()> {
|
||||||
|
run_command_in_directory(directory, "make", &[])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_command_in_directory<P: AsRef<Path>>(directory: P, cmd: &str, args: &[&str]) -> Result<()> {
|
||||||
|
let saved = push_directory(directory)?;
|
||||||
|
Command::new(cmd).args(args).status()?;
|
||||||
|
env::set_current_dir(saved)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn push_directory<P: AsRef<Path>>(directory: P) -> Result<PathBuf> {
|
||||||
|
let current = env::current_dir()?;
|
||||||
|
env::set_current_dir(directory.as_ref())?;
|
||||||
|
Ok(current)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
4
rust/.gitignore
vendored
4
rust/.gitignore
vendored
@ -1,4 +0,0 @@
|
|||||||
*.iml
|
|
||||||
.idea/
|
|
||||||
target/
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::memory::{GuestRam, KVM_KERNEL_LOAD_ADDRESS, MemoryManager, SystemAllo
|
|||||||
use crate::kvm::*;
|
use crate::kvm::*;
|
||||||
|
|
||||||
static KERNEL: &[u8] = include_bytes!("../../kernel/ph_linux");
|
static KERNEL: &[u8] = include_bytes!("../../kernel/ph_linux");
|
||||||
static PHINIT: &[u8] = include_bytes!("../../target/release/ph-init");
|
static PHINIT: &[u8] = include_bytes!("../../ph-init/target/release/ph-init");
|
||||||
static SOMMELIER: &[u8] = include_bytes!("../../sommelier/sommelier");
|
static SOMMELIER: &[u8] = include_bytes!("../../sommelier/sommelier");
|
||||||
|
|
||||||
mod run;
|
mod run;
|
||||||
|
Loading…
Reference in New Issue
Block a user