-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow multiple languages for compilers #128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes a lot of sense and simplifies things a lot.
I only have doc nits
src/compilers/solc/mod.rs
Outdated
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub enum SolcLanguages { | ||
Solidity, | ||
Yul, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs some docs
src/compilers/solc/mod.rs
Outdated
|
||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub enum SolcLanguages { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
pub enum SolcLanguages { | |
pub enum SolcLanguage { |
src/compilers/mod.rs
Outdated
@@ -136,45 +206,31 @@ impl<E> Default for CompilerOutput<E> { | |||
} | |||
} | |||
|
|||
pub trait Language: Hash + Eq + Clone + Debug { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this also be Display and I think this should be 'static
src/compilers/solc/mod.rs
Outdated
self | ||
} | ||
#[derive(Debug, Clone, Serialize)] | ||
pub struct SolcVerionedInput { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
src/compilers/solc/mod.rs
Outdated
|
||
type Input = SolcInput; | ||
impl Compiler for SolcRegistry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, it's a bit weird that we implement compiler on registry, maybe we can rename this? so it's more obvious that this is compiler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, not sure how to name it
perhaps MultiSolc
or just SolcCompiler
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SolcCompiler fits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solc compiler = Sol Compiler Compiler 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, I only have pedantic doc nits hehe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gg
let mut solc = match self { | ||
Self::Specific(solc) => solc.clone(), | ||
|
||
#[cfg(feature = "svm-solc")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can consider removing this feature
ref foundry-rs/foundry#8062 ref https://t.me/foundry_support/54144 introduced in #128
This changes
Compiler
trait to also have associatedLanguage
type which is supposed to be an enum with languages supported by the compiler. AlsoCompilerVersionManager
trait is removed and compiler now should contain full logic for version resolution.For version management we have to keep track of all different languages and versions to compile them with, thus I've rewritten some of the graph logic to use
HashMap<C::Language, HashMap<Version, Sources>>
during compilation.Now, instead of representing a binary wrapper,
Compiler
is more like binary manager which resolves and installs binaries dynamically depending on requestedlanguage
andversion
.It's mostly ready, I just need to add logic for compilation with locked compiler version.