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 Windows Support #48

Merged
merged 4 commits into from
Jul 2, 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
29 changes: 25 additions & 4 deletions main/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
use cargo_stylus_util::{color::Color, sys};
use clap::Parser;
use eyre::{bail, Result};

// Conditional import for Unix-specific `CommandExt`
#[cfg(unix)]
use std::{env, os::unix::process::CommandExt};

// Conditional import for Windows
#[cfg(windows)]
use std::env;

#[derive(Parser, Debug)]
#[command(name = "stylus")]
#[command(bin_name = "cargo stylus")]
Expand Down Expand Up @@ -102,8 +109,15 @@ fn main() -> Result<()> {
// see if custom extension exists
let custom = format!("cargo-stylus-{arg}");
if sys::command_exists(&custom) {
let err = sys::new_command(&custom).arg(arg).args(args).exec();
bail!("failed to invoke {}: {err}", custom.red());
let mut command = sys::new_command(&custom);
command.arg(arg).args(args);

// Execute command conditionally based on the platform
#[cfg(unix)]
let err = command.exec(); // Unix-specific execution
#[cfg(windows)]
let err = command.status(); // Windows-specific execution
bail!("failed to invoke {:?}: {:?}", custom.red(), err);
}

eprintln!("Unknown subcommand {}.", arg.red());
Expand All @@ -126,6 +140,13 @@ fn main() -> Result<()> {
}

// should never return
let err = sys::new_command(name).arg(arg).args(args).exec();
bail!("failed to invoke {}: {err}", name.red());
let mut command = sys::new_command(name);
command.arg(arg).args(args);

// Execute command conditionally based on the platform
#[cfg(unix)]
let err = command.exec(); // Unix-specific execution
#[cfg(windows)]
let err = command.status(); // Windows-specific execution
bail!("failed to invoke {:?}: {:?}", name.red(), err);
}
14 changes: 13 additions & 1 deletion replay/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ use alloy_primitives::TxHash;
use cargo_stylus_util::{color::Color, sys};
use clap::{Args, Parser};
use eyre::{bail, eyre, Context, Result};
// Conditional import for Unix-specific `CommandExt`
#[cfg(unix)]
use std::{
os::unix::process::CommandExt,
path::{Path, PathBuf},
};

// Conditional import for Windows
#[cfg(windows)]
use std::{
env,
path::{Path, PathBuf},
};
use tokio::runtime::Builder;

mod hostio;
Expand Down Expand Up @@ -127,9 +136,12 @@ async fn replay(args: ReplayArgs) -> Result<()> {
cmd.arg(arg);
}
cmd.arg("--child");
#[cfg(unix)]
let err = cmd.exec();
#[cfg(windows)]
let err = cmd.status();

bail!("failed to exec gdb {}", err);
bail!("failed to exec gdb {:?}", err);
}

let provider = sys::new_provider(&args.endpoint)?;
Expand Down
Loading