Make --target flags be linux32 and linux64

This commit is contained in:
Richard Feldman 2022-04-13 00:10:02 -04:00
parent 2e1b384bdc
commit 746fb6ce88
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798

View file

@ -15,7 +15,9 @@ use std::path::PathBuf;
use std::process; use std::process;
use std::process::Command; use std::process::Command;
use target_lexicon::BinaryFormat; use target_lexicon::BinaryFormat;
use target_lexicon::{Architecture, OperatingSystem, Triple, X86_32Architecture}; use target_lexicon::{
Architecture, Environment, OperatingSystem, Triple, Vendor, X86_32Architecture,
};
pub mod build; pub mod build;
mod format; mod format;
@ -509,8 +511,8 @@ fn run_with_wasmer(_wasm_path: &std::path::Path, _args: &[String]) {
enum Target { enum Target {
Host, Host,
X86_32, Linux32,
X86_64, Linux64,
Wasm32, Wasm32,
} }
@ -522,48 +524,50 @@ impl Default for Target {
impl Target { impl Target {
const fn as_str(&self) -> &'static str { const fn as_str(&self) -> &'static str {
use Target::*;
match self { match self {
Target::Host => "host", Host => "host",
Target::X86_32 => "x86_32", Linux32 => "linux32",
Target::X86_64 => "x86_64", Linux64 => "linux64",
Target::Wasm32 => "wasm32", Wasm32 => "wasm32",
} }
} }
/// NOTE keep up to date! /// NOTE keep up to date!
const OPTIONS: &'static [&'static str] = &[ const OPTIONS: &'static [&'static str] = &[
Target::Host.as_str(), Target::Host.as_str(),
Target::X86_32.as_str(), Target::Linux32.as_str(),
Target::X86_64.as_str(), Target::Linux64.as_str(),
Target::Wasm32.as_str(), Target::Wasm32.as_str(),
]; ];
fn to_triple(&self) -> Triple { fn to_triple(&self) -> Triple {
let mut triple = Triple::unknown(); use Target::*;
match self { match self {
Target::Host => Triple::host(), Host => Triple::host(),
Target::X86_32 => { Linux32 => Triple {
triple.architecture = Architecture::X86_32(X86_32Architecture::I386); architecture: Architecture::X86_32(X86_32Architecture::I386),
triple.binary_format = BinaryFormat::Elf; vendor: Vendor::Unknown,
operating_system: OperatingSystem::Linux,
// TODO make this user-specified? environment: Environment::Unknown,
triple.operating_system = OperatingSystem::Linux; binary_format: BinaryFormat::Elf,
},
triple Linux64 => Triple {
} architecture: Architecture::X86_64,
Target::X86_64 => { vendor: Vendor::Unknown,
triple.architecture = Architecture::X86_64; operating_system: OperatingSystem::Linux,
triple.binary_format = BinaryFormat::Elf; environment: Environment::Unknown,
binary_format: BinaryFormat::Elf,
triple },
} Wasm32 => Triple {
Target::Wasm32 => { architecture: Architecture::Wasm32,
triple.architecture = Architecture::Wasm32; vendor: Vendor::Unknown,
triple.binary_format = BinaryFormat::Wasm; operating_system: OperatingSystem::Unknown,
environment: Environment::Unknown,
triple binary_format: BinaryFormat::Wasm,
} },
} }
} }
} }
@ -586,8 +590,8 @@ impl std::str::FromStr for Target {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
match s { match s {
"host" => Ok(Target::Host), "host" => Ok(Target::Host),
"x86_32" => Ok(Target::X86_32), "linux32" => Ok(Target::Linux32),
"x86_64" => Ok(Target::X86_64), "linux64" => Ok(Target::Linux64),
"wasm32" => Ok(Target::Wasm32), "wasm32" => Ok(Target::Wasm32),
_ => Err(()), _ => Err(()),
} }