Skip to content

Commit d7215d6

Browse files
authored
Add configurable application name to CTRConfig (#76)
1 parent 4cadb6f commit d7215d6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn check_rust_version(input: &Input) {
263263
pub(crate) fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig {
264264
// For now, assume a single "kind" per artifact. It seems to be the case
265265
// when a single executable is built anyway but maybe not in all cases.
266-
let name = match artifact.target.kind[0] {
266+
let package_name = match artifact.target.kind[0] {
267267
Bin | Lib | RLib | DyLib if artifact.profile.test => {
268268
format!("{} tests", artifact.target.name)
269269
}
@@ -283,7 +283,7 @@ pub(crate) fn get_artifact_config(package: Package, artifact: Artifact) -> CTRCo
283283
.unwrap_or_default();
284284

285285
CTRConfig {
286-
name,
286+
package_name,
287287
authors: config.authors.or(Some(package.authors)),
288288
description: config.description.or(package.description),
289289
manifest_dir: package.manifest_path.parent().unwrap().into(),
@@ -374,11 +374,13 @@ pub struct CTRConfig {
374374
#[serde(alias = "romfs-dir")]
375375
romfs_dir: Option<Utf8PathBuf>,
376376

377+
/// The name of the application, defaulting to the package name if not specified.
378+
name: Option<String>,
379+
377380
// Remaining fields come from cargo metadata / build artifact output and
378-
// cannot be customized by users in `package.metadata.cargo-3ds`. I suppose
379-
// in theory we could allow name to be customizable if we wanted...
381+
// cannot be customized by users in `package.metadata.cargo-3ds`.
380382
#[serde(skip)]
381-
name: String,
383+
package_name: String,
382384
#[serde(skip)]
383385
target_path: Utf8PathBuf,
384386
#[serde(skip)]
@@ -428,7 +430,7 @@ impl CTRConfig {
428430
let mut command = Command::new("smdhtool");
429431
command
430432
.arg("--create")
431-
.arg(&self.name)
433+
.arg(self.name.as_ref().unwrap_or(&self.package_name))
432434
.arg(description)
433435
.arg(publisher)
434436
.arg(icon_path)

0 commit comments

Comments
 (0)