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 package magic script #1771

Open
mkaput opened this issue Nov 25, 2024 · 0 comments
Open

Add package magic script #1771

mkaput opened this issue Nov 25, 2024 · 0 comments
Assignees

Comments

@mkaput
Copy link
Member

mkaput commented Nov 25, 2024

Add a new “magic” script (magic in that sense that Scarb has some logic that makes use of this script, like the test one being also used by scarb test command) called package. While running scarb package it will look for this script and, if present, it will execute it after preparing the tarball directory and before making an archive. The script will be run with PWD set to tarball preparation directory (unlike package directory, this is important and is exceptional!).

This script will be used to automate prebuilding macros (as an alternative to forcing devs to do this manually, see #1770). The rough procedure should look like this:

  1. Create directory target/scarb/cairo-plugin in tarball preparation directory.
  2. For each target triplet (see platform support for full list):
    1. call rustup component add $TARGET (avoid doing that if we can cheaply detect if it’s already installed)
    2. call cargo build --target $TARGET to build the plugin (note: ensure cargo shows a clear message if any build tools are missing)
    3. copy generated *.so/*.dll + debug info files to target/scarb/cairo-plugin directory, following this naming pattern:
      ${PACKAGE_NAME}_v${PACKAGE_VERSION}_${TARGET}.${so|dylib|dll}
  3. Ensure no other garbage is left in tarball directory. We do not want to publish unwanted files!

Example: usage by Starknet Foundry

Starknet Foundry will use the script mechanism in their CI for automatic packaging. It will implement the packaging procedure as a bash script that will be committed to the repository and hooked as a package script.
We will ask Dojo people to copy Foundry’s approach.
So, Foundry plugin will change its Scarb.toml to look as follows:

[package]
name = "snforge_scarb_plugin"
version = "0.33.1"
edition = "2024_07"

[scripts]
package = "prebuild.sh"

Note

No such task was created in Foundry repo.

@mkaput mkaput added this to the Proc Macro AOT Compilation milestone Nov 25, 2024
@github-project-automation github-project-automation bot moved this to Triage in Scarb Nov 25, 2024
@maciektr maciektr moved this from Triage to Todo in Scarb Nov 26, 2024
@wawel37 wawel37 moved this from Todo to In Progress in Scarb Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants