-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
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.
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.
done
} | ||
|
||
/// 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.
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.
done
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
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.
no longer needed
/// 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.
done
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
.
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.
done
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".
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.
The test runner checks for directories containing "deps_only", and doesn't build the packages under that directory.
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.
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.
It depends on whether you set the skip_fetch_latest_git_deps
command line argument. If we set it and the local cache exists, we will update the local cache. By default, we don't update the cache and only download if a local copy does not exist. This is implemented in download_and_update_if_remote
in resolution_graph.rs
.
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 its a bit different, skip will actually skip checks, and otherwise we do update. The code is quite convoluted here. https://github.com/aptos-labs/aptos-core/blob/main/third_party/move/tools/move-package/src/resolution/resolution_graph.rs#L558
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.
Tried the tool. Seemed to work well. Good job on the work!
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
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.