Skip to content

Commit

Permalink
Completely functional compilation process functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Feb 21, 2024
1 parent 68d3a19 commit cb4e2c8
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tools/rishka-cc/src/process.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
/*
* 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;

use crate::args::Options;
use crate::env::RishkaEnv;
use colored::Colorize;
use std::process::Command;
use std::process::exit;
Expand All @@ -21,6 +40,36 @@ fn check_dep(dep: &str) {
}
}

pub fn run_riscv64_gpp(options: &Options, cc_env: RishkaEnv) -> bool {
match Command::new("riscv64-unknown-elf-g++")
.arg("-march=rv64im")
.arg("-mabi=lp64")
.arg("-nostdlib")
.arg("-O2")
.arg(format!("-Wl,-T,{}/link.ld", cc_env.scripts))
.arg(format!("-I{}", cc_env.library))
.arg(format!("-o{}.out", options.output))
.arg(format!("{}/librishka_impl.cpp", cc_env.library))
.arg(format!("{}/launcher.s", cc_env.scripts))
.arg(options.files.join(" "))
.output() {
Ok(proc)=> proc.status.success(),
Err(_)=> false
}
}

pub fn run_riscv64_objcopy(options: &Options) -> bool {
match Command::new("riscv64-unknown-elf-objcopy")
.arg("-O")
.arg("binary")
.arg(format!("{}.out", options.output))
.arg(format!("{}.bin", options.output))
.output() {
Ok(proc)=> proc.status.success(),
Err(_)=> false
}
}

pub fn check_req_deps() {
check_dep("riscv64-unknown-elf-g++");
check_dep("riscv64-unknown-elf-objcopy");
Expand Down

0 comments on commit cb4e2c8

Please sign in to comment.