forked from mirrors/jj
buck: unify cargo deps with reindeer deps
This includes a very simple script to do the synchronization between the workspace Cargo file and the Buck2-specific Cargo file, automatically. Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
parent
d295c3d447
commit
0e53927e97
6 changed files with 13089 additions and 16 deletions
2
.github/workflows/codespell.yml
vendored
2
.github/workflows/codespell.yml
vendored
|
@ -18,5 +18,5 @@ jobs:
|
|||
with:
|
||||
check_filenames: true
|
||||
check_hidden: true
|
||||
skip: ./target,./.jj,*.lock
|
||||
skip: ./target,./.jj,*.lock,./buck/third-party/rust/BUILD
|
||||
ignore_words_list: crate,NotIn
|
||||
|
|
9224
buck/third-party/rust/BUILD
vendored
9224
buck/third-party/rust/BUILD
vendored
File diff suppressed because it is too large
Load diff
3693
buck/third-party/rust/Cargo.lock
generated
vendored
3693
buck/third-party/rust/Cargo.lock
generated
vendored
File diff suppressed because it is too large
Load diff
81
buck/third-party/rust/Cargo.toml
vendored
81
buck/third-party/rust/Cargo.toml
vendored
|
@ -1,3 +1,4 @@
|
|||
# @generated by buck/third-party/rust/synchronize.py
|
||||
[workspace]
|
||||
|
||||
[package]
|
||||
|
@ -12,4 +13,84 @@ name = "top"
|
|||
path = "top.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
assert_cmd = "2.0.8"
|
||||
assert_matches = "1.5.0"
|
||||
async-trait = "0.1.82"
|
||||
backoff = "0.4.0"
|
||||
blake2 = "0.10.6"
|
||||
bstr = "1.10.0"
|
||||
clap = { version = "4.5.16", features = [ "derive", "deprecated", "wrap_help", "string" ] }
|
||||
clap_complete = "4.5.24"
|
||||
clap_complete_nushell = "4.5.3"
|
||||
clap-markdown = "0.1.4"
|
||||
clap_mangen = "0.2.10"
|
||||
chrono = { version = "0.4.38", default-features = false, features = [ "std", "clock" ] }
|
||||
chrono-english = { version = "0.1.7" }
|
||||
clru = "0.6.2"
|
||||
config = { version = "0.13.4", default-features = false, features = [ "toml" ] }
|
||||
criterion = "0.5.1"
|
||||
crossterm = { version = "0.27", default-features = false }
|
||||
digest = "0.10.7"
|
||||
dirs = "5.0.1"
|
||||
dunce = "1.0.5"
|
||||
either = "1.13.0"
|
||||
esl01-renderdag = "0.3.0"
|
||||
futures = "0.3.30"
|
||||
git2 = { version = "0.19.0", features = [ "vendored-libgit2" ] }
|
||||
gix = { version = "0.66.0", default-features = false, features = [ "index", "max-performance-safe", "blob-diff" ] }
|
||||
gix-filter = "0.13.0"
|
||||
glob = "0.3.1"
|
||||
hex = "0.4.3"
|
||||
ignore = "0.4.20"
|
||||
indexmap = "2.5.0"
|
||||
indoc = "2.0.4"
|
||||
insta = { version = "1.39.0", features = [ "filters" ] }
|
||||
itertools = "0.13.0"
|
||||
libc = { version = "0.2.158" }
|
||||
maplit = "1.0.2"
|
||||
minus = { version = "5.6.1", features = [ "dynamic_output", "search" ] }
|
||||
num_cpus = "1.16.0"
|
||||
once_cell = "1.19.0"
|
||||
pest = "2.7.11"
|
||||
pest_derive = "2.7.11"
|
||||
pollster = "0.3.0"
|
||||
pretty_assertions = "1.4.0"
|
||||
proc-macro2 = "1.0.86"
|
||||
prost = "0.12.6"
|
||||
prost-build = "0.12.6"
|
||||
quote = "1.0.36"
|
||||
rand = "0.8.5"
|
||||
rand_chacha = "0.3.1"
|
||||
rayon = "1.10.0"
|
||||
ref-cast = "1.0.23"
|
||||
regex = "1.10.6"
|
||||
rpassword = "7.3.1"
|
||||
scm-record = "0.3.0"
|
||||
serde = { version = "1.0", features = [ "derive" ] }
|
||||
serde_json = "1.0.127"
|
||||
slab = "0.4.9"
|
||||
smallvec = { version = "1.13.2", features = [ "const_generics", "const_new", "union" ] }
|
||||
strsim = "0.11.1"
|
||||
syn = "2.0.77"
|
||||
tempfile = "3.12.0"
|
||||
test-case = "3.3.1"
|
||||
textwrap = "0.16.1"
|
||||
thiserror = "1.0.63"
|
||||
timeago = { version = "0.4.2", default-features = false }
|
||||
tokio = { version = "1.40.0" }
|
||||
toml_edit = { version = "0.19.15", features = [ "serde" ] }
|
||||
tracing = "0.1.40"
|
||||
tracing-chrome = "0.7.2"
|
||||
tracing-subscriber = { version = "0.3.18", default-features = false, features = [ "std", "ansi", "env-filter", "fmt" ] }
|
||||
unicode-width = "0.1.13"
|
||||
version_check = "0.9.5"
|
||||
watchman_client = { version = "0.9.0" }
|
||||
whoami = "1.5.2"
|
||||
zstd = "0.12.4"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
rustix = { version = "0.38.35", features = [ "fs" ] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winreg = "0.52"
|
||||
|
|
6
buck/third-party/rust/reindeer.toml
vendored
6
buck/third-party/rust/reindeer.toml
vendored
|
@ -31,5 +31,11 @@ alias(
|
|||
visibility = ["PUBLIC"],
|
||||
)
|
||||
|
||||
python_bootstrap_binary(
|
||||
name = 'sync.py',
|
||||
main = 'synchronize.py',
|
||||
visibility = [ 'PUBLIC' ],
|
||||
)
|
||||
|
||||
# XXX: normal reindeer-generated code below
|
||||
"""
|
||||
|
|
99
buck/third-party/rust/synchronize.py
vendored
Executable file
99
buck/third-party/rust/synchronize.py
vendored
Executable file
|
@ -0,0 +1,99 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# synchronize.py: sync workspace Cargo.toml with buck2/reindeer Cargo.toml
|
||||
|
||||
import subprocess
|
||||
import tomllib
|
||||
|
||||
# the workspace Cargo.toml file does not allow expressing conditional
|
||||
# dependencies, but it functions as the source of truth for all version data,
|
||||
# and if we want to update third-party//rust with correct platform-specific
|
||||
# dependencies, we need to parse it, then emit a valid version
|
||||
|
||||
WINDOWS_DEPS = [ 'winreg' ]
|
||||
UNIX_DEPS = [ 'rustix' ]
|
||||
|
||||
CARGO_TEMPLATE = """# @generated by buck/third-party/rust/synchronize.py
|
||||
[workspace]
|
||||
|
||||
[package]
|
||||
name = "rust-third-party"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
edition = "2021"
|
||||
|
||||
# Dummy target to keep Cargo happy
|
||||
[[bin]]
|
||||
name = "top"
|
||||
path = "top.rs"
|
||||
|
||||
"""
|
||||
|
||||
def format_dep(rhs) -> str:
|
||||
# if it's a string, just print it out
|
||||
if isinstance(rhs, str):
|
||||
return f'"{rhs}"'
|
||||
elif isinstance(rhs, bool):
|
||||
return f'{str(rhs).lower()}'
|
||||
# if it's a list, format it as a toml array
|
||||
elif isinstance(rhs, list):
|
||||
return f'[ {", ".join([f'"{x}"' for x in rhs])} ]'
|
||||
else:
|
||||
# format the dict as a toml dict manually
|
||||
return "{ " + ", ".join([f'{k} = {format_dep(v)}' for k, v in rhs.items()]) + " }"
|
||||
|
||||
def sync_cargo_deps():
|
||||
contents = CARGO_TEMPLATE
|
||||
with open ("Cargo.toml", "rb") as f:
|
||||
# parse the workspace Cargo.toml
|
||||
data = tomllib.load(f)
|
||||
deps = data["workspace"]["dependencies"]
|
||||
|
||||
# delete jj crates
|
||||
for bad in [ "jj-lib", "jj-lib-proc-macros", "testutils" ]:
|
||||
if bad in deps:
|
||||
del deps[bad]
|
||||
|
||||
contents += "[dependencies]\n"
|
||||
for x, v in deps.items():
|
||||
# some crates are only for one platform; we need to remove them and
|
||||
# handle it below
|
||||
if x in WINDOWS_DEPS or x in UNIX_DEPS:
|
||||
continue
|
||||
contents += f'{x} = {format_dep(v)}\n'
|
||||
|
||||
contents += ("\n[target.'cfg(unix)'.dependencies]\n")
|
||||
for x in UNIX_DEPS:
|
||||
contents += f'{x} = {format_dep(deps[x])}\n'
|
||||
|
||||
contents += ("\n[target.'cfg(windows)'.dependencies]\n")
|
||||
for x in WINDOWS_DEPS:
|
||||
contents += f'{x} = {format_dep(deps[x])}\n'
|
||||
|
||||
# now write the contents to buck/third-party/rust/Cargo.toml
|
||||
print("Writing new buck/third-party/rust/Cargo.toml")
|
||||
with open("buck/third-party/rust/Cargo.toml", "w") as f:
|
||||
f.write(contents)
|
||||
|
||||
# now run reindeer
|
||||
print("Now running 'reindeer' to regenerate BUILD files")
|
||||
cmd = [
|
||||
"./tools/bin/reindeer",
|
||||
"--third-party-dir",
|
||||
"buck/third-party/rust",
|
||||
"buckify",
|
||||
]
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
# Now run 'buck2 build' to make sure everything is up to date
|
||||
print("Now running 'buck2 build' to make sure everything works")
|
||||
cmd = [
|
||||
"buck2",
|
||||
"build",
|
||||
"@mode//debug",
|
||||
"third-party//rust",
|
||||
]
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
sync_cargo_deps()
|
Loading…
Reference in a new issue