Skip to content

Commit 654c8f0

Browse files
HugooDaniPopes
andauthored
feat(forge build): add --use-literal-content CLI flag (#10143)
Co-authored-by: DaniPopes <[email protected]>
1 parent 44c4416 commit 654c8f0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

crates/cli/src/opts/build/core.rs

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ pub struct BuildOpts {
7878
#[serde(skip)]
7979
pub via_ir: bool,
8080

81+
/// Changes compilation to only use literal content and not URLs.
82+
#[arg(long, help_heading = "Compiler options")]
83+
#[serde(skip)]
84+
pub use_literal_content: bool,
85+
8186
/// Do not append any metadata to the bytecode.
8287
///
8388
/// This is equivalent to setting `bytecode_hash` to `none` and `cbor_metadata` to `false`.
@@ -222,6 +227,10 @@ impl Provider for BuildOpts {
222227
dict.insert("via_ir".to_string(), true.into());
223228
}
224229

230+
if self.use_literal_content {
231+
dict.insert("use_literal_content".to_string(), true.into());
232+
}
233+
225234
if self.no_metadata {
226235
dict.insert("bytecode_hash".to_string(), "none".into());
227236
dict.insert("cbor_metadata".to_string(), false.into());

crates/forge/tests/cli/config.rs

+12
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,18 @@ forgetest!(can_set_optimizer_runs, |prj, cmd| {
487487
assert_eq!(config.optimizer_runs, Some(300));
488488
});
489489

490+
// test that use_literal_content works
491+
forgetest!(can_set_use_literal_content, |prj, cmd| {
492+
// explicitly set use_literal_content
493+
prj.update_config(|config| config.use_literal_content = false);
494+
495+
let config = cmd.config();
496+
assert_eq!(config.use_literal_content, false);
497+
498+
let config = prj.config_from_output(["--use-literal-content"]);
499+
assert_eq!(config.use_literal_content, true);
500+
});
501+
490502
// <https://github.com/foundry-rs/foundry/issues/9665>
491503
forgetest!(enable_optimizer_when_runs_set, |prj, cmd| {
492504
// explicitly set optimizer runs

0 commit comments

Comments
 (0)