-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for using a custom target under linux Fixes #18 #78
Add support for using a custom target under linux Fixes #18 #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to get input from termoshtt.
@@ -2,10 +2,11 @@ | |||
|
|||
use crate::{check::*, error::*}; | |||
use std::{ | |||
fs, | |||
fmt, fs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run rustfmt.
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
let target = match s.to_ascii_lowercase().as_str() { | ||
"p2" => Self::P2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please also split it into sections with titles just like in the enum? To keep things synced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e3fa176 comment added
|
||
impl fmt::Display for ParseTargetError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
"provided string was not a valid target".fmt(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deviates from the other error messages. Maybe “The target is not supported.”?
} | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort these.
pub struct ParseTargetError; | ||
|
||
impl fmt::Display for ParseTargetError { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call it formatter
.
impl FromStr for Target { | ||
type Err = ParseTargetError; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call it string
or value
.
@@ -116,6 +117,99 @@ pub enum Target { | |||
Z14, | |||
} | |||
|
|||
impl FromStr for Target { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably generate both the enum and this impl via a macro to avoid repetition. But if cumbersome, let’s keep it as is.
@@ -104,6 +104,10 @@ fn build() { | |||
} else { | |||
cfg.no_static = true; | |||
} | |||
cfg.target = match env::var("OPENBLAS_TARGET") { | |||
Ok(target) => target.parse().ok(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the error is ignored, I propose to remove ParseTargetError
all together. Just use some existing struct to satisfy the trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParseTargetError
is merged in openblas_build::error::Error::UnsupportedTarget
cee2fd0
cfg.target = match env::var("OPENBLAS_TARGET") { | ||
Ok(target) => target.parse().ok(), | ||
_ => None, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change here in e25b20f to immediately panic when $OPENBLAS_TARGET
is invalid.
Manually trigger CI for additional commit |
This allows the requested target to be specified by the environment variable
OPENBLAS_TARGET
under linux. This fixes #18