@@ -186,6 +186,9 @@ pub enum Cli {
186186 /// print timings
187187 #[ arg( long) ]
188188 timings : bool ,
189+ /// Print header as JSON
190+ #[ arg( long) ]
191+ dump_header : bool ,
189192 } ,
190193 /// multi-file utilities
191194 #[ command( subcommand) ]
@@ -219,12 +222,6 @@ pub enum DbgSubcommand {
219222 #[ arg( long) ]
220223 timings : bool ,
221224 } ,
222- /// Parse a Cobalt header
223- ParseHeader {
224- /// header files to parse
225- #[ arg( required = true ) ]
226- inputs : Vec < Input > ,
227- } ,
228225}
229226#[ derive( Debug , Clone , Subcommand ) ]
230227pub enum MultiSubcommand {
@@ -314,6 +311,9 @@ pub enum MultiSubcommand {
314311 /// print timings
315312 #[ arg( long) ]
316313 timings : bool ,
314+ /// Print header as JSON
315+ #[ arg( long) ]
316+ dump_header : bool ,
317317 } ,
318318}
319319#[ derive( Debug , Clone , Subcommand ) ]
@@ -602,18 +602,6 @@ pub fn driver(cli: Cli) -> anyhow::Result<()> {
602602 print ! ( "{}" , ctx. module. to_string( ) ) ;
603603 reporter. finish ( ) ;
604604 }
605- #[ cfg( debug_assertions) ]
606- DbgSubcommand :: ParseHeader { inputs } => {
607- for mut input in inputs {
608- let ink_ctx = inkwell:: context:: Context :: create ( ) ;
609- let ctx = CompCtx :: new ( & ink_ctx, "<anon>" ) ;
610- let mut file = BufReader :: new ( & mut input) ;
611- match ctx. load ( & mut file) {
612- Ok ( _) => ctx. with_vars ( |v| v. dump ( ) ) ,
613- Err ( e) => eprintln ! ( "error loading {}: {e}" , input. path( ) . display( ) ) ,
614- }
615- }
616- }
617605 } ,
618606 Cli :: Aot {
619607 mut input,
@@ -1268,6 +1256,7 @@ pub fn driver(cli: Cli) -> anyhow::Result<()> {
12681256 headers,
12691257 no_default_link,
12701258 timings,
1259+ dump_header,
12711260 } => {
12721261 struct Reporter {
12731262 timings : bool ,
@@ -1453,6 +1442,9 @@ pub fn driver(cli: Cli) -> anyhow::Result<()> {
14531442 if fail {
14541443 anyhow:: bail!( CompileErrors ( ec) )
14551444 }
1445+ if dump_header {
1446+ serde_json:: to_writer_pretty ( std:: io:: stdout ( ) , & ctx) ?;
1447+ }
14561448 reporter. finish ( ) ;
14571449 }
14581450 Cli :: Multi ( cmd) => match cmd {
@@ -2191,6 +2183,7 @@ pub fn driver(cli: Cli) -> anyhow::Result<()> {
21912183 headers,
21922184 no_default_link,
21932185 timings,
2186+ dump_header,
21942187 } => {
21952188 struct Reporter {
21962189 timings : bool ,
@@ -2431,6 +2424,9 @@ pub fn driver(cli: Cli) -> anyhow::Result<()> {
24312424 if fail {
24322425 anyhow:: bail!( CompileErrors ( ec) )
24332426 }
2427+ if dump_header {
2428+ serde_json:: to_writer_pretty ( std:: io:: stdout ( ) , & ctx) ?;
2429+ }
24342430 reporter. finish ( ) ;
24352431 }
24362432 } ,
0 commit comments