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

output configured targets #1240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Emilgardis
Copy link
Member

@Emilgardis Emilgardis commented Apr 3, 2023

$ cross-util list-targets --format-version=1
{
  "format_version": "1",
  "targets": [
    {
      "platforms": [
        "linux/amd64=x86_64-unknown-linux-gnu"
      ],
      "triplet": "x86_64-unknown-linux-gnu"
    },
    {
      "platforms": [
        "linux/amd64=x86_64-unknown-linux-gnu"
      ],
      "triplet": "x86_64-unknown-linux-musl"
    }
	<...snip...>
  ]
}

@Emilgardis Emilgardis requested a review from a team as a code owner April 3, 2023 23:16
@Emilgardis Emilgardis linked an issue Apr 3, 2023 that may be closed by this pull request
2 tasks
@Emilgardis
Copy link
Member Author

@mcandre does this work for you? I can add more data to the array

.iter()
.filter_map(|i| {
Some(Target {
triplet: Some(i.name).filter(|i| *i != "zig")?.to_owned(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice usage of try trait :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
triplet: Some(i.name).filter(|i| *i != "zig")?.to_owned(),
triplet: if *i.name != "zig" { i.name.to_owned() } else { return None },

.collect::<Vec<_>>()
})
.filter(|v| !v.is_empty())
.unwrap_or_else(|| vec![docker::ImagePlatform::DEFAULT.to_string()]),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +7 to +15
#[derive(Args, Debug)]
pub struct ListTargets {
/// Format version
#[clap(long)]
format_version: Option<FormatVersion>,
/// Coloring: auto, always, never
#[clap(long)]
pub color: Option<String>,
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a way to only output targets in toml config? Maybe that could be data included in the output?

Comment on lines +9 to +11
/// Format version
#[clap(long)]
format_version: Option<FormatVersion>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this kind of stability?

@mcandre
Copy link

mcandre commented Apr 4, 2023

@mcandre does this work for you? I can add more data to the array

For my purposes, I would like to see the support tier number included in the output. Perhaps a field like "support_tier": 3 as a sister field beside the "triplet" fields.

If possible, I would prefer a flatter array design, that doesn't restate some of the triple and platform information. I just want to be able to associate triple with support tier number.

If we go with JSON, then I would like to see all cross data models exported as a stable Rust library. The current policy treats only the CLI as stable. Until the data models and schemas (e.g., the entire Cross.toml schema) enter a stable library, I would actually prefer to see non-JSON in cross CLI tool output.

That is, docker ps -a-style text tables would be fine. These are easier to parse through via simple regex captures, than a long series of manual JSON value casting and checking snippets.

@Emilgardis
Copy link
Member Author

Emilgardis commented Apr 4, 2023

For my purposes, I would like to see the support tier number included in the output. Perhaps a field like "support_tier": 3 as a sister field beside the "triplet" fields.

The tier is not relevant to cross, all targets emitted are the targets that actually has been setup for the project. i.e not every tier 1 and tier 2 target are emitted, only targets in any tier, including custom targets when specified in a projects config, are emitted iff they are supported by cross or have been setup to work with cross in the project which cross-util has been executed from.

i.e

# Cross.toml
[target."my-custom-target.json"]
image = "my-image:latest"
build-std = false

[target.aarch64-apple-ios]
image = "aarch64-apple-ios-cross:local"

would output with cross-util list-targets --format-version=1 that the targets my-custom-target.json and aarch64-apple-ios are a target. See https://docs.rust-embedded.org/embedonomicon/custom-target.html

If we go with JSON, then I would like to see all cross data models exported as a stable Rust library. The current policy treats only the CLI as stable. Until the data models and schemas (e.g., the entire Cross.toml schema) enter a stable library, I would actually prefer to see non-JSON in cross CLI tool output.

That's the entire reason behind --format-version 1, we are guaranteeing that if you use --format-version 1 you'll get the same object/schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

request: CLI flag to list tier 1 & 2 target triples
2 participants