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

Change Default Build Options #138

Merged
merged 7 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ ark-bls12-381 = { git = "https://github.com/arkworks-rs/curves/", rev = "3fded1f
codegen-units = 1
lto = true

[profile.release-unoptimized]
inherits = "release"

[profile.release-unoptimized.package.example]
opt-level = 0

[profile.bench]
inherits = "release"
debug = true
16 changes: 5 additions & 11 deletions tools/src/command/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ use nexus_tools_dev::{
};

pub fn handle_command(args: RunArgs) -> anyhow::Result<()> {
let RunArgs { verbose, release, bin } = args;
let RunArgs { verbose, profile, bin } = args;

run_vm(bin, verbose, release)
run_vm(bin, verbose, &profile)
}

fn run_vm(bin: Option<String>, verbose: bool, release: bool) -> anyhow::Result<()> {
// build the artifact
let profile = if release {
cargo(None, ["build", "--release"])?;
"release"
} else {
cargo(None, ["build"])?;
"debug"
};
fn run_vm(bin: Option<String>, verbose: bool, profile: &str) -> anyhow::Result<()> {
// build artifact
cargo(None, ["build", "--profile", profile])?;

let path = path_to_artifact(bin, profile)?;

Expand Down
19 changes: 18 additions & 1 deletion tools/tools-dev/src/command/common/new.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fs, path::PathBuf};
use std::{fs, io::Write, path::PathBuf};

use anyhow::Context;
use clap::Args;
Expand Down Expand Up @@ -32,6 +32,23 @@ fn setup_crate(path: PathBuf) -> anyhow::Result<()> {
],
)?;

let mut fp = fs::OpenOptions::new()
.append(true)
.open(path.join("Cargo.toml"))?;

writeln!(
fp,
concat!(
"\n",
"# Generated by nexus-tools, do not remove!",
sjudson marked this conversation as resolved.
Show resolved Hide resolved
"#",
"# This profile is used for generating proofs, as Nexus VM support for compiler optimizations is still under development.",
"[profile.release-unoptimized]\n",
"inherits = \"release\"\n",
"opt-level = 0\n"
)
)?;

// .cargo/config
let config_path = path.join(".cargo");
fs::create_dir_all(&config_path)?;
Expand Down
4 changes: 2 additions & 2 deletions tools/tools-dev/src/command/common/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub struct LocalProveArgs {

#[derive(Debug, Args)]
pub struct CommonProveArgs {
/// Build artifacts with the specified profile. "release" is default.
#[arg(long, default_value = "release")]
/// Build artifacts with the specified profile. "release-unoptimized" is default.
#[arg(long, default_value = "release-unoptimized")]
pub profile: String,

/// Name of the bin target to run.
Expand Down
6 changes: 3 additions & 3 deletions tools/tools-dev/src/command/common/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ pub struct RunArgs {
#[arg(short)]
pub verbose: bool,

/// Build artifacts in release mode, with optimizations.
#[arg(short, long)]
pub release: bool,
/// Build artifacts with the specified profile. "dev" is default.
#[arg(long, default_value = "dev")]
pub profile: String,

/// Name of the bin target to run.
#[arg(long)]
Expand Down
16 changes: 5 additions & 11 deletions tools/tools-dev/src/command/dev/common_impl/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ use crate::{
};

pub fn handle_command(args: RunArgs) -> anyhow::Result<()> {
let RunArgs { verbose, release, bin } = args;
let RunArgs { verbose, profile, bin } = args;

run_vm(bin, verbose, release)
run_vm(bin, verbose, &profile)
}

fn run_vm(bin: Option<String>, verbose: bool, release: bool) -> anyhow::Result<()> {
// build the artifact
let profile = if release {
cargo(None, ["build", "--release"])?;
"release"
} else {
cargo(None, ["build"])?;
"debug"
};
fn run_vm(bin: Option<String>, verbose: bool, profile: &str) -> anyhow::Result<()> {
// build artifact
cargo(None, ["build", "--profile", profile])?;

let path = path_to_artifact(bin, profile)?;

Expand Down
Loading