diff --git a/bake/Cargo.lock b/bake/Cargo.lock new file mode 100644 index 0000000..3bccd01 --- /dev/null +++ b/bake/Cargo.lock @@ -0,0 +1,32 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "bake" +version = "0.0.1" +dependencies = [ + "eyre", +] + +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" diff --git a/bake/Cargo.toml b/bake/Cargo.toml new file mode 100644 index 0000000..cf29202 --- /dev/null +++ b/bake/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "bake" +version = "0.0.1" +edition = "2024" + +[lib] +path = "lib/lib.rs" + +[[bin]] +name = "bake" +path = "bin/main.rs" + +[dependencies] +eyre = "0.6.12" diff --git a/bake/bin/main.rs b/bake/bin/main.rs new file mode 100644 index 0000000..f752bb6 --- /dev/null +++ b/bake/bin/main.rs @@ -0,0 +1,35 @@ +use std::process::ExitCode; + +use eyre::Context; + +const USAGE: &str = r#" +bake [target...] [-- [args-for-last-target...]] +"#; + +fn print_usage() { + println!("{USAGE}"); +} + +fn go() -> eyre::Result<()> { + let contents = match std::fs::read_to_string("build.bake") { + Ok(v) => v, + Err(e) => match e.kind() { + std::io::ErrorKind::NotFound => { + println!("build.bake not present in current directory"); + return Ok(()); + }, + _ => { + return Err(e).wrap_err("Failed to read contents of build.bake") + }, + }, + }; + + let mut graph = bake::build_graph_from_str(&contents)?; + bake::execute_graph(&graph)?; + + Ok(()) +} + +fn main() -> eyre::Result<()> { + go() +} diff --git a/bake/build.bake b/bake/build.bake new file mode 100644 index 0000000..b2ff4de --- /dev/null +++ b/bake/build.bake @@ -0,0 +1 @@ +(-> :name run (phony) (phony) "cargo run") \ No newline at end of file diff --git a/bake/lib/lib.rs b/bake/lib/lib.rs new file mode 100644 index 0000000..b926c3b --- /dev/null +++ b/bake/lib/lib.rs @@ -0,0 +1,22 @@ +pub type Result = core::result::Result; + +#[derive(Debug)] +pub struct Error; +impl core::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{self:?}") + } +} + +impl std::error::Error for Error { +} + +pub struct Graph; + +pub fn build_graph_from_str(s: &str) -> Result { + todo!() +} + +pub fn execute_graph(graph: &Graph) -> Result<()> { + todo!() +}