Skip to content

Commit

Permalink
Allow packaging via Cargo without verification
Browse files Browse the repository at this point in the history
  • Loading branch information
DelevoXDG committed Sep 24, 2024
1 parent 623357a commit 7d8001c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions scarb/src/compiler/plugin/proc_macro/compilation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::compiler::ProcMacroCompilationUnit;
use crate::core::{Config, Package, Workspace};
use crate::flock::Filesystem;
use crate::ops::PackageOpts;
use crate::process::exec_piping;
use anyhow::Result;
use camino::Utf8PathBuf;
Expand Down Expand Up @@ -64,8 +65,12 @@ pub fn fetch_package(package: &Package, ws: &Workspace<'_>) -> Result<()> {
run_cargo(CargoAction::Fetch, package, ws)
}

pub fn package_package(package: &Package, ws: &Workspace<'_>) -> Result<()> {
run_cargo(CargoAction::Package, package, ws)
pub fn package_package(package: &Package, opts: &PackageOpts, ws: &Workspace<'_>) -> Result<()> {
if opts.verify {
run_cargo(CargoAction::Package, package, ws)
} else {
run_cargo(CargoAction::PackageNoVerify, package, ws)
}
}

fn run_cargo(action: CargoAction, package: &Package, ws: &Workspace<'_>) -> Result<()> {
Expand All @@ -90,6 +95,7 @@ enum CargoAction {
Check,
Fetch,
Package,
PackageNoVerify,
}

struct CargoCommand {
Expand Down Expand Up @@ -131,6 +137,7 @@ impl From<CargoCommand> for Command {
CargoAction::Build => cmd.arg("build"),
CargoAction::Check => cmd.arg("check"),
CargoAction::Package => cmd.arg("package"),
CargoAction::PackageNoVerify => cmd.arg("package"),
};
match args.action {
CargoAction::Fetch => (),
Expand All @@ -139,6 +146,11 @@ impl From<CargoCommand> for Command {
cmd.arg("--target-dir");
cmd.arg(args.target_dir);
}
CargoAction::PackageNoVerify => {
cmd.arg("--target-dir");
cmd.arg(args.target_dir);
cmd.arg("--no-verify");
}
_ => {
cmd.arg("--release");
cmd.arg("--message-format");
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/ops/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn prepare_archive_recipe(

if pkg.manifest.targets.iter().any(|x| x.is_cairo_plugin()) {
// Package crate with Cargo.
package_package(pkg, ws)?;
package_package(pkg, opts, ws)?;

// Add normalized Cargo.toml file.
recipe.push(ArchiveFile {
Expand Down

0 comments on commit 7d8001c

Please sign in to comment.