Skip to content

Commit

Permalink
override (fix) manifest fields (id & name) for examples, wip
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed May 14, 2024
1 parent 3e1370d commit 33fa4aa
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions cargo/src/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ fn package_single_target<'p>(config: &Config,
}

// manifest:
build_manifest(config, &product.layout, product.package, assets)?;
let ext_id = product.example.then(|| format!("dev.{}", product.name).into());
let ext_name = product.example.then_some(product.name.as_str().into());
build_manifest(config, &product.layout, product.package, assets, ext_id, ext_name)?;

// finally call pdc and pack:
let mut artifact = execute_pdc(config, &product.layout)?;
Expand Down Expand Up @@ -217,15 +219,15 @@ fn package_multi_target<'p>(config: &Config,
}
crate::layout::Layout::prepare(&mut layout.as_mut())?;

let mut has_dev = Default::default();
let mut dev = Default::default();
for product in &products {
log::debug!("Preparing binaries for packaging {}", product.presentable_name());
assert_eq!(package, product.package, "package must be same");
let dst = layout.build().join(product.path.file_name().expect("file_name"));
soft_link_checked(&product.path, &dst, true, layout.as_inner().target())?;

if product.example {
has_dev = true;
dev = Some(product);
}
}

Expand All @@ -237,15 +239,17 @@ fn package_multi_target<'p>(config: &Config,
prepare_assets(
config,
assets,
has_dev,
dev.is_some(),
layout.build(),
true,
layout.as_inner().target(),
)?;
}

// manifest:
build_manifest(config, &layout, package, assets)?;
let ext_id = dev.and_then(|p| p.example.then(|| format!("dev.{}", p.name).into()));
let ext_name = dev.and_then(|p| p.example.then_some(p.name.as_str().into()));
build_manifest(config, &layout, package, assets, ext_id, ext_name)?;

// finally call pdc and pack:
let mut artifact = execute_pdc(config, &layout)?;
Expand Down Expand Up @@ -273,20 +277,28 @@ fn package_multi_target<'p>(config: &Config,
fn build_manifest<Layout: playdate::layout::Layout>(config: &Config,
layout: &Layout,
package: &Package,
assets: Option<&AssetsArtifact<'_>>)
assets: Option<&AssetsArtifact<'_>>,
dev_id_suffix: Option<Cow<'_, str>>,
name_override: Option<Cow<'_, str>>)
-> CargoResult<()> {
config.log().verbose(|mut log| {
let msg = format!("building package manifest for {}", package.package_id());
log.status("Manifest", msg);
});

if dev_id_suffix.is_some() || name_override.is_some() {
// TODO: modify ManifestSource
}

let manifest = if let Some(metadata) = assets.and_then(|a| a.metadata.as_ref()) {
Manifest::try_from_source(ManifestSource { package,
metadata: metadata.into() })
let source = ManifestSource { package,
metadata: metadata.into() };
Manifest::try_from_source(source)
} else {
let metadata = playdate_metadata(package);
Manifest::try_from_source(ManifestSource { package,
metadata: metadata.as_ref() })
let source = ManifestSource { package,
metadata: metadata.as_ref() };
Manifest::try_from_source(source)
}.map_err(|err| anyhow!(err))?;
std::fs::write(layout.manifest(), manifest.to_manifest_string())?;
Ok(())
Expand Down

0 comments on commit 33fa4aa

Please sign in to comment.