From 18e4997d9488aa49939cc4b6b5e12a89ed3740d4 Mon Sep 17 00:00:00 2001 From: cohae Date: Sun, 30 Nov 2025 18:47:50 +0100 Subject: [PATCH] Add configurable application name to CTRConfig --- src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ef8b0e6..87e41c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -263,7 +263,7 @@ pub fn check_rust_version(input: &Input) { pub(crate) fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig { // For now, assume a single "kind" per artifact. It seems to be the case // when a single executable is built anyway but maybe not in all cases. - let name = match artifact.target.kind[0] { + let package_name = match artifact.target.kind[0] { Bin | Lib | RLib | DyLib if artifact.profile.test => { format!("{} tests", artifact.target.name) } @@ -283,7 +283,7 @@ pub(crate) fn get_artifact_config(package: Package, artifact: Artifact) -> CTRCo .unwrap_or_default(); CTRConfig { - name, + package_name, authors: config.authors.or(Some(package.authors)), description: config.description.or(package.description), manifest_dir: package.manifest_path.parent().unwrap().into(), @@ -374,11 +374,13 @@ pub struct CTRConfig { #[serde(alias = "romfs-dir")] romfs_dir: Option, + /// The name of the application, defaulting to the package name if not specified. + name: Option, + // Remaining fields come from cargo metadata / build artifact output and - // cannot be customized by users in `package.metadata.cargo-3ds`. I suppose - // in theory we could allow name to be customizable if we wanted... + // cannot be customized by users in `package.metadata.cargo-3ds`. #[serde(skip)] - name: String, + package_name: String, #[serde(skip)] target_path: Utf8PathBuf, #[serde(skip)] @@ -428,7 +430,7 @@ impl CTRConfig { let mut command = Command::new("smdhtool"); command .arg("--create") - .arg(&self.name) + .arg(self.name.as_ref().unwrap_or(&self.package_name)) .arg(description) .arg(publisher) .arg(icon_path)