1 use target_lexicon::{Architecture, Triple}; 2 3 /// Extension methods for `target_lexicon::Triple`. 4 pub trait TripleExt { 5 /// Helper for returning whether this target is for pulley, wasmtime's 6 /// interpreter. is_pulley(&self) -> bool7 fn is_pulley(&self) -> bool; 8 9 /// Returns the target triple for pulley to run on this host. pulley_host() -> Self10 fn pulley_host() -> Self; 11 } 12 13 impl TripleExt for Triple { is_pulley(&self) -> bool14 fn is_pulley(&self) -> bool { 15 match self.architecture { 16 Architecture::Pulley32 | Architecture::Pulley32be => true, 17 Architecture::Pulley64 | Architecture::Pulley64be => true, 18 _ => false, 19 } 20 } 21 pulley_host() -> Self22 fn pulley_host() -> Self { 23 if cfg!(target_endian = "little") { 24 if cfg!(target_pointer_width = "32") { 25 return "pulley32".parse().unwrap(); 26 } else if cfg!(target_pointer_width = "64") { 27 return "pulley64".parse().unwrap(); 28 } 29 } 30 if cfg!(target_endian = "big") { 31 if cfg!(target_pointer_width = "32") { 32 return "pulley32be".parse().unwrap(); 33 } else if cfg!(target_pointer_width = "64") { 34 return "pulley64be".parse().unwrap(); 35 } 36 } 37 38 unreachable!() 39 } 40 } 41