Executes the command.
(self)
| 106 | impl SettingsCommand { |
| 107 | /// Executes the command. |
| 108 | pub fn execute(self) -> Result<()> { |
| 109 | // Gather settings from the cranelift compiler builder |
| 110 | let mut builder = wasmtime_cranelift::builder(None)?; |
| 111 | let tunables = if let Some(target) = &self.target { |
| 112 | let target = target_lexicon::Triple::from_str(target).map_err(|e| format_err!(e))?; |
| 113 | let tunables = Tunables::default_for_target(&target)?; |
| 114 | builder.target(target)?; |
| 115 | tunables |
| 116 | } else { |
| 117 | Tunables::default_host() |
| 118 | }; |
| 119 | |
| 120 | builder.set_tunables(tunables)?; |
| 121 | let mut settings = Settings::from_builder(&builder); |
| 122 | |
| 123 | // Add inferred settings if no target specified |
| 124 | if self.target.is_none() { |
| 125 | settings.infer(&builder)?; |
| 126 | } |
| 127 | |
| 128 | // Print settings |
| 129 | if self.json { |
| 130 | self.print_json(settings) |
| 131 | } else { |
| 132 | self.print_human_readable(settings) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | fn print_json(self, settings: Settings) -> Result<()> { |
| 137 | println!("{}", serde_json::to_string_pretty(&settings)?); |
nothing calls this directly
no test coverage detected