@@ -4,13 +4,14 @@ use polonius_engine::{Algorithm, Engine};
44use std:: env;
55use std:: error;
66use std:: fmt;
7- use std:: path:: Path ;
7+ use std:: path:: { Path , PathBuf } ;
88use std:: process:: exit;
99use std:: str:: FromStr ;
1010use std:: time:: { Duration , Instant } ;
1111
1212use crate :: dump;
1313use crate :: dump:: Output ;
14+ use crate :: facts:: AllFacts ;
1415use crate :: intern;
1516use crate :: tab_delim;
1617
@@ -77,16 +78,9 @@ pub fn main(opt: Options) -> Result<(), Error> {
7778 . souffle_name ( )
7879 . expect ( "Algorithm does not have Soufflé version" ) ;
7980
80- // FIXME This time includes loading/unloading tuples across the FFI boundary.
81- let ( duration, output) = timed ( || polonius_souffle:: run_from_facts ( name, & all_facts) ) ;
82- if !opt. skip_timing {
83- let seconds = duration. as_secs ( ) as f64 ;
84- let millis = f64:: from ( duration. subsec_nanos ( ) ) * 0.000_000_001_f64 ;
85- println ! ( "Time: {:0.3}s" , seconds + millis) ;
86- }
87- if opt. show_tuples {
88- dump:: dump_souffle_output ( & output, & output_directory, tables, opt. verbose )
89- . expect ( "Failed to write output" ) ;
81+ if let Err ( e) = run_polonius_souffle ( & all_facts, & output_directory, tables, name, & opt)
82+ {
83+ error ! ( "`{}`: {}" , facts_dir, e) ;
9084 }
9185
9286 continue ;
@@ -115,6 +109,40 @@ pub fn main(opt: Options) -> Result<(), Error> {
115109 Ok ( ( ) )
116110}
117111
112+ #[ cfg( feature = "polonius-souffle" ) ]
113+ fn run_polonius_souffle (
114+ all_facts : & AllFacts ,
115+ output_directory : & Option < PathBuf > ,
116+ tables : & intern:: InternerTables ,
117+ souffle_name : & str ,
118+ opt : & Options ,
119+ ) {
120+ // FIXME This time includes loading/unloading tuples across the FFI boundary.
121+ let ( duration, output) = timed ( || polonius_souffle:: run_from_facts ( souffle_name, & all_facts) ) ;
122+ if !opt. skip_timing {
123+ let seconds = duration. as_secs ( ) as f64 ;
124+ let millis = f64:: from ( duration. subsec_nanos ( ) ) * 0.000_000_001_f64 ;
125+ println ! ( "Time: {:0.3}s" , seconds + millis) ;
126+ }
127+ if opt. show_tuples {
128+ dump:: dump_souffle_output ( & output, & output_directory, tables, opt. verbose )
129+ . expect ( "Failed to write output" ) ;
130+ }
131+ }
132+
133+ #[ cfg( not( feature = "polonius-souffle" ) ) ]
134+ fn run_polonius_souffle (
135+ _: & AllFacts ,
136+ _: & Option < PathBuf > ,
137+ _: & intern:: InternerTables ,
138+ _: & str ,
139+ _: & Options ,
140+ ) -> Result < ( ) , Error > {
141+ Err ( Error (
142+ "`polonius` was compiled without Soufflé backend (`--feature polonius-souffle`)" . into ( ) ,
143+ ) )
144+ }
145+
118146fn timed < T > ( op : impl FnOnce ( ) -> T ) -> ( Duration , T ) {
119147 let start = Instant :: now ( ) ;
120148 let output = op ( ) ;
0 commit comments