Skip to content

Commit

Permalink
Move cras_processor out of cras/src/server/rust
Browse files Browse the repository at this point in the history
BUG=b:372902037
TEST=devtools/rust_generate.py
TEST=cargo build && SYSTEM_CRAS_RUST_LIB=$PWD/target/debug/libcras_rust.a bazel test --//:apm --//:system_cras_rust //...
TEST=bazel test --//:apm //...
TEST=FEATURES='test -usersandbox' emerge-amd64-generic cras_rust adhd
TEST=bazel run //cras/server/processor:processor_test

Change-Id: If509ca4356f421d7c82d2e184cb33cb56d95e47d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5922501
Reviewed-by: Hung-Hsien Chen <[email protected]>
Tested-by: Li-Yu Yu <[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 72d7854 commit 31f28a0
Show file tree
Hide file tree
Showing 21 changed files with 207 additions and 81 deletions.
115 changes: 80 additions & 35 deletions Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "e58a8c31f302eaa217b2af114fbc2f9d2d29d39fcbbf7f9359bc7ad807a2dac1",
"checksum": "e3af85829e49125de8a0e94f1307d882246338a08bb2c2f0e7c4fedfe9a6b66f",
"crates": {
"addr2line 0.20.0": {
"name": "addr2line",
Expand Down Expand Up @@ -1848,18 +1848,6 @@
]
}
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": false,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "cras",
Expand All @@ -1873,10 +1861,6 @@
"id": "anyhow 1.0.75",
"target": "anyhow"
},
{
"id": "cras 0.1.1",
"target": "build_script_build"
},
{
"id": "hound 3.5.0",
"target": "hound"
Expand All @@ -1899,24 +1883,6 @@
"edition": "2021",
"version": "0.1.1"
},
"build_script_attrs": {
"data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "protobuf-codegen 3.2.0",
"target": "protobuf_codegen"
},
{
"id": "protobuf-parse 3.2.0",
"target": "protobuf_parse"
}
],
"selects": {}
}
},
"license": null,
"license_ids": [],
"license_file": null
Expand Down Expand Up @@ -2262,6 +2228,84 @@
"license_ids": [],
"license_file": null
},
"cras_processor 0.1.0": {
"name": "cras_processor",
"version": "0.1.0",
"package_url": null,
"repository": null,
"targets": [
{
"Library": {
"crate_name": "cras_processor",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"include": [
"**/*.rs"
]
}
}
},
{
"BuildScript": {
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": false,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "cras_processor",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "anyhow 1.0.75",
"target": "anyhow"
},
{
"id": "cras_processor 0.1.0",
"target": "build_script_build"
},
{
"id": "log 0.4.20",
"target": "log"
},
{
"id": "protobuf 3.2.0",
"target": "protobuf"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.1.0"
},
"build_script_attrs": {
"data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "protobuf-codegen 3.2.0",
"target": "protobuf_codegen"
}
],
"selects": {}
}
},
"license": null,
"license_ids": [],
"license_file": null
},
"cras_rust 0.1.1": {
"name": "cras_rust",
"version": "0.1.1",
Expand Down Expand Up @@ -11609,6 +11653,7 @@
"cras_dlc 0.1.0": "cras/server/platform/dlc",
"cras_feature_tier 0.1.0": "cras/server/feature_tier",
"cras_features_backend 0.1.0": "cras/server/platform/features",
"cras_processor 0.1.0": "cras/server/processor",
"cras_rust 0.1.1": "cras/src/server/rust/staticlib",
"cras_s2 0.1.0": "cras/server/s2",
"dsp_rust 0.1.0": "cras/src/dsp/rust",
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"cras/server/feature_tier",
"cras/server/platform/dlc",
"cras/server/platform/features",
"cras/server/processor",
"cras/server/s2",
"cras/src/dsp/rust",
"cras/src/server/rust",
Expand All @@ -28,6 +29,7 @@ cras_common = { path = "cras/common" }
cras_dlc = { path = "cras/server/platform/dlc" }
cras_features_backend = { path = "cras/server/platform/features" }
cras_feature_tier = { path = "cras/server/feature_tier" }
cras_processor = { path = "cras/server/processor" }
cras_s2 = { path = "cras/server/s2" }
dsp_rust = { path = "cras/src/dsp/rust" }

Expand Down
1 change: 1 addition & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ crates_repository(
"//cras/server/feature_tier:Cargo.toml",
"//cras/server/platform/dlc:Cargo.toml",
"//cras/server/platform/features:Cargo.toml",
"//cras/server/processor:Cargo.toml",
"//cras/src/dsp/rust:Cargo.toml",
"//cras/src/server/rust:Cargo.toml",
"//cras/src/server/rust:staticlib/Cargo.toml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ WRITE_SOURCE_FILE_TARGETS = [
"@//cras/common:generate_rust_common_h",
"@//cras/server/feature_tier:generate_feature_tier_h",
"@//cras/server/platform/dlc:generate_dlc_h",
"@//cras/server/processor:generate_processor_h",
"@//cras/server/s2:generate_s2_h",
"@//cras/src/dsp/rust:generate_dsp.h",
"@//cras/src/server/rust:generate_cras_processor_h",
"@//cras/src/server/rust:generate_rate_estimator_h",
]
2 changes: 1 addition & 1 deletion cras/server/platform/dlc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cras_rust_library(
srcs = glob(include = ["src/*.rs"]),
crate_name = "cras_dlc",
visibility = [
"//cras/server/platform:__pkg__",
"//cras/server:__subpackages__",
"//cras/src/server/rust:__pkg__",
],
deps = all_crate_deps() + [
Expand Down
76 changes: 76 additions & 0 deletions cras/server/processor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2024 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

load("@crate_index//:defs.bzl", "all_crate_deps")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_test")
load("//:utils.bzl", "require_no_config")
load("//rules/cbindgen:rules.bzl", "cras_cbindgen")
load("//rules/rust:defs.bzl", "cras_rust_library")

cras_rust_library(
name = "processor",
srcs = glob(
include = ["src/**/*.rs"],
),
crate_name = "cras_processor",
edition = "2021",
visibility = ["//visibility:public"],
deps = all_crate_deps(normal = True) + [
"//audio_processor",
"//cras/server/s2",
"//cras/server/platform/dlc",
"//cras/common:rust_common",
":build_script",
],
)

rust_test(
name = "processor_test",
crate = ":processor",
target_compatible_with = require_no_config("//:system_cras_rust_build"),
)

cras_cbindgen(
name = "processor_h",
srcs = ["src/lib.rs"],
out = "processor.h",
copyright_year = 2024,
extra_args = [
"--with-include=audio_processor/c/plugin_processor.h",
"--with-include=cras/common/rust_common.h",
"--add-keyword-enum",
],
)

cc_library(
name = "cc",
hdrs = ["processor.h"],
visibility = ["//visibility:public"],
deps = [
":processor",
"//audio_processor/c:plugin_processor",
"//cras/common:rust_common_cc",
],
)

cc_test(
name = "cras_processor_test",
srcs = ["cras_processor_test.cc"],
deps = [
":cc",
"@pkg_config//gtest",
"@pkg_config//gtest_main",
],
)

cargo_build_script(
name = "build_script",
srcs = ["build.rs"],
data = [
"proto/cras_processor.proto",
],
deps = all_crate_deps(build = True),
)
17 changes: 17 additions & 0 deletions cras/server/processor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "cras_processor"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = { workspace = true }
log = { workspace = true }
protobuf = { workspace = true }

audio_processor = { workspace = true }
cras_common = { workspace = true }
cras_dlc = { workspace = true }
cras_s2 = { workspace = true }

[build-dependencies]
protobuf-codegen = { workspace = true }
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <vector>

#include "audio_processor/c/plugin_processor.h"
#include "cras/src/server/rust/include/cras_processor.h"
#include "cras/server/processor/processor.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The ChromiumOS Authors
// Copyright 2024 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -9,8 +9,8 @@
extern "C" {
#endif

#ifndef CRAS_SRC_SERVER_RUST_INCLUDE_CRAS_PROCESSOR_H_
#define CRAS_SRC_SERVER_RUST_INCLUDE_CRAS_PROCESSOR_H_
#ifndef CRAS_SERVER_PROCESSOR_PROCESSOR_H_
#define CRAS_SERVER_PROCESSOR_PROCESSOR_H_

#include <stdarg.h>
#include <stdbool.h>
Expand Down Expand Up @@ -59,7 +59,7 @@ struct CrasProcessorCreateResult cras_processor_create(const struct CrasProcesso
*/
bool cras_processor_is_override_enabled(void);

#endif /* CRAS_SRC_SERVER_RUST_INCLUDE_CRAS_PROCESSOR_H_ */
#endif /* CRAS_SERVER_PROCESSOR_PROCESSOR_H_ */

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use cras_dlc::get_dlc_state_cached;
use cras_s2::BEAMFORMING_CONFIG_PATH;

mod processor_override;
mod proto;

#[repr(C)]
#[derive(Clone, Debug)]
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions cras/src/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ cc_library(
"//cras/server:main_message",
"//cras/server/platform/dlc:cc",
"//cras/server/platform/features",
"//cras/server/processor:cc",
"//cras/server/s2:cc",
"//cras/src/common",
"//cras/src/dsp",
Expand Down
2 changes: 1 addition & 1 deletion cras/src/server/cras_stream_apm.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "cras/server/cras_thread.h"
#include "cras/server/main_message.h"
#include "cras/server/platform/features/features.h"
#include "cras/server/processor/processor.h"
#include "cras/server/s2/s2.h"
#include "cras/src/common/byte_buffer.h"
#include "cras/src/common/cras_string.h"
Expand All @@ -30,7 +31,6 @@
#include "cras/src/server/cras_system_state.h"
#include "cras/src/server/float_buffer.h"
#include "cras/src/server/iniparser_wrapper.h"
#include "cras/src/server/rust/include/cras_processor.h"
#include "cras_audio_format.h"
#include "third_party/utlist/utlist.h"
#include "webrtc_apm/webrtc_apm.h"
Expand Down
Loading

0 comments on commit 31f28a0

Please sign in to comment.