pub struct CompileTarget { /* private fields */ }Expand description
Abstraction for the representation of a compilation target that Cargo has.
Compilation targets are one of two things right now:
- A raw target string, like
x86_64-unknown-linux-gnu. - The path to a JSON file, such as
/path/to/my-target.json.
Raw target strings are typically dictated by rustc itself and represent
built-in targets. Custom JSON files are somewhat unstable, but supported
here in Cargo. Note that for JSON target files this CompileTarget stores a
full canonicalized path to the target.
The main reason for this existence is to handle JSON target files where when we call rustc we pass full paths but when we use it for Cargo’s purposes like naming directories or looking up configuration keys we only check the file stem of JSON target files. For built-in rustc targets this is just an uninterpreted string basically.
Implementations§
Source§impl CompileTarget
impl CompileTarget
pub fn new(name: &str) -> CargoResult<CompileTarget>
Sourcepub fn rustc_target(&self) -> &str
pub fn rustc_target(&self) -> &str
Returns the full unqualified name of this target, suitable for passing
to rustc directly.
Typically this is pretty much the same as short_name, but for the case
of JSON target files this will be a full canonicalized path name for the
current filesystem.
Sourcepub fn short_name(&self) -> &str
pub fn short_name(&self) -> &str
Returns a “short” version of the target name suitable for usage within Cargo for configuration and such.
This is typically the same as rustc_target, or the full name, but for
JSON target files this returns just the file stem (e.g. foo out of
foo.json) instead of the full path.
Trait Implementations§
Source§impl Clone for CompileTarget
impl Clone for CompileTarget
Source§fn clone(&self) -> CompileTarget
fn clone(&self) -> CompileTarget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more