@@ -70,6 +70,7 @@ mod json;
7070pub  use  abi_map:: { AbiMap ,  AbiMapping } ; 
7171pub  use  base:: apple; 
7272pub  use  base:: avr:: ef_avr_arch; 
73+ pub  use  json:: json_schema; 
7374
7475/// Linker is called through a C/C++ compiler. 
7576#[ derive( Clone ,  Copy ,  Debug ,  Eq ,  Ord ,  PartialEq ,  PartialOrd ) ]  
@@ -523,6 +524,20 @@ linker_flavor_cli_impls! {
523524} 
524525
525526crate :: json:: serde_deserialize_from_str!( LinkerFlavorCli ) ; 
527+ impl  schemars:: JsonSchema  for  LinkerFlavorCli  { 
528+     fn  schema_name ( )  -> std:: borrow:: Cow < ' static ,  str >  { 
529+         "LinkerFlavor" . into ( ) 
530+     } 
531+     fn  json_schema ( _:  & mut  schemars:: SchemaGenerator )  -> schemars:: Schema  { 
532+         let  all:  Vec < & ' static  str >  =
533+             Self :: all ( ) . iter ( ) . map ( |flavor| flavor. desc ( ) ) . collect :: < Vec < _ > > ( ) ; 
534+         schemars:: json_schema! ( { 
535+             "type" :  "string" , 
536+             "enum" :  all
537+         } ) 
538+         . into ( ) 
539+     } 
540+ } 
526541
527542impl  ToJson  for  LinkerFlavorCli  { 
528543    fn  to_json ( & self )  -> Json  { 
@@ -576,6 +591,18 @@ impl FromStr for LinkSelfContainedDefault {
576591} 
577592
578593crate :: json:: serde_deserialize_from_str!( LinkSelfContainedDefault ) ; 
594+ impl  schemars:: JsonSchema  for  LinkSelfContainedDefault  { 
595+     fn  schema_name ( )  -> std:: borrow:: Cow < ' static ,  str >  { 
596+         "LinkSelfContainedDefault" . into ( ) 
597+     } 
598+     fn  json_schema ( _:  & mut  schemars:: SchemaGenerator )  -> schemars:: Schema  { 
599+         schemars:: json_schema! ( { 
600+             "type" :  "string" , 
601+             "enum" :  [ "false" ,  "true" ,  "wasm" ,  "musl" ,  "mingw" ] 
602+         } ) 
603+         . into ( ) 
604+     } 
605+ } 
579606
580607impl  ToJson  for  LinkSelfContainedDefault  { 
581608    fn  to_json ( & self )  -> Json  { 
@@ -708,6 +735,20 @@ impl FromStr for LinkSelfContainedComponents {
708735} 
709736
710737crate :: json:: serde_deserialize_from_str!( LinkSelfContainedComponents ) ; 
738+ impl  schemars:: JsonSchema  for  LinkSelfContainedComponents  { 
739+     fn  schema_name ( )  -> std:: borrow:: Cow < ' static ,  str >  { 
740+         "LinkSelfContainedComponents" . into ( ) 
741+     } 
742+     fn  json_schema ( _:  & mut  schemars:: SchemaGenerator )  -> schemars:: Schema  { 
743+         let  all =
744+             Self :: all_components ( ) . iter ( ) . map ( |component| component. as_str ( ) ) . collect :: < Vec < _ > > ( ) ; 
745+         schemars:: json_schema! ( { 
746+             "type" :  "string" , 
747+             "enum" :  all, 
748+         } ) 
749+         . into ( ) 
750+     } 
751+ } 
711752
712753impl  ToJson  for  LinkSelfContainedComponents  { 
713754    fn  to_json ( & self )  -> Json  { 
@@ -846,7 +887,6 @@ crate::target_spec_enum! {
846887    parse_error_type = "symbol visibility" ; 
847888} 
848889
849- 
850890#[ derive( Clone ,  Debug ,  PartialEq ,  Hash ) ]  
851891pub  enum  SmallDataThresholdSupport  { 
852892    None , 
@@ -874,6 +914,18 @@ impl FromStr for SmallDataThresholdSupport {
874914} 
875915
876916crate :: json:: serde_deserialize_from_str!( SmallDataThresholdSupport ) ; 
917+ impl  schemars:: JsonSchema  for  SmallDataThresholdSupport  { 
918+     fn  schema_name ( )  -> std:: borrow:: Cow < ' static ,  str >  { 
919+         "SmallDataThresholdSupport" . into ( ) 
920+     } 
921+     fn  json_schema ( _:  & mut  schemars:: SchemaGenerator )  -> schemars:: Schema  { 
922+         schemars:: json_schema! ( { 
923+             "type" :  "string" , 
924+             "pattern" :  r#"^none|default-for-arch|llvm-module-flag=.+|llvm-arg=.+$"# , 
925+         } ) 
926+         . into ( ) 
927+     } 
928+ } 
877929
878930impl  ToJson  for  SmallDataThresholdSupport  { 
879931    fn  to_json ( & self )  -> Value  { 
@@ -1074,7 +1126,7 @@ crate::target_spec_enum! {
10741126
10751127into_diag_arg_using_display ! ( SplitDebuginfo ) ; 
10761128
1077- #[ derive( Clone ,  Debug ,  PartialEq ,  Eq ,  serde_derive:: Deserialize ) ]  
1129+ #[ derive( Clone ,  Debug ,  PartialEq ,  Eq ,  serde_derive:: Deserialize ,  schemars :: JsonSchema ) ]  
10781130#[ serde( tag = "kind" ) ]  
10791131#[ serde( rename_all = "kebab-case" ) ]  
10801132pub  enum  StackProbeType  { 
@@ -1235,6 +1287,19 @@ impl FromStr for SanitizerSet {
12351287} 
12361288
12371289crate :: json:: serde_deserialize_from_str!( SanitizerSet ) ; 
1290+ impl  schemars:: JsonSchema  for  SanitizerSet  { 
1291+     fn  schema_name ( )  -> std:: borrow:: Cow < ' static ,  str >  { 
1292+         "SanitizerSet" . into ( ) 
1293+     } 
1294+     fn  json_schema ( _:  & mut  schemars:: SchemaGenerator )  -> schemars:: Schema  { 
1295+         let  all = Self :: all ( ) . iter ( ) . map ( |sanitizer| sanitizer. as_str ( ) ) . collect :: < Vec < _ > > ( ) ; 
1296+         schemars:: json_schema! ( { 
1297+             "type" :  "string" , 
1298+             "enum" :  all, 
1299+         } ) 
1300+         . into ( ) 
1301+     } 
1302+ } 
12381303
12391304impl  ToJson  for  SanitizerSet  { 
12401305    fn  to_json ( & self )  -> Json  { 
@@ -1328,7 +1393,6 @@ impl BinaryFormat {
13281393    } 
13291394} 
13301395
1331- 
13321396impl  ToJson  for  Align  { 
13331397    fn  to_json ( & self )  -> Json  { 
13341398        self . bits ( ) . to_json ( ) 
0 commit comments