Skip to content

Commit

Permalink
Manage dependency versions at workspace level
Browse files Browse the repository at this point in the history
I want to move crates around and this makes it easier.

This is done for all media-sound/cras_rust crates except rust_common,
which needs to build with media-sound/cras-client when out of
the workspace context.

BUG=b:372902037
TEST=bazel test //... && cros_sdk FEATURES=test emerge-amd64-generic cras_rust

Change-Id: I3c8ef709536d1a036d1800ba988653a20912d8c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5919896
Reviewed-by: Cranel W <[email protected]>
Tested-by: [email protected] <[email protected]>
Commit-Queue: Li-Yu Yu <[email protected]>
  • Loading branch information
afq984 authored and Chromeos LUCI committed Oct 14, 2024
1 parent 1312285 commit 77d6095
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 87 deletions.
4 changes: 3 additions & 1 deletion Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "8e1fba18e7a570f96a487ac2bf11ff45d8f7938e5725799bb2f0773e737225b1",
"checksum": "e7f43a50b1b4d5e87a8a1ceefddafc6e61eec7f7550aef852de87ce3f8ef79f4",
"crates": {
"addr2line 0.20.0": {
"name": "addr2line",
Expand Down Expand Up @@ -5430,9 +5430,11 @@
"crate_features": {
"common": [
"default",
"fs",
"memoffset",
"process",
"resource",
"signal",
"socket",
"uio"
],
Expand Down
58 changes: 57 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ lto = true
panic = "abort"
overflow-checks = true

[patch.crates-io]
[workspace.dependencies]
# Local crates.
audio_processor = { path = "audio_processor" }
cras = { path = "cras/src/server/rust" }
cras_common = { path = "cras/common" }
Expand All @@ -28,6 +29,61 @@ cras_features_backend = { path = "cras/server/platform/features" }
cras_s2 = { path = "cras/server/s2" }
dsp_rust = { path = "cras/src/dsp/rust" }

# crates.io crates.
alsa-sys = "0.2.0"
anyhow = "1.0.75"
assert_matches = "1.5.0"
async-trait = "0.1.36"
bindgen = "0.63.0"
bitflags = { version = "2.4.0", features = ["serde"] }
cbindgen = "0.27.0"
cc = "1.0.73"
cfg-if = "1.0.0"
clap = { version = "4.5.4", features = ["derive"] }
command-fds = "0.3.0"
dasp_sample = "0.11.0"
dbus = { version = "0.9.0", features = ["futures"] }
dbus-tokio = "0.7.6"
either = "1.9.0"
fixedbitset = "0.4.2"
float-cmp = "0.9.0"
futures = "0.3.28"
getopts = "0.2.0"
getrandom = "0.2.7"
glob = "0.3.0"
hound = "3.5.0"
itertools = "0.11.0"
libc = "0.2.124"
log = "0.4.17"
nix = { version = "0.28.0", features = ["socket", "signal", "process", "fs", "resource", "uio"] }
num-traits = "0.2.15"
once_cell = "1.17.0"
openssl = "0.10.48"
proc-macro2 = "1.0.0"
protobuf = "3.2.0"
protobuf-codegen = "3.2.0"
protobuf-parse = "3.2.0"
quote = "1.0.0"
regex = "1.10.4"
remain = "0.2.1"
rustfft = "6.1.0"
serde = { version = "1.0.125", features = ["derive"] }
serde_json = "1.0.96"
serde_yaml = "0.8.11"
static_assertions = "1.1.0"
syn = "1.0.0"
syslog = "6.0.1"
tempfile = "3.4.0"
thiserror = "1.0.30"
tokio = { version = "1.19.2", features = ["rt-multi-thread", "net", "time", "rt"] }
zerocopy = "0.7.32"

# ChromiumOS crates
system_api = "*" # provided by ebuild
featured = "*" # provided by ebuild
minijail = "*" # provided by ebuild

[patch.crates-io]
# When building out of ChromiumOS, we do not actually use system_api.
# Stub it to avoid downloading the platform2 repository.
# See also: https://github.com/rust-lang/cargo/issues/4544
Expand Down
38 changes: 19 additions & 19 deletions audio_processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ authors = ["The ChromiumOS Authors"]
bazel = []

[dependencies]
anyhow = "1.0.70"
assert_matches = "1.5.0"
clap = { version = "4.5.4", features = ["derive"] }
command-fds = "0.3.0"
dasp_sample = "0.11.0"
hound = "3.4.0"
libc = "0.2.124"
nix = { version = "0.28.0", features = ["resource", "socket", "uio"] }
serde = { version = "1.0.52", features = ["derive"]}
serde_json = "1.0.96"
thiserror = "1.0.30"
log = "0.4.17"
protobuf = "3.2.0"
zerocopy = "0.7.32"
anyhow = { workspace = true }
assert_matches = { workspace = true }
clap = { workspace = true }
command-fds = { workspace = true }
dasp_sample = { workspace = true }
hound = { workspace = true }
libc = { workspace = true }
nix = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
log = { workspace = true }
protobuf = { workspace = true }
zerocopy = { workspace = true }

[build-dependencies]
bindgen = "0.63.0"
cc = "1.0.73"
protobuf-codegen = "3.2.0"
protobuf-parse = "3.2.0"
bindgen = { workspace = true }
cc = { workspace = true }
protobuf-codegen = { workspace = true }
protobuf-parse = { workspace = true }

[dev-dependencies]
tempfile = "3.4.0"
tempfile = { workspace = true }
22 changes: 11 additions & 11 deletions cras/server/platform/dlc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ authors = ["The ChromiumOS Authors"]
edition = "2021"

[dependencies]
anyhow = "1.0.32"
cras_common = "*"
cras_s2 = "*"
dbus = "0.9"
libc = "0.2.44"
log = "0.4.17"
once_cell = "1.17.0"
protobuf = "3.2"
static_assertions = "1.1.0"
system_api = { version = "*", optional = true }
thiserror = "1.0.20"
anyhow = { workspace = true }
cras_common = { workspace = true }
cras_s2 = { workspace = true }
dbus = { workspace = true }
libc = { workspace = true }
log = { workspace = true }
once_cell = { workspace = true }
protobuf = { workspace = true }
static_assertions = { workspace = true }
system_api = { workspace = true, optional = true }
thiserror = { workspace = true }

[features]
dlc = ["system_api"]
26 changes: 13 additions & 13 deletions cras/server/platform/features/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ authors = ["The ChromiumOS Authors"]
edition = "2021"

[dependencies]
anyhow = "1.0.32"
cfg-if = "1.0.0"
dbus = { version = "0.9", features = ["futures"] }
dbus-tokio = "0.7.6"
featured = { version = "*", optional = true } # provided by ebuild
fixedbitset = "0.4.2"
futures = "0.3.28"
libc = "0.2.124"
log = "0.4.17"
once_cell = "1.17.0"
tokio = { version = "1.19.2", features = ["rt", "net", "time", "rt-multi-thread"]}
anyhow = { workspace = true }
cfg-if = { workspace = true }
dbus = { workspace = true }
dbus-tokio = { workspace = true }
featured = { workspace = true, optional = true }
fixedbitset = { workspace = true }
futures = { workspace = true }
libc = { workspace = true }
log = { workspace = true }
once_cell = { workspace = true }
tokio = { workspace = true }

[build-dependencies]
bindgen = "0.63.0"
regex = "1.6.0"
bindgen = { workspace = true }
regex = { workspace = true }

[features]
chromiumos = ["featured"]
16 changes: 8 additions & 8 deletions cras/server/s2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
audio_processor = "*"
cras_common = "*"
audio_processor = { workspace = true }
cras_common = { workspace = true }

anyhow = "1.0.75"
libc = "0.2.44"
log = "0.4.17"
once_cell = "1.17.0"
serde = { version = "1.0.52", features = ["derive"]}
serde_json = "1.0.96"
anyhow = { workspace = true }
libc = { workspace = true }
log = { workspace = true }
once_cell = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
12 changes: 6 additions & 6 deletions cras/src/dsp/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ authors = ["The Chromium OS Authors"]
edition = "2021"

[dependencies]
anyhow = "1.0.75"
float-cmp = "0.9.0"
libc = "0.2"
nix = "0.28.0"
num-traits = "0.2.15"
itertools = "0.11.0"
anyhow = { workspace = true }
float-cmp = { workspace = true }
libc = { workspace = true }
nix = { workspace = true }
num-traits = { workspace = true }
itertools = { workspace = true }
28 changes: 14 additions & 14 deletions cras/src/server/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ authors = ["The ChromiumOS Authors"]
edition = "2021"

[dependencies]
anyhow = "1.0.68"
hound = "3.5.0"
libc = "0.2.44"
log = "0.4.17"
protobuf = "3.2.0"
anyhow = { workspace = true }
hound = { workspace = true }
libc = { workspace = true }
log = { workspace = true }
protobuf = { workspace = true }

cras_common = "*"
cras_dlc = "*"
dsp_rust = "*"
audio_processor = "*"
cras_features_backend = "*"
cras_s2 = "*"
minijail = { version = "*", optional = true } # provided by ebuild
cras_common = { workspace = true }
cras_dlc = { workspace = true }
dsp_rust = { workspace = true }
audio_processor = { workspace = true }
cras_features_backend = { workspace = true }
cras_s2 = { workspace = true }
minijail = { workspace = true, optional = true }

[build-dependencies]
protobuf-codegen = "3.2.0"
protobuf-parse = "3.2.0"
protobuf-codegen = { workspace = true }
protobuf-parse = { workspace = true }

[features]
chromiumos = ["minijail"]
2 changes: 1 addition & 1 deletion cras/src/server/rust/staticlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
crate-type = ["staticlib"]

[dependencies]
cras = { version = "*" }
cras = { workspace = true }
8 changes: 7 additions & 1 deletion devtools/cargo_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ def render(self):
with open(path, encoding='utf-8') as file:
manifest = toml.load(path)
for section, items in manifest.items():
# For [workspace.dependencies].
if section == 'workspace' and 'dependencies' in items:
section = 'dependencies'
items = items['dependencies']

# Merge all [dependencies], [dev-dependencies], etc.
# For the purposes of src/third_party/rust_crates vendoring, the differences
# between the dependency types do not matter.
if section.endswith('dependencies'):
for name, spec in items.items():
if spec == '*' or (
isinstance(spec, dict) and (spec.get('version') == '*' or 'path' in spec)
isinstance(spec, dict)
and (spec.get('workspace') or spec.get('version') == '*' or 'path' in spec)
):
continue
s = Spec.parse(spec)
Expand Down
10 changes: 5 additions & 5 deletions rock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"
authors = ["The ChromiumOS Authors"]

[dependencies]
audio_processor = "*"
anyhow = "1.0.75"
clap = { version = "4.5.4", features = ["derive"] }
hound = "3.5.0"
rustfft = "6.1.0"
audio_processor = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true }
hound = { workspace = true }
rustfft = { workspace = true }
4 changes: 2 additions & 2 deletions rules/cbindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cbindgen = "0.27"
clap = { version = "4.5.4", features = ["derive"] }
cbindgen = { workspace = true }
clap = { workspace = true }
10 changes: 5 additions & 5 deletions sof_helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["The ChromiumOS Authors"]
edition = "2021"

[dependencies]
anyhow = "1.0.68"
clap = { version = "4.5.4", features = ["derive"]}
regex = "1.10.4"
serde = { version = "1.0.52", features = ["derive"]}
serde_json = "1.0.96"
anyhow = { workspace = true }
clap = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }

0 comments on commit 77d6095

Please sign in to comment.