@@ -70,6 +70,7 @@ mod json;
70
70
pub use abi_map:: { AbiMap , AbiMapping } ;
71
71
pub use base:: apple;
72
72
pub use base:: avr:: ef_avr_arch;
73
+ pub use json:: json_schema;
73
74
74
75
/// Linker is called through a C/C++ compiler.
75
76
#[ derive( Clone , Copy , Debug , Eq , Ord , PartialEq , PartialOrd ) ]
@@ -523,6 +524,20 @@ linker_flavor_cli_impls! {
523
524
}
524
525
525
526
crate :: 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
+ }
526
541
527
542
impl ToJson for LinkerFlavorCli {
528
543
fn to_json ( & self ) -> Json {
@@ -576,6 +591,18 @@ impl FromStr for LinkSelfContainedDefault {
576
591
}
577
592
578
593
crate :: 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
+ }
579
606
580
607
impl ToJson for LinkSelfContainedDefault {
581
608
fn to_json ( & self ) -> Json {
@@ -708,6 +735,20 @@ impl FromStr for LinkSelfContainedComponents {
708
735
}
709
736
710
737
crate :: 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
+ }
711
752
712
753
impl ToJson for LinkSelfContainedComponents {
713
754
fn to_json ( & self ) -> Json {
@@ -846,7 +887,6 @@ crate::target_spec_enum! {
846
887
parse_error_type = "symbol visibility" ;
847
888
}
848
889
849
-
850
890
#[ derive( Clone , Debug , PartialEq , Hash ) ]
851
891
pub enum SmallDataThresholdSupport {
852
892
None ,
@@ -874,6 +914,18 @@ impl FromStr for SmallDataThresholdSupport {
874
914
}
875
915
876
916
crate :: 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
+ }
877
929
878
930
impl ToJson for SmallDataThresholdSupport {
879
931
fn to_json ( & self ) -> Value {
@@ -1074,7 +1126,7 @@ crate::target_spec_enum! {
1074
1126
1075
1127
into_diag_arg_using_display ! ( SplitDebuginfo ) ;
1076
1128
1077
- #[ derive( Clone , Debug , PartialEq , Eq , serde_derive:: Deserialize ) ]
1129
+ #[ derive( Clone , Debug , PartialEq , Eq , serde_derive:: Deserialize , schemars :: JsonSchema ) ]
1078
1130
#[ serde( tag = "kind" ) ]
1079
1131
#[ serde( rename_all = "kebab-case" ) ]
1080
1132
pub enum StackProbeType {
@@ -1235,6 +1287,19 @@ impl FromStr for SanitizerSet {
1235
1287
}
1236
1288
1237
1289
crate :: 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
+ }
1238
1303
1239
1304
impl ToJson for SanitizerSet {
1240
1305
fn to_json ( & self ) -> Json {
@@ -1328,7 +1393,6 @@ impl BinaryFormat {
1328
1393
}
1329
1394
}
1330
1395
1331
-
1332
1396
impl ToJson for Align {
1333
1397
fn to_json ( & self ) -> Json {
1334
1398
self . bits ( ) . to_json ( )
0 commit comments