Merge pull request #344 from GuillaumeGomez/improvements

Improve y.sh script (to potentially allow dependencies) and improve `build_system` help message
This commit is contained in:
antoyo 2023-09-25 17:19:20 -04:00 committed by GitHub
commit 71febd94f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -9,13 +9,19 @@ mod utils;
macro_rules! arg_error { macro_rules! arg_error {
($($err:tt)*) => {{ ($($err:tt)*) => {{
eprintln!($($err)*); eprintln!($($err)*);
eprintln!();
usage(); usage();
std::process::exit(1); std::process::exit(1);
}}; }};
} }
fn usage() { fn usage() {
// println!("{}", include_str!("usage.txt")); println!("\
Available commands for build_system:
prepare : Run prepare command
build : Run build command
--help : Show this message");
} }
pub enum Command { pub enum Command {
@ -31,6 +37,10 @@ fn main() {
let command = match env::args().nth(1).as_deref() { let command = match env::args().nth(1).as_deref() {
Some("prepare") => Command::Prepare, Some("prepare") => Command::Prepare,
Some("build") => Command::Build, Some("build") => Command::Build,
Some("--help") => {
usage();
process::exit(0);
}
Some(flag) if flag.starts_with('-') => arg_error!("Expected command found flag {}", flag), Some(flag) if flag.starts_with('-') => arg_error!("Expected command found flag {}", flag),
Some(command) => arg_error!("Unknown command {}", command), Some(command) => arg_error!("Unknown command {}", command),
None => { None => {

7
y.sh
View File

@ -2,6 +2,7 @@
set -e set -e
echo "[BUILD] build system" 1>&2 echo "[BUILD] build system" 1>&2
mkdir -p build_system/target cd build_system
rustc build_system/src/main.rs -o build_system/target/y -Cdebuginfo=1 --edition 2021 cargo build --release
exec ./build_system/target/y "$@" cd ..
./build_system/target/release/y $@