-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add new tool for dumping feature status based on tidy #135662
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c22f569
Add new tool for dumping feature status based on tidy
yaahc b7d2d1f
format files
yaahc a5e5453
features-status-dump: pass key paths via cli flags + misc changes
jieyouxu a542953
bootstrap: register `features-status-dump` as runnable tool
jieyouxu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "features-status-dump" | ||
version = "0.1.0" | ||
license = "MIT OR Apache-2.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = { version = "1", features = ["backtrace"] } | ||
clap = { version = "4", features = ["derive"] } | ||
serde = { version = "1.0.125", features = [ "derive" ] } | ||
serde_json = "1.0.59" | ||
tidy = { path = "../tidy" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::collections::HashMap; | ||
use std::fs::File; | ||
use std::io::BufWriter; | ||
use std::path::PathBuf; | ||
|
||
use anyhow::{Context, Result}; | ||
use clap::Parser; | ||
use tidy::features::{Feature, collect_lang_features, collect_lib_features}; | ||
|
||
#[derive(Debug, Parser)] | ||
struct Cli { | ||
/// Path to `library/` directory. | ||
#[arg(long)] | ||
library_path: PathBuf, | ||
/// Path to `compiler/` directory. | ||
#[arg(long)] | ||
compiler_path: PathBuf, | ||
/// Path to `output/` directory. | ||
#[arg(long)] | ||
output_path: PathBuf, | ||
} | ||
|
||
#[derive(Debug, serde::Serialize)] | ||
struct FeaturesStatus { | ||
lang_features_status: HashMap<String, Feature>, | ||
lib_features_status: HashMap<String, Feature>, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let Cli { compiler_path, library_path, output_path } = Cli::parse(); | ||
|
||
let lang_features_status = collect_lang_features(&compiler_path, &mut false); | ||
let lib_features_status = collect_lib_features(&library_path) | ||
.into_iter() | ||
.filter(|&(ref name, _)| !lang_features_status.contains_key(name)) | ||
.collect(); | ||
let features_status = FeaturesStatus { lang_features_status, lib_features_status }; | ||
|
||
let output_dir = output_path.parent().with_context(|| { | ||
format!("failed to get parent dir of output path `{}`", output_path.display()) | ||
})?; | ||
std::fs::create_dir_all(output_dir).with_context(|| { | ||
format!("failed to create output directory at `{}`", output_dir.display()) | ||
})?; | ||
|
||
let output_file = File::create(&output_path).with_context(|| { | ||
format!("failed to create file at given output path `{}`", output_path.display()) | ||
})?; | ||
let writer = BufWriter::new(output_file); | ||
serde_json::to_writer_pretty(writer, &features_status) | ||
.context("failed to write json output")?; | ||
Ok(()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: should this be gated behind like a
build-metrics
cargo feature? I ask becausetidy
is built very often (many people have pre-push hooks that will run tidy) so build time is important.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ye I can totally do that, that sounds like a good idea to me.