-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Feature] [Package System] Add option to override standard library version #13318
base: main
Are you sure you want to change the base?
Conversation
⏱️ 2h 16m total CI duration on this PR
|
} else { | ||
bail!( | ||
"Invalid verion for standard libraries to override: {}", | ||
version_str |
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.
Could we say here the expected strings? See also my remark about ValueEnum
derive below.
} | ||
|
||
/// Represents a standard library version. | ||
pub enum StdVersion { |
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.
You could use #[derive(ValueEnum)]
here and then use that type directly in the clap fields instead of strings. I believe this will give an error message about what are the allowed variants.
Some(version) | ||
} else { | ||
bail!( | ||
"Invalid verion for standard libraries to override: {}", |
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.
s/verion/version
/// Returns the dependency for the standard library with the given version. | ||
pub fn dependency(&self, version: &StdVersion) -> Dependency { | ||
let local = | ||
PathBuf::from(MOVE_HOME.clone()).join(format!("{}_{}", self.as_str(), version.rev())); |
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.
Is this the same location which is chosen if someone explicitly uses the github dep in their Move.toml? I'm worried that we are potentially double caching the package here. The local path should be the same to avoid this.
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.
(1/2)
Sorry for the delay. Looks great to me so far!
Let me play with the code locally and see if it handles certain details correctly (e.g. the local path).
@@ -109,6 +109,10 @@ pub struct BuildConfig { | |||
#[clap(name = "test-mode", long = "test", global = true)] | |||
pub test_mode: bool, | |||
|
|||
/// Whether to override the standard library with the given version. | |||
#[clap(long = "override-std", global = true, value_parser)] | |||
pub override_std: Option<String>, |
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 as @wrwg mentioned, you could change this to pub override_std: Option<StdVersion>
if you implement the required traits for StdVersion
.
subdir = "aptos-move/framework/aptos-framework" | ||
|
||
[dependencies.B] | ||
local = "./deps_only" |
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: the directory name "deps_only" seems a bit confusing to me. Wonder if it would be better to rename this to "intermediate_dep".
subst: None, | ||
version: None, | ||
digest: None, | ||
git_info: Some(GitInfo { |
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.
@wrwg Just to double check: what is the local caching behavior of the git dependencies? Do we update every time the build command is run, or it has to be triggered by some other events?
Specifically I want to understand what's going to happen when we update the branches in the repo.
Description
Closes #13326
Implements a
--override-std mainnet/testnet/dev
option for overriding the version of standard library (aptos framework, aptos stdlib, move stdlib) as dependencies. For example, if--override-std mainnet
is specified, a dependencywill effectively be overridden by the one from the well-know location for stdlib with the specified version
Type of Change
Which Components or Systems Does This Change Impact?
How Has This Been Tested?
Two new tests
third_pary/move/tools/move-package/tests/test_sources/compilation/std-lib-{conflicts, override}
one showing the problem, one showing the solution.