@@ -13,7 +13,8 @@ use wasmparser::types::{CoreTypeId, EntityType, Types};
13
13
use wasmparser:: { Payload , ValidPayload } ;
14
14
use wat:: Detect ;
15
15
use wit_component:: {
16
- embed_component_metadata, ComponentEncoder , DecodedWasm , Linker , StringEncoding , WitPrinter ,
16
+ embed_component_metadata, metadata, ComponentEncoder , DecodedWasm , Linker , StringEncoding ,
17
+ WitPrinter ,
17
18
} ;
18
19
use wit_parser:: { Mangling , PackageId , Resolve } ;
19
20
@@ -308,6 +309,15 @@ pub struct EmbedOpts {
308
309
/// Print the output in the WebAssembly text format instead of binary.
309
310
#[ clap( long, short = 't' ) ]
310
311
wat : bool ,
312
+
313
+ /// Print the wasm custom section only.
314
+ #[ clap(
315
+ long,
316
+ conflicts_with = "wat" ,
317
+ conflicts_with = "dummy" ,
318
+ conflicts_with = "dummy_names"
319
+ ) ]
320
+ only_custom : bool ,
311
321
}
312
322
313
323
impl EmbedOpts {
@@ -318,7 +328,21 @@ impl EmbedOpts {
318
328
/// Executes the application.
319
329
fn run ( self ) -> Result < ( ) > {
320
330
let ( resolve, pkg_id) = self . resolve . load ( ) ?;
331
+
321
332
let world = resolve. select_world ( pkg_id, self . world . as_deref ( ) ) ?;
333
+
334
+ if self . only_custom {
335
+ let encoded = metadata:: encode (
336
+ & resolve,
337
+ world,
338
+ self . encoding . unwrap_or ( StringEncoding :: UTF8 ) ,
339
+ None ,
340
+ ) ?;
341
+
342
+ self . io . output_wasm ( & encoded, false ) ?;
343
+ return Ok ( ( ) ) ;
344
+ }
345
+
322
346
let mut wasm = if self . dummy {
323
347
wit_component:: dummy_module ( & resolve, world, Mangling :: Standard32 )
324
348
} else if let Some ( mangling) = self . dummy_names {
0 commit comments