Skip to content

Commit 0b92122

Browse files
committed
Merge branch 'main' into cairo-lint-extension
2 parents c1c24e8 + bc60328 commit 0b92122

File tree

11 files changed

+56
-10
lines changed

11 files changed

+56
-10
lines changed

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
pull_request:
88
merge_group:
99

10+
concurrency:
11+
group: ${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: ${{ github.head_ref != 'main' }}
13+
1014
jobs:
1115
build-test:
1216
name: build test ${{ matrix.platform.name }}

scarb/src/core/manifest/toml_manifest.rs

+13
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub struct TomlManifest {
4646
pub dependencies: Option<BTreeMap<PackageName, MaybeTomlWorkspaceDependency>>,
4747
pub dev_dependencies: Option<BTreeMap<PackageName, MaybeTomlWorkspaceDependency>>,
4848
pub lib: Option<TomlTarget<TomlLibTargetParams>>,
49+
pub executable: Option<TomlTarget<TomlExecutableTargetParams>>,
4950
pub cairo_plugin: Option<TomlTarget<TomlCairoPluginTargetParams>>,
5051
pub test: Option<Vec<TomlTarget<TomlExternalTargetParams>>>,
5152
pub target: Option<BTreeMap<TargetKind, Vec<TomlTarget<TomlExternalTargetParams>>>>,
@@ -295,6 +296,10 @@ pub struct TomlLibTargetParams {
295296
pub sierra_text: Option<bool>,
296297
}
297298

299+
#[derive(Debug, Default, Deserialize, Serialize)]
300+
#[serde(rename_all = "kebab-case")]
301+
pub struct TomlExecutableTargetParams {}
302+
298303
#[derive(Debug, Default, Deserialize, Serialize)]
299304
#[serde(rename_all = "kebab-case")]
300305
pub struct TomlCairoPluginTargetParams {
@@ -640,6 +645,14 @@ impl TomlManifest {
640645
None,
641646
)?);
642647

648+
targets.extend(Self::collect_target(
649+
TargetKind::EXECUTABLE,
650+
self.executable.as_ref(),
651+
&package_name,
652+
root,
653+
None,
654+
)?);
655+
643656
for (kind, ext_toml) in self
644657
.target
645658
.iter()

scarb/src/core/publishing/manifest_normalization.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub fn prepare_manifest_for_publish(pkg: &Package) -> Result<TomlManifest> {
3838
dependencies,
3939
dev_dependencies: None,
4040
lib: None,
41+
executable: None,
4142
cairo_plugin,
4243
test: None,
4344
target: None,

scarb/src/core/registry/client/local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl RegistryClient for LocalRegistryClient<'_> {
114114
let records = match fsx::read(records_path) {
115115
Err(e)
116116
if e.downcast_ref::<io::Error>()
117-
.map_or(false, |ioe| ioe.kind() == io::ErrorKind::NotFound) =>
117+
.is_some_and(|ioe| ioe.kind() == io::ErrorKind::NotFound) =>
118118
{
119119
return Ok(RegistryResource::NotFound);
120120
}

scarb/src/flock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl DerefMut for FileLockGuard {
8383
impl Drop for FileLockGuard {
8484
fn drop(&mut self) {
8585
if let Some(file) = self.file.take() {
86-
let _ = file.unlock();
86+
let _ = FileExt::unlock(&file);
8787
}
8888
}
8989
}
@@ -156,7 +156,7 @@ pub struct AdvisoryLockGuard {
156156
_inner: Arc<FileLockGuard>,
157157
}
158158

159-
impl<'f> AdvisoryLock<'f> {
159+
impl AdvisoryLock<'_> {
160160
/// Acquires this advisory lock in an async manner.
161161
///
162162
/// This lock is global per-process and can be acquired recursively.

scarb/src/ops/lockfile.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ pub fn read_lockfile(ws: &Workspace<'_>) -> Result<Lockfile> {
1616
.open(ws.lockfile_path())
1717
.context("failed to open lockfile")?;
1818

19-
file.lock_shared()
20-
.context("failed to acquire shared lockfile access")?;
19+
FileExt::lock_shared(&file).context("failed to acquire shared lockfile access")?;
2120

2221
let mut content = String::new();
2322
file.read_to_string(&mut content)?;

scarb/src/resolver/algorithm/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ mod state;
6565
/// packages that satisfy all incompatibilities cannot is never a solution of the dependency
6666
/// requirements). During the resolver run, new incompatibilities are derived until a valid solution
6767
/// is found in available versions.
68-
pub async fn resolve<'c>(
68+
pub async fn resolve(
6969
summaries: &[Summary],
7070
registry: &dyn Registry,
7171
lockfile: Lockfile,

scarb/src/resolver/algorithm/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl ResolverState {
3737
Ok(())
3838
}
3939

40-
async fn process_request<'a>(
40+
async fn process_request(
4141
&self,
4242
request: Request,
4343
registry: &dyn Registry,

scarb/src/sources/registry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl Source for RegistrySource<'_> {
132132
}
133133
}
134134

135-
impl<'c> RegistrySource<'c> {
135+
impl RegistrySource<'_> {
136136
/// Turn the downloaded `.tar.zst` tarball into a [`Package`].
137137
///
138138
/// This method extracts the tarball into cache directory, and then loads it using

scarb/tests/build_targets.rs

+29
Original file line numberDiff line numberDiff line change
@@ -1119,3 +1119,32 @@ fn test_executable_compiler_creates_output_files() {
11191119
t.child("target/dev/executable_test.executable.json")
11201120
.assert(predicates::path::exists());
11211121
}
1122+
1123+
#[test]
1124+
fn compile_executable_target_can_use_short_declaration() {
1125+
let t = TempDir::new().unwrap();
1126+
ProjectBuilder::start()
1127+
.name("executable_test")
1128+
.dep_cairo_test()
1129+
.dep_starknet()
1130+
.dep_cairo_execute()
1131+
.manifest_extra(indoc! {r#"
1132+
[executable]
1133+
"#})
1134+
.lib_cairo(indoc! {r#"
1135+
#[executable]
1136+
fn main() -> felt252 {
1137+
42
1138+
}
1139+
"#})
1140+
.build(&t);
1141+
1142+
Scarb::quick_snapbox()
1143+
.arg("build")
1144+
.current_dir(&t)
1145+
.assert()
1146+
.success();
1147+
1148+
t.child("target/dev/executable_test.executable.json")
1149+
.assert(predicates::path::exists());
1150+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Cairo Language Server
22

33
Scarb is distributed with the `scarb cairo-language-server` extension which is a compilation of the official
4-
[Cairo Language Server](https://github.com/starkware-libs/cairo/tree/main/crates/cairo-lang-language-server),
4+
[Cairo Language Server](https://github.com/software-mansion/cairols),
55
that is matching the version of Cairo compiler used in Scarb itself.
66
Scarb's version of the language server is just a launcher for the original code, unmodified.
77

88
## Visual Studio Code
99

1010
The Cairo Visual Studio Code extension will start language server from Scarb automatically.
1111
You do not need to take any further steps.
12-
Consult extension's [documentation](https://github.com/starkware-libs/cairo/blob/main/vscode-cairo/README.md)
12+
Consult extension's [documentation](https://github.com/software-mansion/vscode-cairo)
1313
for more detailed information.

0 commit comments

Comments
 (0)