Skip to content

Commit

Permalink
Revert "[Feature] [Package System] Add option to override standard li…
Browse files Browse the repository at this point in the history
…brary version (#13318)"

This reverts commit bbce0f1.
  • Loading branch information
brmataptos committed Jun 30, 2024
1 parent 31e2546 commit 7e265ac
Show file tree
Hide file tree
Showing 46 changed files with 19 additions and 311 deletions.
1 change: 0 additions & 1 deletion aptos-move/framework/src/aptos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ impl ReleaseTarget {
with_source_maps: false,
with_error_map: true,
named_addresses: Default::default(),
override_std: None,
install_dir: None,
with_docs: true,
docgen_options: Some(DocgenOptions {
Expand Down
11 changes: 1 addition & 10 deletions aptos-move/framework/src/built_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ use move_model::{
};
use move_package::{
compilation::{compiled_package::CompiledPackage, package_layout::CompiledPackageLayout},
source_package::{
manifest_parser::{parse_move_manifest_string, parse_source_manifest},
std_lib::StdVersion,
},
source_package::manifest_parser::{parse_move_manifest_string, parse_source_manifest},
BuildConfig, CompilerConfig, ModelConfig,
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -76,9 +73,6 @@ pub struct BuildOptions {
pub install_dir: Option<PathBuf>,
#[clap(skip)] // TODO: have a parser for this; there is one in the CLI buts its downstream
pub named_addresses: BTreeMap<String, AccountAddress>,
/// Whether to override the standard library with the given version.
#[clap(long, value_parser)]
pub override_std: Option<StdVersion>,
#[clap(skip)]
pub docgen_options: Option<DocgenOptions>,
#[clap(long)]
Expand Down Expand Up @@ -110,7 +104,6 @@ impl Default for BuildOptions {
with_docs: false,
install_dir: None,
named_addresses: Default::default(),
override_std: None,
docgen_options: None,
// This is false by default, because it could accidentally pull new dependencies
// while in a test (and cause some havoc)
Expand Down Expand Up @@ -154,7 +147,6 @@ pub fn build_model(
full_model_generation: false,
install_dir: None,
test_mode: false,
override_std: None,
force_recompilation: false,
fetch_deps_only: false,
skip_fetch_latest_git_deps: true,
Expand Down Expand Up @@ -198,7 +190,6 @@ impl BuiltPackage {
full_model_generation: options.check_test_code,
install_dir: options.install_dir.clone(),
test_mode: false,
override_std: options.override_std.clone(),
force_recompilation: false,
fetch_deps_only: false,
skip_fetch_latest_git_deps: options.skip_fetch_latest_git_deps,
Expand Down
6 changes: 0 additions & 6 deletions crates/aptos/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ use move_core_types::{
account_address::AccountAddress, language_storage::TypeTag, vm_status::VMStatus,
};
use move_model::metadata::{CompilerVersion, LanguageVersion};
use move_package::source_package::std_lib::StdVersion;
use serde::{Deserialize, Serialize};
#[cfg(unix)]
use std::os::unix::fs::OpenOptionsExt;
Expand Down Expand Up @@ -1049,10 +1048,6 @@ pub struct MovePackageDir {
#[clap(long, value_parser = crate::common::utils::parse_map::<String, AccountAddressWrapper>, default_value = "")]
pub(crate) named_addresses: BTreeMap<String, AccountAddressWrapper>,

/// Override the standard library version by mainnet/testnet/devnet
#[clap(long, value_parser)]
pub override_std: Option<StdVersion>,

/// Skip pulling the latest git dependencies
///
/// If you don't have a network connection, the compiler may fail due
Expand Down Expand Up @@ -1093,7 +1088,6 @@ impl MovePackageDir {
package_dir: Some(package_dir),
output_dir: None,
named_addresses: Default::default(),
override_std: None,
skip_fetch_latest_git_deps: true,
bytecode_version: None,
compiler_version: None,
Expand Down
1 change: 0 additions & 1 deletion crates/aptos/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,6 @@ impl CliCommand<()> for GenerateUpgradeProposal {
move_options.dev,
move_options.skip_fetch_latest_git_deps,
move_options.named_addresses(),
move_options.override_std,
move_options.bytecode_version,
move_options.compiler_version,
move_options.language_version,
Expand Down
17 changes: 1 addition & 16 deletions crates/aptos/src/move_tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ use move_cli::{self, base::test::UnitTestResult};
use move_command_line_common::env::MOVE_HOME;
use move_core_types::{identifier::Identifier, language_storage::ModuleId, u256::U256};
use move_model::metadata::{CompilerVersion, LanguageVersion};
use move_package::{
source_package::{layout::SourcePackageLayout, std_lib::StdVersion},
BuildConfig, CompilerConfig,
};
use move_package::{source_package::layout::SourcePackageLayout, BuildConfig, CompilerConfig};
use move_unit_test::UnitTestingConfig;
pub use package_hooks::*;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -334,7 +331,6 @@ impl CliCommand<Vec<String>> for CompilePackage {
self.move_options.dev,
self.move_options.skip_fetch_latest_git_deps,
self.move_options.named_addresses(),
self.move_options.override_std.clone(),
self.move_options.bytecode_version,
self.move_options.compiler_version,
self.move_options.language_version,
Expand Down Expand Up @@ -398,7 +394,6 @@ impl CompileScript {
self.move_options.dev,
self.move_options.skip_fetch_latest_git_deps,
self.move_options.named_addresses(),
self.move_options.override_std.clone(),
self.move_options.bytecode_version,
self.move_options.compiler_version,
self.move_options.language_version,
Expand Down Expand Up @@ -616,7 +611,6 @@ impl CliCommand<&'static str> for DocumentPackage {
with_docs: true,
install_dir: None,
named_addresses: move_options.named_addresses(),
override_std: move_options.override_std.clone(),
docgen_options: Some(docgen_options),
skip_fetch_latest_git_deps: move_options.skip_fetch_latest_git_deps,
bytecode_version: move_options.bytecode_version,
Expand Down Expand Up @@ -688,7 +682,6 @@ impl TryInto<PackagePublicationData> for &PublishPackage {
self.move_options.dev,
self.move_options.skip_fetch_latest_git_deps,
self.move_options.named_addresses(),
self.move_options.override_std.clone(),
self.move_options.bytecode_version,
self.move_options.compiler_version,
self.move_options.language_version,
Expand Down Expand Up @@ -760,7 +753,6 @@ impl IncludedArtifacts {
dev: bool,
skip_fetch_latest_git_deps: bool,
named_addresses: BTreeMap<String, AccountAddress>,
override_std: Option<StdVersion>,
bytecode_version: Option<u32>,
compiler_version: Option<CompilerVersion>,
language_version: Option<LanguageVersion>,
Expand All @@ -777,7 +769,6 @@ impl IncludedArtifacts {
// Always enable error map bytecode injection
with_error_map: true,
named_addresses,
override_std,
skip_fetch_latest_git_deps,
bytecode_version,
compiler_version,
Expand All @@ -794,7 +785,6 @@ impl IncludedArtifacts {
with_source_maps: false,
with_error_map: true,
named_addresses,
override_std,
skip_fetch_latest_git_deps,
bytecode_version,
compiler_version,
Expand All @@ -811,7 +801,6 @@ impl IncludedArtifacts {
with_source_maps: true,
with_error_map: true,
named_addresses,
override_std,
skip_fetch_latest_git_deps,
bytecode_version,
compiler_version,
Expand Down Expand Up @@ -934,7 +923,6 @@ impl CliCommand<TransactionSummary> for CreateObjectAndPublishPackage {
self.move_options.dev,
self.move_options.skip_fetch_latest_git_deps,
self.move_options.named_addresses(),
self.move_options.override_std.clone(),
self.move_options.bytecode_version,
self.move_options.compiler_version,
self.move_options.language_version,
Expand Down Expand Up @@ -1012,7 +1000,6 @@ impl CliCommand<TransactionSummary> for UpgradeObjectPackage {
self.move_options.dev,
self.move_options.skip_fetch_latest_git_deps,
self.move_options.named_addresses(),
self.move_options.override_std.clone(),
self.move_options.bytecode_version,
self.move_options.compiler_version,
self.move_options.language_version,
Expand Down Expand Up @@ -1138,7 +1125,6 @@ impl CliCommand<TransactionSummary> for CreateResourceAccountAndPublishPackage {
move_options.dev,
move_options.skip_fetch_latest_git_deps,
move_options.named_addresses(),
move_options.override_std,
move_options.bytecode_version,
move_options.compiler_version,
move_options.language_version,
Expand Down Expand Up @@ -1291,7 +1277,6 @@ impl CliCommand<&'static str> for VerifyPackage {
self.move_options.dev,
self.move_options.skip_fetch_latest_git_deps,
self.move_options.named_addresses(),
self.move_options.override_std.clone(),
self.move_options.bytecode_version,
self.move_options.compiler_version,
self.move_options.language_version,
Expand Down
1 change: 0 additions & 1 deletion crates/aptos/src/move_tool/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ impl CliCommand<Vec<EntryABI>> for ShowAbi {
self.move_options.dev,
self.move_options.skip_fetch_latest_git_deps,
self.move_options.named_addresses(),
self.move_options.override_std.clone(),
self.move_options.bytecode_version,
self.move_options.compiler_version,
self.move_options.language_version,
Expand Down
1 change: 0 additions & 1 deletion crates/aptos/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,6 @@ impl CliTestFramework {
package_dir: Some(self.move_dir()),
output_dir: None,
named_addresses: Self::named_addresses(account_strs),
override_std: None,
skip_fetch_latest_git_deps: true,
bytecode_version: None,
compiler_version: None,
Expand Down
6 changes: 1 addition & 5 deletions third_party/move/tools/move-package/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use move_model::{
model,
};
use serde::{Deserialize, Serialize};
use source_package::{layout::SourcePackageLayout, std_lib::StdVersion};
use source_package::layout::SourcePackageLayout;
use std::{
collections::{BTreeMap, BTreeSet},
fmt,
Expand Down Expand Up @@ -109,10 +109,6 @@ 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<StdVersion>,

/// Generate documentation for packages
#[clap(name = "generate-docs", long = "doc", global = true)]
pub generate_docs: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{
Dependencies, Dependency, FileName, NamedAddress, PackageDigest, PackageName,
SourceManifest, SubstOrRename,
},
std_lib::{StdLib, StdVersion},
},
BuildConfig,
};
Expand Down Expand Up @@ -108,22 +107,14 @@ impl ResolvingGraph {
}
let mut resolution_graph = Self {
root_package_path: root_package_path.clone(),
build_options: build_options.clone(),
build_options,
root_package: root_package.clone(),
graph: DiGraphMap::new(),
package_table: BTreeMap::new(),
};

let override_std = &build_options.override_std;

resolution_graph
.build_resolution_graph(
root_package.clone(),
root_package_path,
true,
override_std,
writer,
)
.build_resolution_graph(root_package.clone(), root_package_path, true, writer)
.with_context(|| {
format!(
"Unable to resolve packages for package '{}'",
Expand Down Expand Up @@ -208,7 +199,6 @@ impl ResolvingGraph {
package: SourceManifest,
package_path: PathBuf,
is_root_package: bool,
override_std: &Option<StdVersion>,
writer: &mut W,
) -> Result<()> {
let package_name = package.package.name;
Expand Down Expand Up @@ -247,17 +237,12 @@ impl ResolvingGraph {
BTreeMap::new()
};

for (dep_name, mut dep) in package
for (dep_name, dep) in package
.dependencies
.clone()
.into_iter()
.chain(additional_deps.into_iter())
{
if let Some(std_version) = &override_std {
if let Some(std_lib) = StdLib::from_package_name(dep_name) {
dep = std_lib.dependency(std_version);
}
}
let dep_node_id = self.get_or_add_node(dep_name).with_context(|| {
format!(
"Cycle between packages {} and {} found",
Expand All @@ -267,7 +252,7 @@ impl ResolvingGraph {
self.graph.add_edge(package_node_id, dep_node_id, ());

let (dep_renaming, dep_resolution_table) = self
.process_dependency(dep_name, dep, package_path.clone(), override_std, writer)
.process_dependency(dep_name, dep, package_path.clone(), writer)
.with_context(|| {
format!(
"While resolving dependency '{}' in package '{}'",
Expand Down Expand Up @@ -408,7 +393,6 @@ impl ResolvingGraph {
dep_name_in_pkg: PackageName,
dep: Dependency,
root_path: PathBuf,
override_std: &Option<StdVersion>,
writer: &mut W,
) -> Result<(Renaming, ResolvingTable)> {
Self::download_and_update_if_remote(
Expand All @@ -420,14 +404,10 @@ impl ResolvingGraph {
let (dep_package, dep_package_dir) =
Self::parse_package_manifest(&dep, &dep_name_in_pkg, root_path)
.with_context(|| format!("While processing dependency '{}'", dep_name_in_pkg))?;
self.build_resolution_graph(
dep_package.clone(),
dep_package_dir,
false,
override_std,
writer,
)
.with_context(|| format!("Unable to resolve package dependency '{}'", dep_name_in_pkg))?;
self.build_resolution_graph(dep_package.clone(), dep_package_dir, false, writer)
.with_context(|| {
format!("Unable to resolve package dependency '{}'", dep_name_in_pkg)
})?;

if dep_name_in_pkg != dep_package.package.name {
bail!("Name of dependency declared in package '{}' does not match dependency's package name '{}'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ fn parse_dependency(dep_name: &str, tval: TV) -> Result<PM::Dependency> {
})
},
(None, Some(git), None) => {
let move_home = MOVE_HOME.clone();
let rev_name = match table.remove("rev") {
None => bail!("Git revision not supplied for dependency"),
Some(r) => Symbol::from(
Expand All @@ -366,7 +367,11 @@ fn parse_dependency(dep_name: &str, tval: TV) -> Result<PM::Dependency> {
let git_url = git
.as_str()
.ok_or_else(|| anyhow::anyhow!("Git URL not a string"))?;
let local_path = git_repo_cache_path(git_url, rev_name.as_str());
let local_path = PathBuf::from(move_home).join(format!(
"{}_{}",
url_to_file_name(git_url),
rev_name.replace('/', "__")
));
let subdir = PathBuf::from(match table.remove("subdir") {
None => "".to_string(),
Some(path) => path
Expand Down Expand Up @@ -566,13 +571,3 @@ fn check_for_required_field_names(

Ok(())
}

/// Gets the local path to download the package from a git repo
pub fn git_repo_cache_path(git_url: &str, rev_name: &str) -> PathBuf {
let move_home = MOVE_HOME.clone();
PathBuf::from(move_home).join(format!(
"{}_{}",
url_to_file_name(git_url),
rev_name.replace('/', "__")
))
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
pub mod layout;
pub mod manifest_parser;
pub mod parsed_manifest;
pub mod std_lib;
Loading

0 comments on commit 7e265ac

Please sign in to comment.