Skip to content

Commit

Permalink
Functional rishka-cc tool for Rishka binary compilations.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Feb 21, 2024
1 parent cb4e2c8 commit 5acd8d1
Showing 1 changed file with 65 additions and 2 deletions.
67 changes: 65 additions & 2 deletions tools/rishka-cc/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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());
}

0 comments on commit 5acd8d1

Please sign in to comment.