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,
        })
    }
/// 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>
target_triple
Option<String>