mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Use strum_macros::EnumString for Target
This commit is contained in:
parent
80c3334a18
commit
1423d4f50f
1 changed files with 2 additions and 20 deletions
|
@ -3,7 +3,7 @@
|
||||||
// See github.com/roc-lang/roc/issues/800 for discussion of the large_enum_variant check.
|
// See github.com/roc-lang/roc/issues/800 for discussion of the large_enum_variant check.
|
||||||
#![allow(clippy::large_enum_variant)]
|
#![allow(clippy::large_enum_variant)]
|
||||||
|
|
||||||
use strum_macros::{EnumCount, EnumIter, IntoStaticStr};
|
use strum_macros::{EnumCount, EnumIter, EnumString, IntoStaticStr};
|
||||||
use target_lexicon::Triple;
|
use target_lexicon::Triple;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
@ -160,7 +160,7 @@ impl From<target_lexicon::Architecture> for Architecture {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, EnumIter, IntoStaticStr, PartialEq, Eq, Default)]
|
#[derive(Debug, Copy, Clone, EnumIter, EnumString, IntoStaticStr, PartialEq, Eq, Default)]
|
||||||
pub enum Target {
|
pub enum Target {
|
||||||
#[strum(serialize = "system")]
|
#[strum(serialize = "system")]
|
||||||
#[default]
|
#[default]
|
||||||
|
@ -276,24 +276,6 @@ impl std::fmt::Display for Target {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::str::FromStr for Target {
|
|
||||||
type Err = String;
|
|
||||||
|
|
||||||
fn from_str(string: &str) -> Result<Self, Self::Err> {
|
|
||||||
match string {
|
|
||||||
"system" => Ok(Target::System),
|
|
||||||
"linux-x86-32" => Ok(Target::LinuxX32),
|
|
||||||
"linux-x86-64" => Ok(Target::LinuxX64),
|
|
||||||
"linux-arm-64" => Ok(Target::LinuxArm64),
|
|
||||||
"macos-x86-64" => Ok(Target::MacX64),
|
|
||||||
"macos-arm-64" => Ok(Target::MacArm64),
|
|
||||||
"windows-x86-64" => Ok(Target::WinX64),
|
|
||||||
"wasm-32" => Ok(Target::Wasm32),
|
|
||||||
_ => Err(format!("Roc does not know how to compile to {}", string)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_target_triple_str(target: &target_lexicon::Triple) -> Option<&'static str> {
|
pub fn get_target_triple_str(target: &target_lexicon::Triple) -> Option<&'static str> {
|
||||||
match target {
|
match target {
|
||||||
target_lexicon::Triple {
|
target_lexicon::Triple {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue