/// Uses the given target triple or tries the guess the current target by using the one used
/// for compilation
///
/// Fails if the target triple isn't supported
Uses the given target triple or tries the guess the current target by using the one used
for compilation

Fails if the target triple isn't supported
Uses the given target triple or tries the guess the current target by using the one used for compilation Fails if the target triple isn ' t supported
pub fn from_target_triple(target_triple: Option<String>) -> Result<Self> {
        let platform = if let Some(ref target_triple) = target_triple {
            Platform::find(target_triple)
                .ok_or_else(|| format_err!("Unknown target triple {}", target_triple))?
        } else {
            Platform::guess_current()
                .ok_or_else(|| format_err!("Could guess the current platform"))?
        };
        let os = match platform.target_os {
            platforms::target::OS::Linux => Os::Linux,
            platforms::target::OS::Windows => Os::Windows,
            platforms::target::OS::MacOS => Os::Macos,
            platforms::target::OS::FreeBSD => Os::FreeBsd,
            unsupported => bail!("The operating system {:?} is not supported", unsupported),
        };
        let arch = match platform.target_arch {
            platforms::target::Arch::X86_64 => Arch::X86_64,
            platforms::target::Arch::X86 => Arch::X86,
            platforms::target::Arch::ARM => Arch::Armv7L,
            platforms::target::Arch::AARCH64 => Arch::Aarch64,
            platforms::target::Arch::POWERPC64
                if platform.target_triple.starts_with("powerpc64-") =>
            {
                Arch::Powerpc64
            }
            platforms::target::Arch::POWERPC64
                if platform.target_triple.starts_with("powerpc64le-") =>
            {
                Arch::Powerpc64Le
            }
            unsupported => bail!("The architecture {:?} is not supported", unsupported),
        };
        // bail on any unsupported targets
        match (&os, &arch) {
            (Os::FreeBsd, Arch::Aarch64) => bail!("aarch64 is not supported for FreeBSD"),
            (Os::FreeBsd, Arch::Armv7L) => bail!("armv7l is not supported for FreeBSD"),
            (Os::FreeBsd, Arch::X86) => bail!("32-bit wheels are not supported for FreeBSD"),
            (Os::FreeBsd, Arch::X86_64) => {
                match PlatformInfo::new() {
                    Ok(_) => {}
                    Err(error) => bail!(error),
                };
            }
            (Os::Macos, Arch::Armv7L) => bail!("armv7l is not supported for macOS"),
            (Os::Macos, Arch::X86) => bail!("32-bit wheels are not supported for macOS"),
            (Os::Windows, Arch::Aarch64) => bail!("aarch64 is not supported for Windows"),
            (Os::Windows, Arch::Armv7L) => bail!("armv7l is not supported for Windows"),
            (_, _) => {}
        }
        Ok(Target {
            os,
            arch,
            env: platform.target_env,
            triple: platform.target_triple,
        })
    }
pub fn from_target_triple ( target_triple : Option < String > ) -> Result < Self > { let platform = if let Some ( ref target_triple ) = target_triple { Platform :: find ( target_triple ) . ok_or_else ( | | format_err ! ( " " target_triple ) ) ? } else { Platform :: guess_current ( ) . ok_or_else ( | | format_err ! ( " " ) ) ? } ; let os = match platform . target_os { platforms :: target :: OS :: Linux => Os :: Linux , platforms :: target :: OS :: Windows => Os :: Windows , platforms :: target :: OS :: MacOS => Os :: Macos , platforms :: target :: OS :: FreeBSD => Os :: FreeBsd , unsupported => bail ! ( " " unsupported ) , } ; let arch = match platform . target_arch { platforms :: target :: Arch :: X86_64 => Arch :: X86_64 , platforms :: target :: Arch :: X86 => Arch :: X86 , platforms :: target :: Arch :: ARM => Arch :: Armv7L , platforms :: target :: Arch :: AARCH64 => Arch :: Aarch64 , platforms :: target :: Arch :: POWERPC64 if platform . target_triple . starts_with ( " " ) => { Arch :: Powerpc64 } platforms :: target :: Arch :: POWERPC64 if platform . target_triple . starts_with ( " " ) => { Arch :: Powerpc64Le } unsupported => bail ! ( " " unsupported ) , } ; // bail on any unsupported targets match ( & os , & arch ) { ( Os :: FreeBsd , Arch :: Aarch64 ) => bail ! ( " " ) , ( Os :: FreeBsd , Arch :: Armv7L ) => bail ! ( " " ) , ( Os :: FreeBsd , Arch :: X86 ) => bail ! ( " " ) , ( Os :: FreeBsd , Arch :: X86_64 ) => { match PlatformInfo :: new ( ) { Ok ( _ ) => { } Err ( error ) => bail ! ( error ) , } ; } ( Os :: Macos , Arch :: Armv7L ) => bail ! ( " " ) , ( Os :: Macos , Arch :: X86 ) => bail ! ( " " ) , ( Os :: Windows , Arch :: Aarch64 ) => bail ! ( " " ) , ( Os :: Windows , Arch :: Armv7L ) => bail ! ( " " ) , ( _ , _ ) => { } } Ok ( Target { os , arch , env : platform . target_env , triple : platform . target_triple , } ) }
Uses the given target triple or tries the guess the current target by using the one used
for compilation
Uses the given target triple or tries the guess the current target by using the one used for compilation
target_triple
Option<String>