@@ -195,16 +195,7 @@ pub enum Backend<E: Extension> {
195195
196196impl fmt:: Display for Backend < ( ) > {
197197 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
198- match self {
199- Backend :: Fstar { .. } => write ! ( f, "fstar" ) ,
200- Backend :: Coq { .. } => write ! ( f, "coq" ) ,
201- Backend :: Ssprove { .. } => write ! ( f, "ssprove" ) ,
202- Backend :: Easycrypt { .. } => write ! ( f, "easycrypt" ) ,
203- Backend :: ProVerif { .. } => write ! ( f, "proverif" ) ,
204- Backend :: Lean { .. } => write ! ( f, "lean" ) ,
205- Backend :: Rust { .. } => write ! ( f, "rust" ) ,
206- Backend :: GenerateRustEngineNames { .. } => write ! ( f, "generate_rust_engine_names" ) ,
207- }
198+ BackendName :: from ( self ) . fmt ( f)
208199 }
209200}
210201
@@ -537,4 +528,75 @@ impl From<Options> for hax_frontend_exporter_options::Options {
537528 }
538529}
539530
531+ /// The subset of `Options` the frontend is sensible to.
532+ #[ derive_group( Serializers ) ]
533+ #[ derive( JsonSchema , Debug , Clone ) ]
534+ pub struct ExporterOptions {
535+ pub deps : bool ,
536+ pub force_cargo_build : ForceCargoBuild ,
537+ pub backend : Option < BackendName > ,
538+ pub body_kinds : Vec < ExportBodyKind > ,
539+ }
540+
541+ #[ derive_group( Serializers ) ]
542+ #[ derive( JsonSchema , Debug , Clone , Copy ) ]
543+ pub enum BackendName {
544+ Fstar ,
545+ Coq ,
546+ Ssprove ,
547+ Easycrypt ,
548+ ProVerif ,
549+ Lean ,
550+ Rust ,
551+ GenerateRustEngineNames ,
552+ }
553+
554+ impl fmt:: Display for BackendName {
555+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
556+ let name = match self {
557+ BackendName :: Fstar => "fstar" ,
558+ BackendName :: Coq => "coq" ,
559+ BackendName :: Ssprove => "ssprove" ,
560+ BackendName :: Easycrypt => "easycrypt" ,
561+ BackendName :: ProVerif => "proverif" ,
562+ BackendName :: Lean => "lean" ,
563+ BackendName :: Rust => "rust" ,
564+ BackendName :: GenerateRustEngineNames => "generate_rust_engine_names" ,
565+ } ;
566+ write ! ( f, "{name}" )
567+ }
568+ }
569+
570+ impl From < & Options > for ExporterOptions {
571+ fn from ( options : & Options ) -> Self {
572+ let backend = match & options. command {
573+ Command :: Backend ( backend_options) => Some ( ( & backend_options. backend ) . into ( ) ) ,
574+ _ => None ,
575+ } ;
576+ let body_kinds = options. command . body_kinds ( ) ;
577+ ExporterOptions {
578+ deps : options. deps ,
579+ force_cargo_build : options. force_cargo_build . clone ( ) ,
580+ backend,
581+ body_kinds,
582+ }
583+ }
584+ }
585+
586+ impl From < & Backend < ( ) > > for BackendName {
587+ fn from ( backend : & Backend < ( ) > ) -> Self {
588+ match backend {
589+ Backend :: Fstar { .. } => BackendName :: Fstar ,
590+ Backend :: Coq { .. } => BackendName :: Coq ,
591+ Backend :: Ssprove { .. } => BackendName :: Ssprove ,
592+ Backend :: Easycrypt { .. } => BackendName :: Easycrypt ,
593+ Backend :: ProVerif { .. } => BackendName :: ProVerif ,
594+ Backend :: Lean { .. } => BackendName :: Lean ,
595+ Backend :: Rust { .. } => BackendName :: Rust ,
596+ Backend :: GenerateRustEngineNames { .. } => BackendName :: GenerateRustEngineNames ,
597+ }
598+ }
599+ }
600+
540601pub const ENV_VAR_OPTIONS_FRONTEND : & str = "DRIVER_HAX_FRONTEND_OPTS" ;
602+ pub const ENV_VAR_OPTIONS_FULL : & str = "DRIVER_HAX_FRONTEND_FULL_OPTS" ;
0 commit comments