From 7d8001c026a6297d422dee0714f28283a1c9d923 Mon Sep 17 00:00:00 2001 From: Maksim Zdobnikau Date: Tue, 24 Sep 2024 15:18:50 +0200 Subject: [PATCH] Allow packaging via Cargo without verification --- .../compiler/plugin/proc_macro/compilation.rs | 16 ++++++++++++++-- scarb/src/ops/package.rs | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/scarb/src/compiler/plugin/proc_macro/compilation.rs b/scarb/src/compiler/plugin/proc_macro/compilation.rs index fd64233cc..36c3a5156 100644 --- a/scarb/src/compiler/plugin/proc_macro/compilation.rs +++ b/scarb/src/compiler/plugin/proc_macro/compilation.rs @@ -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; @@ -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<()> { @@ -90,6 +95,7 @@ enum CargoAction { Check, Fetch, Package, + PackageNoVerify, } struct CargoCommand { @@ -131,6 +137,7 @@ impl From 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 => (), @@ -139,6 +146,11 @@ impl From 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"); diff --git a/scarb/src/ops/package.rs b/scarb/src/ops/package.rs index ae536eb01..34e5e932f 100644 --- a/scarb/src/ops/package.rs +++ b/scarb/src/ops/package.rs @@ -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 {