Skip to content

Commit

Permalink
small fixes, reduce Package using where just id needed
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook committed Jun 7, 2024
1 parent f8b5c7e commit 8d7ae65
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
9 changes: 4 additions & 5 deletions cargo/src/assets/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::path::{PathBuf, Path};

use anstyle::AnsiColor as Color;
use anyhow::bail;
use cargo::CargoResult;
use cargo::core::{Package, PackageId, Verbosity};
use playdate::manifest::ManifestSourceOpt as _;
use playdate::metadata::source::MetadataSource as _;
use playdate::metadata::source::MetadataSource;
use playdate::metadata::METADATA_FIELD;
use playdate::layout::Layout;

Expand Down Expand Up @@ -41,7 +40,7 @@ pub fn build<'cfg>(config: &'cfg Config) -> CargoResult<AssetsArtifacts<'cfg>> {
let mut artifacts = AssetsArtifacts::new();

for (package, targets, ..) in config.possible_targets()? {
let env = plan::LazyEnvBuilder::new(config, package);
let env = plan::LazyEnvBuilder::new_for(config, package);
let mut plans: HashMap<&Package, _> = Default::default();
let global_layout = CrossTargetLayout::new(config, package.package_id(), None)?;
let mut layout = global_layout.assets_layout(config);
Expand Down Expand Up @@ -291,7 +290,7 @@ pub fn build<'cfg>(config: &'cfg Config) -> CargoResult<AssetsArtifacts<'cfg>> {
let msg = format!("{kind_prefix}assets pre-build for {}, {REASON}.", dep_pkg_id);
config.log().status("Skip", msg);
} else {
match pdc::build(config, dependency, locked.as_inner(), kind) {
match pdc::build(config, &dependency.package_id(), locked.as_inner(), kind) {
Ok(_) => {
let msg = format!("{kind_prefix}assets for {}", dep_pkg_id);
config.log().status("Finished", msg);
Expand Down
10 changes: 5 additions & 5 deletions cargo/src/assets/pdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::path::PathBuf;
use std::process::Command;

use anyhow::bail;
use cargo::core::PackageId;
use cargo::CargoResult;
use cargo::core::Package;
use playdate::fs::soft_link_checked;
use playdate::layout::Layout;

Expand All @@ -16,7 +16,7 @@ use super::plan::AssetKind;


pub fn build(config: &Config,
package: &Package,
package_id: &PackageId,
layout: &PlaydateAssets<PathBuf>,
kind: AssetKind)
-> CargoResult<()> {
Expand All @@ -34,12 +34,12 @@ pub fn build(config: &Config,
},
};

build_in(config, package, &src, &build, &layout.dest())
build_in(config, package_id, &src, &build, &layout.dest())
}

fn build_in(config: &Config, package: &Package, src: &Path, build: &Path, root: &Path) -> CargoResult<()> {
fn build_in(config: &Config, package_id: &PackageId, src: &Path, build: &Path, root: &Path) -> CargoResult<()> {
config.log()
.status("Compiling", format!("assets for {}", package.package_id()));
.status("Compiling", format!("assets for {}", package_id));

if config.no_sdk {
bail!("Build without Playdate SDK is not supported yet.");
Expand Down
14 changes: 8 additions & 6 deletions cargo/src/proc/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ pub fn cmd_logged(config: &Config, mut cmd: Command) -> CargoResult<Command> {
});
} else {
config.log_extra_verbose(|mut log| {
log.status(&tool, "output:");
output.stdout.lines().for_each(|line| {
if let Ok(line) = line {
log.status("", line);
}
});
if !output.stdout.trim_ascii().is_empty() {
log.status(&tool, "output:");
output.stdout.lines().for_each(|line| {
if let Ok(line) = line {
log.status("", line);
}
});
}
});
}

Expand Down

0 comments on commit 8d7ae65

Please sign in to comment.