Scarb Second Alpha
Welcome to the second alpha release of Scarb. There are two significant updates in this version, that we hope you'll like:
- Multi target architecture - A capability of building various kinds of artefacts, via a notion of package targets:
- Starknet contract target - Build Starknet contracts with the multi-target architecture.
- Built-in CASM compiler - Build CASM code along Sierra.
scarb fmt
- Run Cairo1 formatter over Scarb projects.
Multi target architecture
Like Cargo, Scarb can now treat a package as a library that can also be compiled to several more sophisticated kinds of artefacts. While Cargo is building binaries, tests, benchmarks etc., and this set is hardcoded Scarb can currently build Starknet contracts and the system here is prepared for extensibility by adding custom target kinds via future Scarb extensions.
The most basic aspect of building Sierra code is also a target, called lib
, which is the default one. You can explicitly enable it by adding the following line to Scarb.toml
:
[lib]
Other targets can be added by adding entries to the targets
table, for example in the future you could hypothetically do:
[[targets.dojo-game]]
[[targets.starknet-os]]
All targets have names, which default to the package name. They are used in logs and when naming output artefacts. Note, that for each target kind, each target name must be unique (otherwise targets would overwrite each other). For example, if your package is named foo
, and you want to build it to a file called bar.sierra
, you can add the following snippet to Scarb.toml
:
[lib]
name = "bar"
Note: We are not particularly happy with the fact that all targets share the same crate root. This brings some interesting problems, for example it is not possible to build both lib
and starknet-contract
targets from the single package, because they use mutually incompatible compilers. We plan to tackle this before Scarb release candidate release.
Starknet contract target
Scarb is now capable of building Cairo contracts, if package's Scarb.toml
contains [[target.starknet-contract]]
line:
[package]
name = "hello"
version = "0.1.0"
[[target.starknet-contract]]
Enabling Starknet contract target will cause the compiler to look for contract modules in source, and will emit a contract JSON file in the target/release
directory, instead of raw Sierra, for each found contract.
For more examples, check out related test from Scarb's codebase.
Built-in CASM compiler
In the default lib
target, we added a possibility to automatically compile generated Sierra code to CASM. Simply add these lines to your Scarb.toml
:
[lib]
casm = true
You can also disable generation of Sierra code with:
[lib]
sierra = false
casm = true
scarb fmt
The scarb fmt
command formats all Cairo source files in the project using the official formatter. It also has the --check
argument for use in CI checks. Shortly speaking, scarb fmt
works just exactly the same as cargo fmt
. We tried to mimic its behaviour as close as possible.
Notable minor changes
Better release archives
We have also done some serious release engineering, thanks to which:
-
Release archives now have POSIX-style directory layout. This is a very forward-looking change, as we expect the amount of bundled files to grow in future releases. Scarb binary now resides in the
bin
directory. -
We now publish checksums of release archives. You can verify integrity of downloaded archives with:
sha256sum --ignore-missing --check checksums.sha256
-
We added builds for Linux AArch64 platform.
OpenSSL dependency
This release does not depend on OpenSSL, so it should work on any Linux distribution, no matter whether it is OpenSSL 1.1 or 3.0-based.
Cairo version
This version of Scarb comes with Cairo starkware-libs/cairo@e0665d8.
Pull requests
- Make
create-output-dir
crate not depend oncargo-util
. Releasecreate-output-dir
1.0.0 by @mkaput in #53 - Bump indoc from 1.0.8 to 1.0.9 by @dependabot in #56
- Bump clap from 4.1.1 to 4.1.4 by @dependabot in #57
- Fix fixed durations in flock tests by actively listening to stdout by @mkaput in #59
- Multi-target architecture by @mkaput in #55
- Rework release workflow by @mkaput in #62
- Build StarkNet contracts by @mkaput in #61
- Bump toml_edit version by @maciektr in #68
- scarb fmt by @maciektr in #66
Full Changelog: v0.1.0-alpha.0...v0.1.0-alpha.1