-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add --print target-spec-json-schema #144498
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
With this macro we only need to enumerate every variant once. This saves a lot of duplication already between the definition, the `FromStr` impl and the `ToJson` impl. It also enables us to do further things with it like JSON schema generation.
547cba8
to
d6acb28
Compare
This comment has been minimized.
This comment has been minimized.
d6acb28
to
8f1abd3
Compare
This comment has been minimized.
This comment has been minimized.
8f1abd3
to
a07cfd1
Compare
This comment has been minimized.
This comment has been minimized.
a07cfd1
to
d4383c1
Compare
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
Some changes occurred in compiler/rustc_codegen_ssa The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging. These commits modify the If this was unintentional then you should revert the changes before this PR is merged. These commits modify compiler targets. This PR modifies cc @jieyouxu There are changes to the cc @jieyouxu |
The MCP isn't accepted yet, but that doesn't need to stop anyone from reviewing. |
|
I can probably review it after the MCP passes. |
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.
Thanks, looks good to me overall, a few questions
@@ -361,6 +362,8 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ | |||
"rand_xorshift", // dependency for doc-tests in rustc_thread_pool | |||
"rand_xoshiro", | |||
"redox_syscall", | |||
"ref-cast", |
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.
Remark: at least this uses rustc version detection, not just nightly detection
https://github.com/dtolnay/ref-cast/blob/1.0.24/build.rs
None of them are blocking, so feel free to r=me once the MCP is accepted. |
d4383c1
to
1dfa421
Compare
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.
Looks good
@bors r=jieyouxu |
…youxu Add --print target-spec-json-schema This schema is helpful for people writing custom target spec JSON. It can provide autocomplete in the editor, and also serves as documentation when there are documentation comments on the structs, as `schemars` will put them in the schema. I was motivated to do this because I saw someone write their own version of this schema by hand, so demand for this clearly exists. It's not a lot of effort to implement, so I thought it would make sense. MCP: rust-lang/compiler-team#905 I think it would also be useful to put this in the sysroot in `etc` so people can link it directly in their editors. I would have loved to add a test that validates the JSON schema against the spec JSON of every builtin target, but I don't want to do it as the JSON schema validation crates have incredible amounts of dependencies because JSON schema supports a ton of random features. I don't want to add that, even as a dev dependency.
Rollup of 21 pull requests Successful merges: - #137831 (Tweak auto trait errors) - #138689 (add nvptx_target_feature) - #140267 (implement continue_ok and break_ok for ControlFlow) - #143679 (Preserve the .debug_gdb_scripts section) - #143857 (Port #[macro_export] to the new attribute parsing infrastructure) - #143929 (Mark all deprecation lints in name resolution as deny-by-default and report-in-deps) - #144133 (Stabilize const TypeId::of) - #144369 (Upgrade semicolon_in_expressions_from_macros from warn to deny) - #144473 (Address libunwind.a inconsistency issues in the bootstrap program) - #144498 (Add --print target-spec-json-schema) - #144552 (Rehome 33 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`) - #144659 (bootstrap: refactor mingw dist and fix gnullvm) - #144676 (Add documentation for unstable_feature_bound) - #144794 (Port `#[coroutine]` to the new attribute system) - #144835 (Anonymize binders in tail call sig) - #144836 (Change visibility of Args new function) - #144861 (Stabilize `panic_payload_as_str` feature) - #144910 (Add regression tests for seemingly fixed issues) - #144913 ([rustdoc] Fix wrong `i` tooltip icon) - #144917 (Enforce tail call type is related to body return type in borrowck) - #144924 (compiletest: add hint for when a ui test produces no errors) r? `@ghost` `@rustbot` modify labels: rollup
…youxu Add --print target-spec-json-schema This schema is helpful for people writing custom target spec JSON. It can provide autocomplete in the editor, and also serves as documentation when there are documentation comments on the structs, as `schemars` will put them in the schema. I was motivated to do this because I saw someone write their own version of this schema by hand, so demand for this clearly exists. It's not a lot of effort to implement, so I thought it would make sense. MCP: rust-lang/compiler-team#905 I think it would also be useful to put this in the sysroot in `etc` so people can link it directly in their editors. I would have loved to add a test that validates the JSON schema against the spec JSON of every builtin target, but I don't want to do it as the JSON schema validation crates have incredible amounts of dependencies because JSON schema supports a ton of random features. I don't want to add that, even as a dev dependency.
…youxu Add --print target-spec-json-schema This schema is helpful for people writing custom target spec JSON. It can provide autocomplete in the editor, and also serves as documentation when there are documentation comments on the structs, as `schemars` will put them in the schema. I was motivated to do this because I saw someone write their own version of this schema by hand, so demand for this clearly exists. It's not a lot of effort to implement, so I thought it would make sense. MCP: rust-lang/compiler-team#905 I think it would also be useful to put this in the sysroot in `etc` so people can link it directly in their editors. I would have loved to add a test that validates the JSON schema against the spec JSON of every builtin target, but I don't want to do it as the JSON schema validation crates have incredible amounts of dependencies because JSON schema supports a ton of random features. I don't want to add that, even as a dev dependency.
Still trying to track down #144995 (comment) @bors try jobs=dist-ohos-x86_64 |
Add --print target-spec-json-schema try-job: dist-ohos-x86_64
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed (CI). Failed jobs:
|
This PR seems to be the cause of the mysterious failure; probably something in the @bors r- |
wtf |
Might be worth trying some other dist jobs, in case the |
|
||
/// Copies the output of --print=target-spec-json-schema into etc. | ||
fn run(self, builder: &Builder<'_>) { | ||
let mut rustc = command(builder.rustc(self.compiler)).fail_fast(); |
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.
I'll need to check which compiler is used
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.
For a stage 2 cross build it would still need to use the stage 1 compiler since that's on the host, that might be the problem..
Could be because of cross compilation maybe, let's try a more linux job to confirm |
Add --print target-spec-json-schema try-job: dist-loongarch64-linux
💔 Test failed (CI). Failed jobs:
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
This schema is helpful for people writing custom target spec JSON. It can provide autocomplete in the editor, and also serves as documentation when there are documentation comments on the structs, as
schemars
will put them in the schema.I was motivated to do this because I saw someone write their own version of this schema by hand, so demand for this clearly exists. It's not a lot of effort to implement, so I thought it would make sense.
MCP: rust-lang/compiler-team#905
I think it would also be useful to put this in the sysroot in
etc
so people can link it directly in their editors.I would have loved to add a test that validates the JSON schema against the spec JSON of every builtin target, but I don't want to do it as the JSON schema validation crates have incredible amounts of dependencies because JSON schema supports a ton of random features. I don't want to add that, even as a dev dependency.