@@ -69,6 +69,7 @@ mod json;
69
69
pub use abi_map:: { AbiMap , AbiMapping } ;
70
70
pub use base:: apple;
71
71
pub use base:: avr:: ef_avr_arch;
72
+ pub use json:: json_schema;
72
73
73
74
/// Linker is called through a C/C++ compiler.
74
75
#[ derive( Clone , Copy , Debug , Eq , Ord , PartialEq , PartialOrd ) ]
@@ -522,6 +523,20 @@ linker_flavor_cli_impls! {
522
523
}
523
524
524
525
crate :: 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
+ }
525
540
526
541
impl ToJson for LinkerFlavorCli {
527
542
fn to_json ( & self ) -> Json {
@@ -575,6 +590,18 @@ impl FromStr for LinkSelfContainedDefault {
575
590
}
576
591
577
592
crate :: 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
+ }
578
605
579
606
impl ToJson for LinkSelfContainedDefault {
580
607
fn to_json ( & self ) -> Json {
@@ -707,6 +734,20 @@ impl FromStr for LinkSelfContainedComponents {
707
734
}
708
735
709
736
crate :: 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
+ }
710
751
711
752
impl ToJson for LinkSelfContainedComponents {
712
753
fn to_json ( & self ) -> Json {
@@ -839,7 +880,6 @@ crate::target_spec_enum! {
839
880
parse_error_type = "symbol visibility" ;
840
881
}
841
882
842
-
843
883
#[ derive( Clone , Debug , PartialEq , Hash ) ]
844
884
pub enum SmallDataThresholdSupport {
845
885
None ,
@@ -867,6 +907,17 @@ impl FromStr for SmallDataThresholdSupport {
867
907
}
868
908
869
909
crate :: 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
+ }
870
921
871
922
impl ToJson for SmallDataThresholdSupport {
872
923
fn to_json ( & self ) -> Value {
@@ -1065,7 +1116,7 @@ crate::target_spec_enum! {
1065
1116
parse_error_type = "split debuginfo" ;
1066
1117
}
1067
1118
1068
- #[ derive( Clone , Debug , PartialEq , Eq , serde_derive:: Deserialize ) ]
1119
+ #[ derive( Clone , Debug , PartialEq , Eq , serde_derive:: Deserialize , schemars :: JsonSchema ) ]
1069
1120
#[ serde( tag = "kind" ) ]
1070
1121
#[ serde( rename_all = "kebab-case" ) ]
1071
1122
pub enum StackProbeType {
@@ -1226,6 +1277,19 @@ impl FromStr for SanitizerSet {
1226
1277
}
1227
1278
1228
1279
crate :: 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
+ }
1229
1293
1230
1294
impl ToJson for SanitizerSet {
1231
1295
fn to_json ( & self ) -> Json {
@@ -1317,7 +1381,6 @@ impl BinaryFormat {
1317
1381
}
1318
1382
}
1319
1383
1320
-
1321
1384
impl ToJson for Align {
1322
1385
fn to_json ( & self ) -> Json {
1323
1386
self . bits ( ) . to_json ( )
0 commit comments