diff --git a/scarb/src/core/manifest/toml_manifest.rs b/scarb/src/core/manifest/toml_manifest.rs index db65e3c53..b180384d8 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 { @@ -640,6 +645,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 33562c290..05bb82914 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()); +}