Skip to content

Commit a5d5c3f

Browse files
authored
Merge pull request #57 from rust3ds/fix/cargo-new
2 parents af2d8bf + 067520c commit a5d5c3f

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
matrix:
4444
toolchain:
4545
# Oldest supported nightly
46-
- nightly-2023-06-01
46+
- nightly-2024-02-18
4747
- nightly
4848

4949
continue-on-error: ${{ matrix.toolchain == 'nightly' }}

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ serde = { version = "1.0.139", features = ["derive"] }
1818
tee = "0.1.0"
1919
toml = "0.5.6"
2020
clap = { version = "4.0.15", features = ["derive", "wrap_help"] }
21-
shlex = "1.1.0"
21+
shlex = "1.3.0"
2222
serde_json = "1.0.108"

src/command.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,11 @@ impl New {
555555
let toml_path = project_path.join("Cargo.toml");
556556
let romfs_path = project_path.join("romfs");
557557
let main_rs_path = project_path.join("src/main.rs");
558+
let dummy_romfs_path = romfs_path.join("PUT_YOUR_ROMFS_FILES_HERE.txt");
558559

559-
// Create the "romfs" directory
560+
// Create the "romfs" directory, and place a dummy file within it.
560561
fs::create_dir(romfs_path).unwrap();
562+
fs::File::create(dummy_romfs_path).unwrap();
561563

562564
// Read the contents of `Cargo.toml` to a string
563565
let mut buf = String::new();

src/lib.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::graph::UnitGraph;
2525
pub fn run_cargo(input: &Input, message_format: Option<String>) -> (ExitStatus, Vec<Message>) {
2626
let mut command = make_cargo_command(input, &message_format);
2727

28+
// The unit graph is needed only when compiling a program.
2829
if input.cmd.should_compile() {
2930
let libctru = if should_use_ctru_debuginfo(&command, input.verbose) {
3031
"ctrud"
@@ -184,10 +185,13 @@ fn print_command(command: &Command) {
184185
eprintln!(
185186
" {}={} \\",
186187
k.to_string_lossy(),
187-
v.map_or_else(String::new, |s| shlex::quote(&s).to_string())
188+
v.map_or_else(String::new, |s| shlex::try_quote(&s).unwrap().to_string())
188189
);
189190
}
190-
eprintln!(" {}\n", shlex::join(cmd_str.iter().map(String::as_str)));
191+
eprintln!(
192+
" {}\n",
193+
shlex::try_join(cmd_str.iter().map(String::as_str)).unwrap()
194+
);
191195
}
192196

193197
/// Finds the sysroot path of the current toolchain
@@ -208,11 +212,13 @@ pub fn find_sysroot() -> PathBuf {
208212

209213
/// Checks the current rust version and channel.
210214
/// Exits if the minimum requirement is not met.
211-
pub fn check_rust_version() {
215+
pub fn check_rust_version(input: &Input) {
212216
let rustc_version = rustc_version::version_meta().unwrap();
213217

214-
if rustc_version.channel > Channel::Nightly {
215-
eprintln!("cargo-3ds requires a nightly rustc version.");
218+
// If the channel isn't nightly, we can't make use of the required unstable tools.
219+
// However, `cargo 3ds new` doesn't have these requirements.
220+
if rustc_version.channel > Channel::Nightly && input.cmd.should_compile() {
221+
eprintln!("building with cargo-3ds requires a nightly rustc version.");
216222
eprintln!(
217223
"Please run `rustup override set nightly` to use nightly in the \
218224
current directory, or use `cargo +nightly 3ds` to use it for a \

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use cargo_3ds::{check_rust_version, run_cargo};
55
use clap::Parser;
66

77
fn main() {
8-
check_rust_version();
9-
108
let Cargo::Input(mut input) = Cargo::parse();
119

10+
// Depending on the command, we might have different base requirements for the Rust version.
11+
check_rust_version(&input);
12+
1213
let message_format = match input.cmd.extract_message_format() {
1314
Ok(fmt) => fmt,
1415
Err(msg) => {

0 commit comments

Comments
 (0)