Skip to content
Snippets Groups Projects
Commit a66151be authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'riscv' into 'master'

RISC-V target support

See merge request !24
parents 27fa0914 6aea2b05
No related branches found
No related tags found
1 merge request!24RISC-V target support
use std::{env, ffi, io, process}; use std::{env, ffi, io, process};
use crate::{status_error, target, toolchain}; use crate::{gnu_target, status_error, target, toolchain};
pub fn command<S: AsRef<ffi::OsStr>>(program: S) -> io::Result<process::Command> { pub fn command<S: AsRef<ffi::OsStr>>(program: S) -> io::Result<process::Command> {
let toolchain_dir = toolchain()?; let toolchain_dir = toolchain()?;
...@@ -15,9 +15,9 @@ pub fn command<S: AsRef<ffi::OsStr>>(program: S) -> io::Result<process::Command> ...@@ -15,9 +15,9 @@ pub fn command<S: AsRef<ffi::OsStr>>(program: S) -> io::Result<process::Command>
env::set_var("PATH", new_path); env::set_var("PATH", new_path);
} }
let ar = format!("{}-ar", target()); let ar = format!("{}-ar", gnu_target());
let cc = format!("{}-gcc", target()); let cc = format!("{}-gcc", gnu_target());
let cxx = format!("{}-g++", target()); let cxx = format!("{}-g++", gnu_target());
let cc_target_var = target().replace("-", "_"); let cc_target_var = target().replace("-", "_");
let cargo_target_var = cc_target_var.to_uppercase(); let cargo_target_var = cc_target_var.to_uppercase();
...@@ -28,6 +28,7 @@ pub fn command<S: AsRef<ffi::OsStr>>(program: S) -> io::Result<process::Command> ...@@ -28,6 +28,7 @@ pub fn command<S: AsRef<ffi::OsStr>>(program: S) -> io::Result<process::Command>
command.env(format!("CXX_{}", cc_target_var), &cxx); command.env(format!("CXX_{}", cc_target_var), &cxx);
command.env("RUSTUP_TOOLCHAIN", &toolchain_dir); command.env("RUSTUP_TOOLCHAIN", &toolchain_dir);
command.env("TARGET", target()); command.env("TARGET", target());
command.env("GNU_TARGET", gnu_target());
Ok(command) Ok(command)
} }
......
...@@ -12,6 +12,7 @@ const SUPPORTED_TARGETS: &'static [&'static str] = &[ ...@@ -12,6 +12,7 @@ const SUPPORTED_TARGETS: &'static [&'static str] = &[
"x86_64-unknown-redox", "x86_64-unknown-redox",
"aarch64-unknown-redox", "aarch64-unknown-redox",
"i686-unknown-redox", "i686-unknown-redox",
"riscv64gc-unknown-redox",
]; ];
fn installed(program: &str) -> io::Result<bool> { fn installed(program: &str) -> io::Result<bool> {
...@@ -71,6 +72,15 @@ pub fn target() -> &'static str { ...@@ -71,6 +72,15 @@ pub fn target() -> &'static str {
SUPPORTED_TARGETS[index] SUPPORTED_TARGETS[index]
} }
pub fn gnu_target() -> &'static str {
let rust_target = target();
if rust_target == "riscv64gc-unknown-redox" {
"riscv64-unknown-redox"
} else {
rust_target
}
}
pub fn main(args: &[String]) { pub fn main(args: &[String]) {
match args.get(1) { match args.get(1) {
Some(arg) => match arg.as_str() { Some(arg) => match arg.as_str() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment