Skip to content

Commit f926c19

Browse files
bazel: Replace crate extension with score-crates
1 parent 19548bc commit f926c19

File tree

5 files changed

+53
-31
lines changed

5 files changed

+53
-31
lines changed

MODULE.bazel

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,6 @@ bazel_dep(name = "score_process", version = "1.3.1")
101101
bazel_dep(name = "score_baselibs", version = "0.1.2")
102102

103103
## additional settings / config
104-
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
105-
crate.from_cargo(
106-
name = "score_persistency_crates",
107-
cargo_lockfile = "//:Cargo.lock",
108-
manifests = [
109-
"//:Cargo.toml",
110-
"//src/rust/rust_kvs:Cargo.toml",
111-
"//src/rust/rust_kvs_tool:Cargo.toml",
112-
"//tests/rust_test_scenarios:Cargo.toml",
113-
],
114-
)
115-
116104
bazel_dep(name = "rust_qnx8_toolchain", version = "1.0.0", dev_dependency = True)
117105
archive_override(
118106
module_name = "rust_qnx8_toolchain",
@@ -122,8 +110,6 @@ archive_override(
122110
],
123111
)
124112

125-
use_repo(crate, "score_persistency_crates")
126-
127113
## temporary overrides / tools
128114
# Testing utils dependency.
129115
# Direct usage of tag in git_override reports false problem in editor, using hash of a tag
@@ -190,3 +176,11 @@ register_toolchains(
190176
"@toolchains_qnx_ifs//:ifs_aarch64",
191177
dev_dependency = True,
192178
)
179+
180+
# S-CORE crates
181+
bazel_dep(name = "score_crates", version = "0.0.6")
182+
git_override(
183+
module_name = "score_crates",
184+
commit = "91fd7903f1219bbb4fa3890007eabe4dd512b3a8",
185+
remote = "https://github.com/eclipse-score/score-crates.git",
186+
)

src/rust/rust_kvs/BUILD

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
1313
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
14-
load("@score_persistency_crates//:defs.bzl", "all_crate_deps")
1514

1615
rust_library(
1716
name = "rust_kvs",
1817
srcs = glob(["src/**/*.rs"]),
1918
visibility = ["//visibility:public"],
20-
deps = all_crate_deps(
21-
normal = True,
22-
),
19+
deps = [
20+
"@score_crates//:adler32",
21+
"@score_crates//:tinyjson",
22+
],
2323
)
2424

2525
rust_test(
@@ -29,8 +29,5 @@ rust_test(
2929
"unit_tests",
3030
"ut",
3131
],
32-
deps = all_crate_deps(
33-
normal = True,
34-
normal_dev = True,
35-
),
32+
deps = ["@score_crates//:tempfile"],
3633
)

src/rust/rust_kvs_tool/BUILD

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
1313
load("@rules_rust//rust:defs.bzl", "rust_binary")
14-
load("@score_persistency_crates//:defs.bzl", "all_crate_deps")
1514

1615
rust_binary(
1716
name = "kvs_tool",
@@ -20,9 +19,9 @@ rust_binary(
2019
],
2120
crate_name = "rust_kvs_tool",
2221
visibility = ["//visibility:public"],
23-
deps = all_crate_deps(
24-
normal = True,
25-
) + [
22+
deps = [
2623
"//src/rust/rust_kvs",
24+
"@score_crates//:pico_args",
25+
"@score_crates//:tinyjson",
2726
],
2827
)

tests/rust_test_scenarios/BUILD

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
1313
load("@rules_rust//rust:defs.bzl", "rust_binary")
14-
load("@score_persistency_crates//:defs.bzl", "all_crate_deps")
1514

1615
rust_binary(
1716
name = "rust_test_scenarios",
@@ -20,6 +19,11 @@ rust_binary(
2019
deps =
2120
[
2221
"//src/rust/rust_kvs",
23-
"@score_persistency_crates//:tinyjson",
24-
] + all_crate_deps(normal = True),
22+
"@score_crates//:serde",
23+
"@score_crates//:serde_json",
24+
"@score_crates//:tinyjson",
25+
"@score_crates//:tracing",
26+
"@score_crates//:tracing_subscriber",
27+
"@score_test_scenarios//test_scenarios_rust",
28+
],
2529
)

tests/rust_test_scenarios/src/main.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,35 @@ mod helpers;
66
mod test_basic;
77
use crate::cit::cit_scenario_group;
88
use crate::test_basic::BasicScenario;
9+
use std::time::{SystemTime, UNIX_EPOCH};
10+
use tracing::Level;
11+
use tracing_subscriber::fmt::time::FormatTime;
12+
use tracing_subscriber::FmtSubscriber;
913

10-
fn main() {
14+
struct NumericUnixTime;
15+
16+
impl FormatTime for NumericUnixTime {
17+
fn format_time(&self, w: &mut tracing_subscriber::fmt::format::Writer<'_>) -> std::fmt::Result {
18+
let now = SystemTime::now()
19+
.duration_since(UNIX_EPOCH)
20+
.unwrap_or_default();
21+
write!(w, "{}", now.as_secs())
22+
}
23+
}
24+
25+
fn init_tracing_subscriber() {
26+
let subscriber = FmtSubscriber::builder()
27+
.with_max_level(Level::TRACE)
28+
.with_thread_ids(true)
29+
.with_timer(NumericUnixTime)
30+
.json()
31+
.finish();
32+
33+
tracing::subscriber::set_global_default(subscriber)
34+
.expect("Setting default subscriber failed!");
35+
}
36+
37+
fn main() -> Result<(), String> {
1138
let raw_arguments: Vec<String> = std::env::args().collect();
1239

1340
// Basic group.
@@ -29,6 +56,7 @@ fn main() {
2956
));
3057

3158
// Run.
59+
init_tracing_subscriber();
3260
let test_context = TestContext::new(root_group);
33-
run_cli_app(&raw_arguments, &test_context);
61+
run_cli_app(&raw_arguments, &test_context)
3462
}

0 commit comments

Comments
 (0)