@@ -69,6 +69,7 @@ mod json;
6969pub use abi_map:: { AbiMap , AbiMapping } ;
7070pub use base:: apple;
7171pub use base:: avr:: ef_avr_arch;
72+ pub use json:: json_schema;
7273
7374/// Linker is called through a C/C++ compiler.
7475#[ derive( Clone , Copy , Debug , Eq , Ord , PartialEq , PartialOrd ) ]
@@ -522,6 +523,20 @@ linker_flavor_cli_impls! {
522523}
523524
524525crate :: json:: serde_deserialize_from_str!( LinkerFlavorCli ) ;
526+ impl schemars:: JsonSchema for LinkerFlavorCli {
527+ fn schema_name ( ) -> std:: borrow:: Cow < ' static , str > {
528+ "LinkerFlavor" . into ( )
529+ }
530+ fn json_schema ( _: & mut schemars:: SchemaGenerator ) -> schemars:: Schema {
531+ let all: Vec < & ' static str > =
532+ Self :: all ( ) . iter ( ) . map ( |flavor| flavor. desc ( ) ) . collect :: < Vec < _ > > ( ) ;
533+ schemars:: json_schema! ( {
534+ "type" : "string" ,
535+ "enum" : all
536+ } )
537+ . into ( )
538+ }
539+ }
525540
526541impl ToJson for LinkerFlavorCli {
527542 fn to_json ( & self ) -> Json {
@@ -575,6 +590,18 @@ impl FromStr for LinkSelfContainedDefault {
575590}
576591
577592crate :: json:: serde_deserialize_from_str!( LinkSelfContainedDefault ) ;
593+ impl schemars:: JsonSchema for LinkSelfContainedDefault {
594+ fn schema_name ( ) -> std:: borrow:: Cow < ' static , str > {
595+ "LinkSelfContainedDefault" . into ( )
596+ }
597+ fn json_schema ( _: & mut schemars:: SchemaGenerator ) -> schemars:: Schema {
598+ schemars:: json_schema! ( {
599+ "type" : "string" ,
600+ "enum" : [ "false" , "true" , "wasm" , "musl" , "mingw" ]
601+ } )
602+ . into ( )
603+ }
604+ }
578605
579606impl ToJson for LinkSelfContainedDefault {
580607 fn to_json ( & self ) -> Json {
@@ -707,6 +734,20 @@ impl FromStr for LinkSelfContainedComponents {
707734}
708735
709736crate :: json:: serde_deserialize_from_str!( LinkSelfContainedComponents ) ;
737+ impl schemars:: JsonSchema for LinkSelfContainedComponents {
738+ fn schema_name ( ) -> std:: borrow:: Cow < ' static , str > {
739+ "LinkSelfContainedComponents" . into ( )
740+ }
741+ fn json_schema ( _: & mut schemars:: SchemaGenerator ) -> schemars:: Schema {
742+ let all =
743+ Self :: all_components ( ) . iter ( ) . map ( |component| component. as_str ( ) ) . collect :: < Vec < _ > > ( ) ;
744+ schemars:: json_schema! ( {
745+ "type" : "string" ,
746+ "enum" : all,
747+ } )
748+ . into ( )
749+ }
750+ }
710751
711752impl ToJson for LinkSelfContainedComponents {
712753 fn to_json ( & self ) -> Json {
@@ -839,7 +880,6 @@ crate::target_spec_enum! {
839880 parse_error_type = "symbol visibility" ;
840881}
841882
842-
843883#[ derive( Clone , Debug , PartialEq , Hash ) ]
844884pub enum SmallDataThresholdSupport {
845885 None ,
@@ -867,6 +907,17 @@ impl FromStr for SmallDataThresholdSupport {
867907}
868908
869909crate :: json:: serde_deserialize_from_str!( SmallDataThresholdSupport ) ;
910+ impl schemars:: JsonSchema for SmallDataThresholdSupport {
911+ fn schema_name ( ) -> std:: borrow:: Cow < ' static , str > {
912+ "SmallDataThresholdSupport" . into ( )
913+ }
914+ fn json_schema ( _: & mut schemars:: SchemaGenerator ) -> schemars:: Schema {
915+ schemars:: json_schema! ( {
916+ "type" : "string" ,
917+ } )
918+ . into ( )
919+ }
920+ }
870921
871922impl ToJson for SmallDataThresholdSupport {
872923 fn to_json ( & self ) -> Value {
@@ -1065,7 +1116,7 @@ crate::target_spec_enum! {
10651116 parse_error_type = "split debuginfo" ;
10661117}
10671118
1068- #[ derive( Clone , Debug , PartialEq , Eq , serde_derive:: Deserialize ) ]
1119+ #[ derive( Clone , Debug , PartialEq , Eq , serde_derive:: Deserialize , schemars :: JsonSchema ) ]
10691120#[ serde( tag = "kind" ) ]
10701121#[ serde( rename_all = "kebab-case" ) ]
10711122pub enum StackProbeType {
@@ -1226,6 +1277,19 @@ impl FromStr for SanitizerSet {
12261277}
12271278
12281279crate :: json:: serde_deserialize_from_str!( SanitizerSet ) ;
1280+ impl schemars:: JsonSchema for SanitizerSet {
1281+ fn schema_name ( ) -> std:: borrow:: Cow < ' static , str > {
1282+ "SanitizerSet" . into ( )
1283+ }
1284+ fn json_schema ( _: & mut schemars:: SchemaGenerator ) -> schemars:: Schema {
1285+ let all = Self :: all ( ) . iter ( ) . map ( |sanitizer| sanitizer. as_str ( ) ) . collect :: < Vec < _ > > ( ) ;
1286+ schemars:: json_schema! ( {
1287+ "type" : "string" ,
1288+ "enum" : all,
1289+ } )
1290+ . into ( )
1291+ }
1292+ }
12291293
12301294impl ToJson for SanitizerSet {
12311295 fn to_json ( & self ) -> Json {
@@ -1317,7 +1381,6 @@ impl BinaryFormat {
13171381 }
13181382}
13191383
1320-
13211384impl ToJson for Align {
13221385 fn to_json ( & self ) -> Json {
13231386 self . bits ( ) . to_json ( )
0 commit comments