Skip to content

Commit

Permalink
Merge 1b0d762 into 8d50370
Browse files Browse the repository at this point in the history
  • Loading branch information
esdrubal authored May 15, 2024
2 parents 8d50370 + 1b0d762 commit 581883d
Show file tree
Hide file tree
Showing 45 changed files with 433 additions and 212 deletions.
8 changes: 7 additions & 1 deletion forc-pkg/src/manifest/build_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use sway_core::{OptLevel, PrintAsm};
#[serde(rename_all = "kebab-case")]
pub struct ExperimentalFlags {
pub new_encoding: bool,
pub abi_hash_ids: bool,
}

/// Parameters to pass through to the `sway_core::BuildConfig` during compilation.
Expand Down Expand Up @@ -67,6 +68,7 @@ impl BuildProfile {
optimization_level: OptLevel::Opt0,
experimental: ExperimentalFlags {
new_encoding: false,
abi_hash_ids: false,
},
}
}
Expand All @@ -90,6 +92,7 @@ impl BuildProfile {
optimization_level: OptLevel::Opt1,
experimental: ExperimentalFlags {
new_encoding: false,
abi_hash_ids: false,
},
}
}
Expand Down Expand Up @@ -141,7 +144,10 @@ mod tests {
error_on_warnings: true,
reverse_results: true,
optimization_level: OptLevel::Opt0,
experimental: ExperimentalFlags { new_encoding: true },
experimental: ExperimentalFlags {
new_encoding: true,
abi_hash_ids: true,
},
};
let profile = build_profiles.get("release").expect("release profile");
assert_eq!(*profile, expected);
Expand Down
4 changes: 4 additions & 0 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ pub fn sway_build_config(
.with_optimization_level(build_profile.optimization_level)
.with_experimental(sway_core::ExperimentalFlags {
new_encoding: build_profile.experimental.new_encoding,
abi_hash_ids: build_profile.experimental.abi_hash_ids,
});
Ok(build_config)
}
Expand Down Expand Up @@ -1828,6 +1829,7 @@ pub fn compile(
&mut AbiContext {
program: typed_program,
abi_with_callpaths: profile.json_abi_with_callpaths,
abi_with_hash_ids: profile.experimental.abi_hash_ids,
},
engines,
&mut types,
Expand Down Expand Up @@ -2083,6 +2085,7 @@ fn build_profile_from_opts(
profile.error_on_warnings |= error_on_warnings;
profile.experimental = ExperimentalFlags {
new_encoding: experimental.new_encoding,
abi_hash_ids: experimental.abi_hash_ids,
};

Ok(profile)
Expand Down Expand Up @@ -2161,6 +2164,7 @@ pub fn build_with_options(build_options: &BuildOpts) -> Result<Built> {
&outputs,
sway_core::ExperimentalFlags {
new_encoding: experimental.new_encoding,
abi_hash_ids: experimental.abi_hash_ids,
},
)?;
let output_dir = pkg.output_directory.as_ref().map(PathBuf::from);
Expand Down
2 changes: 1 addition & 1 deletion forc-pkg/tests/sections/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ json-abi-with-callpaths = true
error-on-warnings = true
reverse-results = true
optimization-level = 0
experimental = { new-encoding = true }
experimental = { new-encoding = true, abi-hash-ids = true }

[build-profile.custom]
print-asm = { virtual = false, allocated = false, final = true }
4 changes: 4 additions & 0 deletions forc-plugins/forc-client/src/cmd/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,

/// Enables abi ids using the first 8 bytes of sha256 of the type str.
#[clap(long)]
pub abi_hash_ids: bool,
}
4 changes: 4 additions & 0 deletions forc-plugins/forc-client/src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,

/// Enables abi ids using the first 8 bytes of sha256 of the type str.
#[clap(long)]
pub abi_hash_ids: bool,
}
1 change: 1 addition & 0 deletions forc-plugins/forc-client/src/op/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts {
member_filter: pkg::MemberFilter::only_contracts(),
experimental: ExperimentalFlags {
new_encoding: !cmd.no_encoding_v1,
abi_hash_ids: cmd.abi_hash_ids,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions forc-plugins/forc-client/src/op/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ fn build_opts_from_cmd(cmd: &cmd::Run) -> pkg::BuildOpts {
member_filter: pkg::MemberFilter::only_scripts(),
experimental: ExperimentalFlags {
new_encoding: !cmd.no_encoding_v1,
abi_hash_ids: cmd.abi_hash_ids,
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl DapServer {

let experimental = sway_core::ExperimentalFlags {
new_encoding: false,
abi_hash_ids: false,
};

// 1. Build the packages
Expand Down
4 changes: 4 additions & 0 deletions forc-plugins/forc-doc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,

/// Enables abi ids using the first 8 bytes of sha256 of the type str.
#[clap(long)]
pub abi_hash_ids: bool,
}
1 change: 1 addition & 0 deletions forc-plugins/forc-doc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn main() -> Result<()> {
&get_doc_dir,
sway_core::ExperimentalFlags {
new_encoding: !build_instructions.no_encoding_v1,
abi_hash_ids: build_instructions.abi_hash_ids,
},
)?;

Expand Down
2 changes: 2 additions & 0 deletions forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn test_impl_traits_default() {
&get_doc_dir,
ExperimentalFlags {
new_encoding: false,
abi_hash_ids: false,
},
)
.unwrap();
Expand Down Expand Up @@ -114,6 +115,7 @@ fn test_impl_traits_no_deps() {
&get_doc_dir,
ExperimentalFlags {
new_encoding: false,
abi_hash_ids: false,
},
)
.unwrap();
Expand Down
4 changes: 4 additions & 0 deletions forc/src/cli/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,

/// Enables abi ids using the first 8 bytes of sha256 of the type str.
#[clap(long)]
pub abi_hash_ids: bool,
}

pub(crate) fn exec(command: Command) -> ForcResult<()> {
Expand Down
4 changes: 4 additions & 0 deletions forc/src/cli/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,

/// Enables abi ids using the first 8 bytes of sha256 of the type str.
#[clap(long)]
pub abi_hash_ids: bool,
}

pub(crate) fn exec(command: Command) -> ForcResult<()> {
Expand Down
4 changes: 4 additions & 0 deletions forc/src/cli/commands/contract_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,

/// Enables abi ids using the first 8 bytes of sha256 of the type str.
#[clap(long)]
pub abi_hash_ids: bool,
}

pub(crate) fn exec(cmd: Command) -> ForcResult<()> {
Expand Down
4 changes: 4 additions & 0 deletions forc/src/cli/commands/predicate_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub struct Command {
/// Disable the "new encoding" feature
#[clap(long)]
pub no_encoding_v1: bool,

/// Enables abi ids using the first 8 bytes of sha256 of the type str.
#[clap(long)]
pub abi_hash_ids: bool,
}

pub(crate) fn exec(cmd: Command) -> ForcResult<()> {
Expand Down
1 change: 1 addition & 0 deletions forc/src/cli/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ fn opts_from_cmd(cmd: Command) -> forc_test::TestOpts {
build_target: cmd.build.build_target,
experimental: ExperimentalFlags {
new_encoding: !cmd.no_encoding_v1,
abi_hash_ids: true,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions forc/src/ops/forc_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn opts_from_cmd(cmd: BuildCommand) -> pkg::BuildOpts {
member_filter: MemberFilter::default(),
experimental: ExperimentalFlags {
new_encoding: !cmd.no_encoding_v1,
abi_hash_ids: cmd.abi_hash_ids,
},
}
}
2 changes: 2 additions & 0 deletions forc/src/ops/forc_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn check(command: CheckCommand, engines: &Engines) -> Result<(Option<ty::TyP
disable_tests,
ipfs_node,
no_encoding_v1,
abi_hash_ids,
} = command;

let this_dir = if let Some(ref path) = path {
Expand Down Expand Up @@ -46,6 +47,7 @@ pub fn check(command: CheckCommand, engines: &Engines) -> Result<(Option<ty::TyP
None,
ExperimentalFlags {
new_encoding: !no_encoding_v1,
abi_hash_ids,
},
)?;
let (res, handler) = v
Expand Down
1 change: 1 addition & 0 deletions forc/src/ops/forc_contract_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ fn build_opts_from_cmd(cmd: &ContractIdCommand) -> pkg::BuildOpts {
member_filter: pkg::MemberFilter::only_contracts(),
experimental: ExperimentalFlags {
new_encoding: !cmd.no_encoding_v1,
abi_hash_ids: cmd.abi_hash_ids,
},
}
}
1 change: 1 addition & 0 deletions forc/src/ops/forc_predicate_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fn build_opts_from_cmd(cmd: PredicateRootCommand) -> pkg::BuildOpts {
member_filter: pkg::MemberFilter::only_predicates(),
experimental: ExperimentalFlags {
new_encoding: !cmd.no_encoding_v1,
abi_hash_ids: cmd.abi_hash_ids,
},
}
}
Loading

0 comments on commit 581883d

Please sign in to comment.