Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new target for Cairo executable #1813

Open
maciektr opened this issue Dec 5, 2024 · 0 comments
Open

Add new target for Cairo executable #1813

maciektr opened this issue Dec 5, 2024 · 0 comments
Assignees

Comments

@maciektr
Copy link
Contributor

maciektr commented Dec 5, 2024

Problem

Should compile project with use of compile_executable_in_prepared_db API.
This target should create new json output file with Executable of a function compiled before.

The main crate should have exactly one function marked as #[executable] (this is enforced by the compiler).

This functionality will heavily rely on the API exposed by cairo-lang-execuable crate in Cairo repo.

Proposed Solution

  1. Add new pre-defined TargetKind called executable.

  2. Add new compiler to compilers dir, called executable.

  • This should be similar to the lib compiler
  • Should implement the Compiler trait
  • Should declare the executable target kind (from point 1.) as it's target_kind.
  • Should read target dir, compiler config and main crates from CompilationUnit (see)
  • Should compile main crates with compile_executable_in_prepared_db
  • Do not provide any path, diagnostic reporter can be found in compiler_config.diagnostics_reporter
  1. Wrap compilation result into Executable struct with Executable::new

  2. Serialize the executable struct into JSON with serde

  3. Write the result of serialization to the target directory with .executable.json extension.

  4. Add created compiler to the CompilerRepository so Scarb can find it when compiling targets.

  5. Add a test case to check if your new compiler can be used by users. It can be added to build_targets.rs test file. When creating a test project with ProjectBuilder, add [[target.executable]] to manifest with manifest_extra. Your lib.cairo (can be set with lib_cairo) should define a Cairo function with #[executable] attribute. Check if files in output directory are created properly.

Notes

Try dividing this work into consecutive PRs.

@maciektr maciektr added this to the Scarb execute milestone Dec 5, 2024
@github-project-automation github-project-automation bot moved this to Triage in Scarb Dec 5, 2024
@maciektr maciektr moved this from Triage to Backlog in Scarb Dec 5, 2024
@maciektr maciektr moved this from Backlog to Todo in Scarb Dec 6, 2024
@maciektr maciektr assigned DelevoXDG and unassigned FroyaTheHen Dec 10, 2024
@maciektr maciektr moved this from Todo to In Progress in Scarb Dec 10, 2024
@maciektr maciektr assigned FroyaTheHen and unassigned DelevoXDG Dec 10, 2024
@FroyaTheHen FroyaTheHen moved this from In Progress to Done in Scarb Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants