-
Notifications
You must be signed in to change notification settings - Fork 432
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
Split rust_library into smaller rules #591
Comments
Migration script I used to migrate rules_rust, kythe, and internal codebase. I apologize for poor engineering: #!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! duct = "0.13.5"
//! anyhow = "1.0.44"
//! ```
use duct::cmd;
use std::collections::BTreeSet;
fn main() -> anyhow::Result<()> {
let all_targets = cmd!("buildozer", "print label", "//...:*")
.read()?
.lines()
.map(|l| l.trim().to_owned())
.collect::<Vec<_>>();
let all_packages = all_targets
.iter()
.map(|lbl| format!("{}:__pkg__", lbl.split(':').next().unwrap()))
.collect::<BTreeSet<_>>();
let all_targets_with_crate_type = cmd!("buildozer", "print label crate_type", "//...:*")
.read()?
.lines()
.filter(|l| !l.contains("(missing)"))
.map(|l| l.split_once(' ').unwrap())
.map(|(a, b)| (a.to_string(), b.to_string()))
.collect::<Vec<_>>();
for (crate_type, rule) in [
("staticlib", "rust_static_library"),
("cdylib", "rust_shared_library"),
("proc-macro", "rust_proc_macro"),
] {
let targets_of_type = all_targets_with_crate_type
.iter()
.filter(|(label, ctype)| ctype == crate_type)
.map(|(label, _)| label)
.collect::<Vec<_>>();
cmd(
"buildozer",
vec![
"-k".to_string(),
format!("new_load @rules_rust//rust:defs.bzl {}", rule),
]
.iter()
.chain(targets_of_type.iter().cloned()),
)
.run()
.ok();
cmd(
"buildozer",
vec!["-k".to_string(), format!("set kind {}", rule)]
.iter()
.chain(targets_of_type),
)
.run()
.ok();
}
cmd(
"buildozer",
vec!["-k".to_string(), "remove crate_type".to_string()]
.iter()
.chain(all_targets_with_crate_type.iter().map(|(label, _)| label)),
)
.run()
.ok();
println!("########################### Moving package to top");
cmd(
"buildozer",
vec!["-k".to_string(), "fix movePackageToTop".to_string()]
.into_iter()
.chain(all_packages.iter().cloned()),
)
.run()
.ok();
println!("########################### Migrating from rust.bzl to defs.bzl");
for rule in [
"rust_library",
"rust_binary",
"rustfmt_test",
"rust_clippy",
"rust_test",
"rust_doc",
"rust_doc_test",
"rust_analyzer",
] {
cmd(
"buildozer",
vec![
"-k".to_string(),
format!("replace_load @rules_rust//rust:defs.bzl {}", rule),
]
.into_iter()
.chain(all_packages.iter().cloned()),
)
.run()
.ok();
}
println!("########################### Removing unused loads");
cmd(
"buildozer",
vec!["-k", "fix unusedLoads"]
.into_iter()
.chain(all_packages.iter().map(|a| a.as_str())),
)
.run()
.ok();
Ok(())
} |
FYI: Cargo-raze v0.13 is released and it produces BUILD files that are compatible with this breaking change. |
Status update: I believe this change was in the baking for long enough. I plan to flip the flag in the next couple of days, unless I'm told to wait :) |
Co-authored-by: Shahms King <[email protected]>
Migrate cxx for bazelbuild/rules_rust#591
This migrates tensorboard for bazelbuild/rules_rust#591
This migrates TensorBoard for bazelbuild/rules_rust#591
Rules rust has made some changes upstream that remove the rust.bzl file. It had previously been left in there for compatibility purposes. This has been ongoing since February 16th. See this issue for additional context: bazelbuild/rules_rust#591.
Rules rust has made some changes upstream that remove the rust.bzl file. It had previously been left in there for compatibility purposes. This has been ongoing since February 16th. See this issue for additional context: bazelbuild/rules_rust#591.
Rules rust has made some changes upstream that remove the rust.bzl file. It had previously been left in there for compatibility purposes. This has been ongoing since February 16th. See this issue for additional context: bazelbuild/rules_rust#591.
|
This migrates TensorBoard for bazelbuild/rules_rust#591
This migrates TensorBoard for bazelbuild/rules_rust#591
As socialized on https://groups.google.com/g/rules_rust/c/kGMg6haEF44, we're going to split
rust_library
into smaller rules. This is the tracking issue for the effort.Steps:
@rules_rust//rust:rust.bzl
in the repository to@rules_rust//rust:defs.bzl
The text was updated successfully, but these errors were encountered: