Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cargo #378

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 106 additions & 97 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions cargo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-playdate"
version = "0.5.0-beta.2"
version = "0.5.0-beta.3"
readme = "README.md"
description = "Build tool for neat yellow console."
keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"]
Expand Down Expand Up @@ -31,10 +31,10 @@ clap_lex = "0.7"
dirs.workspace = true
fs_extra.workspace = true

cargo = "0.78"
cargo = "0.79"
cargo-util = "0.2.11"
cargo-platform = "0.1.8"
cargo-util-schemas = "0.2.0"
cargo-util-schemas = "0.3.0"

semver.workspace = true
serde = { workspace = true, features = ["derive"] }
Expand Down
18 changes: 9 additions & 9 deletions cargo/src/assets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ pub mod proto {

// clean layout if needed:
if !cfg.dry_run && cfg.compile_options.build_config.force_rebuild {
if !matches!(cfg.workspace.config().shell().verbosity(), Verbosity::Quiet) {
if !matches!(cfg.workspace.gctx().shell().verbosity(), Verbosity::Quiet) {
cfg.log().status("Clean", format!("assets for {}", key.id));
}
layout.clean()?;
}


let mut locked = layout.lock_mut(cfg.workspace.config())?;
let mut locked = layout.lock_mut(cfg.workspace.gctx())?;
locked.prepare()?;

// path of build-plan file:
Expand Down Expand Up @@ -425,7 +425,7 @@ pub fn build<'cfg>(config: &'cfg Config) -> CargoResult<AssetsArtifacts<'cfg>> {
let mut options = HashMap::new();

if !config.dry_run && config.compile_options.build_config.force_rebuild {
if !matches!(config.workspace.config().shell().verbosity(), Verbosity::Quiet) {
if !matches!(config.workspace.gctx().shell().verbosity(), Verbosity::Quiet) {
config.log()
.status("Clean", format!("assets for {}", package.package_id()));
}
Expand Down Expand Up @@ -470,7 +470,7 @@ pub fn build<'cfg>(config: &'cfg Config) -> CargoResult<AssetsArtifacts<'cfg>> {
// TODO: list deps in the plan

for (package, metadata) in packages {
let locked = layout.lock_mut(config.workspace.config())?;
let locked = layout.lock_mut(config.workspace.gctx())?;
let dev = has_dev && package.package_id() == target_pid;
let err_msg = |err| format!("{err}, caused when planning assets for {}.", package.package_id());

Expand Down Expand Up @@ -517,12 +517,12 @@ pub fn build<'cfg>(config: &'cfg Config) -> CargoResult<AssetsArtifacts<'cfg>> {
.chain(plan.dev.as_ref().into_iter().map(|plan| (plan, AssetKind::Dev)))
{
let message = plan.printable_serializable(package.package_id(), kind);
config.workspace.config().shell().print_json(&message)?;
config.workspace.gctx().shell().print_json(&message)?;
}
}
} else {
config.workspace
.config()
.gctx()
.shell()
.verbose(|shell| {
for (package, plan) in plans.iter() {
Expand Down Expand Up @@ -605,7 +605,7 @@ pub fn build<'cfg>(config: &'cfg Config) -> CargoResult<AssetsArtifacts<'cfg>> {

// finally apply plans:
if !config.dry_run && !config.compile_options.build_config.build_plan && !plans.is_empty() {
let mut locked = layout.lock_mut(config.workspace.config())?;
let mut locked = layout.lock_mut(config.workspace.gctx())?;
locked.prepare()?;

for (dependency, mut plan) in plans.into_iter() {
Expand Down Expand Up @@ -764,8 +764,8 @@ pub fn build<'cfg>(config: &'cfg Config) -> CargoResult<AssetsArtifacts<'cfg>> {


if config.compile_options.build_config.build_plan {
config.workspace.config().shell().out().flush()?;
config.workspace.config().shell().err().flush()?;
config.workspace.gctx().shell().out().flush()?;
config.workspace.gctx().shell().err().flush()?;
std::process::exit(0);
}

Expand Down
12 changes: 6 additions & 6 deletions cargo/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn build<'cfg>(config: &'cfg Config<'cfg>) -> CargoResult<Vec<BuildProduct<'


for (path, ct, inv) in mapping {
let layout = config.layout_for(inv.kind)?.lock(config.workspace.config())?;
let layout = config.layout_for(inv.kind)?.lock(config.workspace.gctx())?;
let artifact = CargoArtifact { package,
path,
name: art.target.name,
Expand Down Expand Up @@ -395,7 +395,7 @@ fn build_binary<'cfg, Layout, S>(config: &'cfg Config,
layout.as_ref(),
package_crate_name,
Some(artifact.name.as_ref()),
).lock(config.workspace.config())?;
).lock(config.workspace.gctx())?;
pdl.as_mut().prepare()?;

let product = if artifact.ck.is_playdate() {
Expand Down Expand Up @@ -445,7 +445,7 @@ fn build_library<'cfg, Layout, S>(config: &'cfg Config,
"{} of {}{}",
artifact.ct,
artifact.package,
if config.workspace.config().extra_verbose() {
if config.workspace.gctx().extra_verbose() {
format!(" from {}", artifact.path.as_relative_to_root(config).display())
} else {
Default::default()
Expand All @@ -464,7 +464,7 @@ fn build_library<'cfg, Layout, S>(config: &'cfg Config,
layout.as_ref(),
package_crate_name,
Some(artifact.name.as_ref()),
).lock(config.workspace.config())?;
).lock(config.workspace.gctx())?;
pdl.as_mut().prepare()?;

let product = if artifact.ck.is_playdate() {
Expand Down Expand Up @@ -511,8 +511,8 @@ fn build_library<'cfg, Layout, S>(config: &'cfg Config,
});

// Print gcc's output in verbose mode only!
let quiet = config.workspace.config().shell().verbosity() == Verbosity::Quiet;
let extra_verbose = config.workspace.config().extra_verbose();
let quiet = config.workspace.gctx().shell().verbosity() == Verbosity::Quiet;
let extra_verbose = config.workspace.gctx().extra_verbose();
gcc.stderr(if quiet { Stdio::null() } else { Stdio::inherit() });
gcc.stdout(if extra_verbose {
Stdio::inherit()
Expand Down
4 changes: 2 additions & 2 deletions cargo/src/build/rustflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Rustflags {
if config.no_gcc {
// export LINK MAP:
let target_dir = config.workspace
.config()
.gctx()
.target_dir()
.unwrap_or_default()
.unwrap_or_else(|| Filesystem::new("target".into()))
Expand Down Expand Up @@ -103,7 +103,7 @@ impl Rustflags {
let existing = [&device_target, &config.host_target].into_iter()
.filter_map(|ck| {
config.workspace
.config()
.gctx()
.target_cfg_triple(ck.short_name())
.ok()
.and_then(|tcfg| tcfg.rustflags)
Expand Down
8 changes: 4 additions & 4 deletions cargo/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use cargo::core::{Workspace, VirtualManifest, WorkspaceConfig, WorkspaceRootConf
use cargo::core::compiler::{CompileTarget, CompileKind};
use cargo::ops::CompileOptions;
use cargo::util::command_prelude::{ArgMatchesExt, CompileMode, ProfileChecking};
use cargo::util::Config as CargoConfig;
use cargo::util::GlobalContext as CargoConfig;
use cargo::util::CargoResult;
use clap_lex::SeekFrom;

Expand Down Expand Up @@ -196,7 +196,7 @@ pub fn initialize_from(args: impl IntoIterator<Item = impl Into<OsString> + AsRe
matches.check_optional_opts(&workspace, &compile_options)?;
}

let rustc = workspace.config().load_global_rustc(Some(&workspace))?;
let rustc = workspace.gctx().load_global_rustc(Some(&workspace))?;
let host_target = CompileTarget::new(&rustc.host)?;


Expand Down Expand Up @@ -365,15 +365,15 @@ fn presented_dangerous_global_args_values<'m>(matches: &'m ArgMatches,


fn compile_options(cmd: &Cmd, matches: &ArgMatches, ws: &Workspace<'_>) -> CargoResult<CompileOptions> {
let cfg = ws.config();
let cfg = ws.gctx();
let mut compile_options = match cmd {
// allow multiple crates:
Cmd::Build | Cmd::Package | Cmd::Migrate | Cmd::Assets => {
matches.compile_options(cfg, CompileMode::Build, Some(ws), ProfileChecking::Custom)?
},

Cmd::New | Cmd::Init => {
let mut opts = CompileOptions::new(ws.config(), CompileMode::Check { test: false })?;
let mut opts = CompileOptions::new(ws.gctx(), CompileMode::Check { test: false })?;
opts.build_config
.requested_kinds
.push(PlaydateTarget::Device.into());
Expand Down
2 changes: 1 addition & 1 deletion cargo/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod cargo;
mod playdate;

use ::cargo::CargoResult;
use ::cargo::Config;
use ::cargo::GlobalContext as Config;
use ::cargo::util::FileLock;
use ::cargo::util::Filesystem;

Expand Down
4 changes: 2 additions & 2 deletions cargo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::borrow::Cow;
use anyhow::bail;
use cargo::core::Verbosity;
use cargo::core::compiler::{CrateType, CompileKind};
use cargo::util::{CargoResult, Config as CargoConfig};
use cargo::util::{CargoResult, GlobalContext as CargoConfig};
use config::Config;
use anstyle::AnsiColor as Color;

Expand Down Expand Up @@ -42,7 +42,7 @@ fn main() -> CargoResult<()> {
|err| {
#[cfg(debug_assertions)]
eprintln!("Error: {err:?}");
let config = config.workspace.config();
let config = config.workspace.gctx();
config.shell().set_verbosity(Verbosity::Normal);
config.shell().error(err).ok();
std::process::exit(1);
Expand Down
2 changes: 1 addition & 1 deletion cargo/src/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn package_multi_target<'p>(config: &Config,
let layout_target_name = Name::with_names(package.name().as_str(), products.first().map(|p| &p.name));
let mut layout =
CrossTargetLayout::new(config, package.package_id(), Some(layout_target_name))?.lock(config.workspace
.config())?;
.gctx())?;
if let Some(assets) = assets {
debug_assert_eq!(
layout.as_ref().assets_layout(config).root(),
Expand Down
8 changes: 4 additions & 4 deletions cargo/src/proc/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ pub fn cmd_logged(config: &Config, mut cmd: Command) -> CargoResult<Command> {
if let Ok(error) = std::str::from_utf8(stderr) {
config.log().status_err(format!("{tool} stderr:\n{error}"));
} else {
config.workspace.config().shell().status_header(&tool)?;
config.workspace.gctx().shell().status_header(&tool)?;
config.workspace
.config()
.gctx()
.shell()
.err()
.write_all("stderr:\n".as_bytes())?;
config.workspace.config().shell().err().write_all(stderr)?;
config.workspace.config().shell().err().write_all(b"\n")?;
config.workspace.gctx().shell().err().write_all(stderr)?;
config.workspace.gctx().shell().err().write_all(b"\n")?;
}
}

Expand Down
6 changes: 3 additions & 3 deletions cargo/src/proc/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn cargo_proxy_with<S: AsRef<OsStr>>(cfg: &Config,
pub fn cargo(cfg: Option<&Config>) -> CargoResult<std::process::Command> {
let mut proc = cargo_cmd(cfg);

if let Some(cfg) = cfg.map(|cfg| cfg.workspace.config()) {
if let Some(cfg) = cfg.map(|cfg| cfg.workspace.gctx()) {
// transparent env:
cfg.env_config()?.iter().for_each(|(k, v)| {
let value = v.resolve(cfg);
Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn cargo(cfg: Option<&Config>) -> CargoResult<std::process::Command> {
pub fn cargo_cmd(cfg: Option<&Config>) -> std::process::Command {
fn cargo_path<'t>(cfg: Option<&'t Config<'t>>) -> (Cow<'t, Path>, Option<&str>) {
if let Some(cfg) = cfg {
let path = cfg.workspace.config().cargo_exe().log_err().ok().map(Cow::from);
let path = cfg.workspace.gctx().cargo_exe().log_err().ok().map(Cow::from);
if path.is_some() && path == std::env::current_exe().log_err().ok().map(Into::into) {
// Seems to we're in standalone mode.
cargo_path(None)
Expand Down Expand Up @@ -115,7 +115,7 @@ pub fn read_cargo_json<T: DeserializeOwned>(cfg: &Config, mut cmd: Command) -> C

let output = cmd.output()?;
if !output.status.success() {
cfg.workspace.config().shell().err().write_all(&output.stderr)?;
cfg.workspace.gctx().shell().err().write_all(&output.stderr)?;
output.status.exit_ok()?;
}

Expand Down
4 changes: 2 additions & 2 deletions cargo/src/utils/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ impl Config<'_> {
#[must_use]
pub fn log(&self) -> CargoLogger<RefMut<'_, Shell>> {
CargoLogger(
self.workspace.config().shell(),
self.workspace.gctx().shell(),
self.compile_options.build_config.emit_json(),
)
}

pub fn log_extra_verbose<F>(&self, mut callback: F)
where F: FnMut(CargoLogger<RefMut<'_, Shell>>) {
if self.workspace.config().extra_verbose() {
if self.workspace.gctx().extra_verbose() {
callback(self.log())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct LazyBuildContext<'a, 'cfg> {

impl<'a, 'cfg> LazyBuildContext<'a, 'cfg> {
pub fn new(config: &'cfg Config) -> CargoResult<Self> {
let options = CompileOptions::new(config.workspace.config(), CompileMode::Check { test: false })?;
let options = CompileOptions::new(config.workspace.gctx(), CompileMode::Check { test: false })?;
Ok(Self { bcx: Lazy::new(),
interner: UnitInterner::new(),
workspace: &config.workspace,
Expand Down
6 changes: 5 additions & 1 deletion cargo/src/utils/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl<'t> Config<'t> {
Ok(members)
}

#[deprecated(since = "0.5", note = "TODO: use unit_graph instead")]
/// Returns a list of targets that are requested by the user.
/// Resolved by requested spec initially, with fallback to all possible targets.
pub fn possible_targets_ext(&'t self) -> CargoResult<Vec<PossibleTargets<'t>>> {
Expand All @@ -37,13 +38,15 @@ impl<'t> Config<'t> {
Ok(possible)
}

#[deprecated(since = "0.5", note = "TODO: use unit_graph instead")]
/// Returns a list of potential targets that are requested by the user.
pub fn possible_targets(&'t self) -> CargoResult<impl Iterator<Item = PossibleTargets<'t>>> {
let packages = self.members_with_features()?.into_iter().map(|(p, _)| p);
let members = self.possible_targets_with(packages);
Ok(members)
}

#[deprecated(since = "0.5", note = "TODO: use unit_graph instead")]
pub fn possible_targets_with(&'t self,
members: impl IntoIterator<Item = &'t Package>)
-> impl Iterator<Item = PossibleTargets<'t>> {
Expand All @@ -57,6 +60,7 @@ impl<'t> Config<'t> {
})
}

#[deprecated(since = "0.5", note = "TODO: determine from unit_graph instead")]
pub fn possible_compile_kinds(&'t self) -> CargoResult<Vec<CompileKind>> {
let member_kinds = self.members_with_features()?.into_iter().flat_map(|(p, _)| {
p.manifest()
Expand All @@ -79,7 +83,7 @@ impl<'t> Config<'t> {

pub fn target_info(&self, kind: CompileKind) -> CargoResult<TargetInfo> {
TargetInfo::new(
self.workspace.config(),
self.workspace.gctx(),
&self.possible_compile_kinds()?,
&self.rustc,
kind,
Expand Down
4 changes: 2 additions & 2 deletions support/addr2line/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-symbolize"
version = "0.1.2"
version = "0.1.3"
readme = "README.md"
description = "Tools for symbolise addresses from bin (pdex.elf) and Playdate's trace or crashlog."
keywords = ["playdate", "bin", "elf", "addr2line", "utility"]
Expand Down Expand Up @@ -48,7 +48,7 @@ workspace = true
optional = true

[dependencies.rusqlite]
version = "0.30"
version = "0.31"
features = ["bundled"]

[dependencies.utils]
Expand Down
Loading