From c7bee1a11864ae97602697f41c87e95cf4b10fc4 Mon Sep 17 00:00:00 2001 From: FroyaTheHen Date: Wed, 18 Dec 2024 09:44:08 +0100 Subject: [PATCH] feat: allow declaring executable target as [executable] commit-id:8719351c --- scarb/.DS_Store | Bin 0 -> 6148 bytes scarb/src/.DS_Store | Bin 0 -> 6148 bytes scarb/src/bin/.DS_Store | Bin 0 -> 6148 bytes scarb/src/core/manifest/toml_manifest.rs | 13 ++++++++ .../core/publishing/manifest_normalization.rs | 1 + scarb/tests/build_targets.rs | 29 ++++++++++++++++++ 6 files changed, 43 insertions(+) create mode 100644 scarb/.DS_Store create mode 100644 scarb/src/.DS_Store create mode 100644 scarb/src/bin/.DS_Store diff --git a/scarb/.DS_Store b/scarb/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..cbd1ff7608bf56cac11854f706dfde0bdae5ed41 GIT binary patch literal 6148 zcmeHK%}T>S5Z<-brW7Fu1-&hJE!b+Q6fYsx7cim+m718M!I&*cY7V84yS|Vw;`2DO zy8(+ii`W_1{pNQ!`$6`HF~;3_*k{aUj9JhSIVv@R?%L3XNk-&2Mm7s#8G!W>%uMXB z1AcphWh`Y6LGk_j<0#8}y-&W;Xl`z`td`ZW?z|^ic)6d?GuKaV(7Kc|4l3ObuA*r% zv3Jg7lKW9IO;te@P9f#?I!Z!WxN@F^nX2`4z-n9ViM_vAoD7Ct(eICrmtCX7Epf2U+ ziNSR__=U-H43-*oIpb<(7{|<9Jzlt)9sEM2Gwx`lo){noRvBn$)5i1v9DbSFNB(LF zS;PP_@Xr|F&9OIjVNvF6{joeeYX!7>XegLhq5=Z?$|V2{+(-6QP{#%8kmndIHR34f RSLJ|o5m1CsM-2P|17CQjNx}dC literal 0 HcmV?d00001 diff --git a/scarb/src/.DS_Store b/scarb/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a3585876b6842aef6ec2eca2c673c194487ea3b6 GIT binary patch literal 6148 zcmeH~O=`nH427SXECStl+2w30pQvfVyQljO&;ssLc!1UOG})p;=82 zR;?Ceh}WZ?+UmMqI#RP8R>OzYoz15hnq@nzF`-!xQ4j$USPS5Z>*N-BN@e6!f;>wP35IQoMv%U%-eSRBB?224l7~sX3HF?)pN$h|lB9 z?gm;c9!2a7?0&QJvzz%K`@0GY(M~^di38fpRU|77KU>WvQfBZyHA`egtcgQA83F1H=F^ zKn!do1NJx&jg73HiY5k#fu9(_{Xs%QbS&lu_0|C$UZ2rlK|}!^-x7$@qGK^P2p$k_ zQUOgWw@(ai(!nlmoMSOJXwn(iE5kf?<>K+e_3B`kI-GIGAoaumF|f)&*$kU_{-47y zv-Xj{nnELDfEf5^4Diap8@N!EJzKw(hi9#Xb`K2&<8o9$Kwr58zySA=J?%7pi8{nN X7IT9*3)*!$AYBABA=D8Azres3#kxxT literal 0 HcmV?d00001 diff --git a/scarb/src/core/manifest/toml_manifest.rs b/scarb/src/core/manifest/toml_manifest.rs index 486df81d8..83d4d38a3 100644 --- a/scarb/src/core/manifest/toml_manifest.rs +++ b/scarb/src/core/manifest/toml_manifest.rs @@ -46,6 +46,7 @@ pub struct TomlManifest { pub dependencies: Option>, pub dev_dependencies: Option>, pub lib: Option>, + pub executable: Option>, pub cairo_plugin: Option>, pub test: Option>>, pub target: Option>>>, @@ -295,6 +296,10 @@ pub struct TomlLibTargetParams { pub sierra_text: Option, } +#[derive(Debug, Default, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +pub struct TomlExecutableTargetParams {} + #[derive(Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct TomlCairoPluginTargetParams { @@ -634,6 +639,14 @@ impl TomlManifest { None, )?); + targets.extend(Self::collect_target( + TargetKind::EXECUTABLE, + self.executable.as_ref(), + &package_name, + root, + None, + )?); + for (kind, ext_toml) in self .target .iter() diff --git a/scarb/src/core/publishing/manifest_normalization.rs b/scarb/src/core/publishing/manifest_normalization.rs index 20e165398..70b4e16f0 100644 --- a/scarb/src/core/publishing/manifest_normalization.rs +++ b/scarb/src/core/publishing/manifest_normalization.rs @@ -38,6 +38,7 @@ pub fn prepare_manifest_for_publish(pkg: &Package) -> Result { dependencies, dev_dependencies: None, lib: None, + executable: None, cairo_plugin, test: None, target: None, diff --git a/scarb/tests/build_targets.rs b/scarb/tests/build_targets.rs index 279f28ada..5370bf7c3 100644 --- a/scarb/tests/build_targets.rs +++ b/scarb/tests/build_targets.rs @@ -1119,3 +1119,32 @@ fn test_executable_compiler_creates_output_files() { t.child("target/dev/executable_test.executable.json") .assert(predicates::path::exists()); } + +#[test] +fn compile_executable_target_can_use_short_declaration() { + let t = TempDir::new().unwrap(); + ProjectBuilder::start() + .name("executable_test") + .dep_cairo_test() + .dep_starknet() + .dep_cairo_execute() + .manifest_extra(indoc! {r#" + [executable] + "#}) + .lib_cairo(indoc! {r#" + #[executable] + fn main() -> felt252 { + 42 + } + "#}) + .build(&t); + + Scarb::quick_snapbox() + .arg("build") + .current_dir(&t) + .assert() + .success(); + + t.child("target/dev/executable_test.executable.json") + .assert(predicates::path::exists()); +}