From 78e9f779503a6d3708dd0d6895ce6353d4f073da Mon Sep 17 00:00:00 2001 From: Robin Randhawa <robin.randhawa@arm.com> Date: Thu, 28 Feb 2019 13:05:24 +0000 Subject: [PATCH] Get TARGET from the environment This enables flexible cross-installation of packages as opposed to only compiling for the x86_64-unknown-redox target. This also permits native builds. --- src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1e512e2..1126a21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,6 @@ use std::str::FromStr; pub(crate) type Result<T> = std::result::Result<T, Error>; const REMOTE: &'static str = "https://static.redox-os.org/pkg"; -const TARGET: &'static str = "x86_64-unknown-redox"; /// Converts a password to a serialized argon2rs hash, understandable /// by redox_users. If the password is blank, the hash is blank. @@ -87,7 +86,9 @@ fn prompt_password(prompt: &str, confirm_prompt: &str) -> Result<String> { } fn install_packages<S: AsRef<str>>(config: &Config, dest: &str, cookbook: Option<S>) { - let mut repo = Repo::new(TARGET); + let target = &env::var("TARGET").unwrap_or(env!("TARGET").to_string()); + + let mut repo = Repo::new(target); repo.add_remote(REMOTE); if let Some(cookbook) = cookbook { @@ -108,7 +109,7 @@ fn install_packages<S: AsRef<str>>(config: &Config, dest: &str, cookbook: Option println!("Installing package {}", packagename); let path = format!("{}/{}/repo/{}/{}.tar.gz", env::current_dir().unwrap().to_string_lossy(), - cookbook.as_ref(), TARGET, packagename); + cookbook.as_ref(), target, packagename); Package::from_path(&path).unwrap().install(dest).unwrap(); } } else { -- GitLab