From 5acd8d1e2f7900045a969161d270f45c2a40e0c4 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Wed, 21 Feb 2024 23:13:17 +0800 Subject: [PATCH] Functional rishka-cc tool for Rishka binary compilations. --- tools/rishka-cc/src/main.rs | 67 +++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/tools/rishka-cc/src/main.rs b/tools/rishka-cc/src/main.rs index 5cb815a..e2e8e07 100644 --- a/tools/rishka-cc/src/main.rs +++ b/tools/rishka-cc/src/main.rs @@ -1,8 +1,71 @@ -mod process; +/* + * This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka-sdk). + * Copyright (c) 2024 Nathanne Isip. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +extern crate colored; + +mod args; mod env; mod io; +mod process; + +use colored::Colorize; +use crate::args::Options; +use crate::env::RishkaEnv; +use std::process::exit; + +fn compile_task(argv: Options, envvars: RishkaEnv) { + print!("{} ELF binary from sources... ", "Building".blue().bold()); + if !process::run_riscv64_gpp(&argv, envvars) { + println!("something went {}.", "wrong".red().bold()); + exit(0); + } + else { + println!("{}!", "done".yellow().bold()); + } + + print!("{} raw binary output from ELF file... ", "Generating".blue().bold()); + if !process::run_riscv64_objcopy(&argv) { + println!("something went {}.", "wrong".red().bold()); + exit(0); + } + else { + println!("{}!", "done".yellow().bold()); + } + + print!("{} ELF binary output file... ", "Deleting".red().bold()); + if !io::delete_gpp_output(&argv) { + println!("something went {}.", "wrong".red().bold()); + exit(0); + } + else { + println!("{}!", "deleted".yellow().bold()); + } +} fn main() { process::check_req_deps(); - env::check_req_env(); + + let envvars: RishkaEnv = env::check_req_env(); + let mut argv: Options = args::get_args(); + + if argv.output == "" { + argv.output = "a".to_string(); + } + + compile_task(argv, envvars); + println!("Task {}!", "done".green().bold()); }