@@ -109,23 +109,23 @@ use crate::{
109109 output:: { AggregatedCompilerOutput , Builds } ,
110110 report,
111111 resolver:: GraphEdges ,
112- ArtifactOutput , Graph , Project , ProjectCompileOutput , Sources ,
112+ ArtifactOutput , CompilerSettings , Graph , Project , ProjectCompileOutput , Sources ,
113113} ;
114114use foundry_compilers_core:: error:: Result ;
115115use rayon:: prelude:: * ;
116116use semver:: Version ;
117117use std:: { collections:: HashMap , path:: PathBuf , time:: Instant } ;
118118
119119/// A set of different Solc installations with their version and the sources to be compiled
120- pub ( crate ) type VersionedSources < L > = HashMap < L , HashMap < Version , Sources > > ;
120+ pub ( crate ) type VersionedSources < L , S > = HashMap < L , Vec < ( Version , Sources , S ) > > ;
121121
122122#[ derive( Debug ) ]
123123pub struct ProjectCompiler < ' a , T : ArtifactOutput , C : Compiler > {
124124 /// Contains the relationship of the source files and their imports
125125 edges : GraphEdges < C :: ParsedSource > ,
126126 project : & ' a Project < C , T > ,
127127 /// how to compile all the sources
128- sources : CompilerSources < C :: Language > ,
128+ sources : CompilerSources < C :: Language , C :: Settings > ,
129129}
130130
131131impl < ' a , T : ArtifactOutput , C : Compiler > ProjectCompiler < ' a , T , C > {
@@ -146,11 +146,7 @@ impl<'a, T: ArtifactOutput, C: Compiler> ProjectCompiler<'a, T, C> {
146146 sources. retain ( |f, _| filter. is_match ( f) )
147147 }
148148 let graph = Graph :: resolve_sources ( & project. paths , sources) ?;
149- let ( sources, edges) = graph. into_sources_by_version (
150- project. offline ,
151- & project. locked_versions ,
152- & project. compiler ,
153- ) ?;
149+ let ( sources, edges) = graph. into_sources_by_version ( project) ?;
154150
155151 // If there are multiple different versions, and we can use multiple jobs we can compile
156152 // them in parallel.
@@ -218,7 +214,7 @@ impl<'a, T: ArtifactOutput, C: Compiler> ProjectCompiler<'a, T, C> {
218214#[ derive( Debug ) ]
219215struct PreprocessedState < ' a , T : ArtifactOutput , C : Compiler > {
220216 /// Contains all the sources to compile.
221- sources : CompilerSources < C :: Language > ,
217+ sources : CompilerSources < C :: Language , C :: Settings > ,
222218
223219 /// Cache that holds `CacheEntry` objects if caching is enabled and the project is recompiled
224220 cache : ArtifactsCache < ' a , T , C > ,
@@ -358,14 +354,14 @@ impl<'a, T: ArtifactOutput, C: Compiler> ArtifactsState<'a, T, C> {
358354
359355/// Determines how the `solc <-> sources` pairs are executed.
360356#[ derive( Debug , Clone ) ]
361- struct CompilerSources < L > {
357+ struct CompilerSources < L , S > {
362358 /// The sources to compile.
363- sources : VersionedSources < L > ,
359+ sources : VersionedSources < L , S > ,
364360 /// The number of jobs to use for parallel compilation.
365361 jobs : Option < usize > ,
366362}
367363
368- impl < L : Language > CompilerSources < L > {
364+ impl < L : Language , S : CompilerSettings > CompilerSources < L , S > {
369365 /// Converts all `\\` separators to `/`.
370366 ///
371367 /// This effectively ensures that `solc` can find imported files like `/src/Cheats.sol` in the
@@ -395,7 +391,7 @@ impl<L: Language> CompilerSources<L> {
395391 ) {
396392 cache. remove_dirty_sources ( ) ;
397393 for versioned_sources in self . sources . values_mut ( ) {
398- for ( version, sources) in versioned_sources {
394+ for ( version, sources, _ ) in versioned_sources {
399395 trace ! ( "Filtering {} sources for {}" , sources. len( ) , version) ;
400396 cache. filter ( sources, version) ;
401397 trace ! (
@@ -408,7 +404,7 @@ impl<L: Language> CompilerSources<L> {
408404 }
409405
410406 /// Compiles all the files with `Solc`
411- fn compile < C : Compiler < Language = L > , T : ArtifactOutput > (
407+ fn compile < C : Compiler < Language = L , Settings = S > , T : ArtifactOutput > (
412408 self ,
413409 cache : & mut ArtifactsCache < ' _ , T , C > ,
414410 ) -> Result < AggregatedCompilerOutput < C > > {
@@ -425,7 +421,7 @@ impl<L: Language> CompilerSources<L> {
425421
426422 let mut jobs = Vec :: new ( ) ;
427423 for ( language, versioned_sources) in self . sources {
428- for ( version, sources) in versioned_sources {
424+ for ( version, sources, mut opt_settings ) in versioned_sources {
429425 if sources. is_empty ( ) {
430426 // nothing to compile
431427 trace ! ( "skip {} for empty sources set" , version) ;
@@ -434,7 +430,6 @@ impl<L: Language> CompilerSources<L> {
434430
435431 // depending on the composition of the filtered sources, the output selection can be
436432 // optimized
437- let mut opt_settings = project. settings . clone ( ) ;
438433 let actually_dirty =
439434 sparse_output. sparse_sources ( & sources, & mut opt_settings, graph) ;
440435
@@ -677,7 +672,7 @@ mod tests {
677672 // single solc
678673 assert_eq ! ( len, 1 ) ;
679674
680- let filtered = & sources. values ( ) . next ( ) . unwrap ( ) . values ( ) . next ( ) . unwrap ( ) ;
675+ let filtered = & sources. values ( ) . next ( ) . unwrap ( ) [ 0 ] . 1 ;
681676
682677 // 3 contracts total
683678 assert_eq ! ( filtered. 0 . len( ) , 3 ) ;
0 commit comments