Skip to content

Commit

Permalink
Bazelify crates
Browse files Browse the repository at this point in the history
Bug: 349587436
Bug: 349587509
Change-Id: I7cbede8c6e2854c8628075d3367481a164b7f50b
  • Loading branch information
tiziano88 committed Jul 3, 2024
1 parent 9acdd5e commit ae50d2d
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 1 deletion.
6 changes: 6 additions & 0 deletions bazel/crates/oak_crates_index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def oak_crates_index(cargo_lockfile, lockfile):
version = "*",
deps = ["@jemalloc"],
)],
# Enable `tokio_unstable` so that we can access the Tokio runtime metrics.
"tokio": [crate.annotation(
rustc_flags = ["--cfg=tokio_unstable"],
)],
},
cargo_lockfile = cargo_lockfile, # In Cargo-free mode this is used as output, not input.
lockfile = lockfile, # Shares most contents with cargo_lockfile.
Expand Down Expand Up @@ -373,9 +377,11 @@ def oak_crates_index(cargo_lockfile, lockfile):
"net",
"parking_lot",
"process",
"rt",
"rt-multi-thread",
"signal",
"sync",
"time",
],
version = "*",
),
Expand Down
8 changes: 7 additions & 1 deletion cargo-bazel-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "c4be2749e541c67a98fce81c31388468fc37a4113e0abc002e9ba5f8d661f680",
"checksum": "29000e1cc506207f10f6725fdfd827400c9e64d2df09af5681b12f77c9a8413b",
"crates": {
"acpi 5.0.0": {
"name": "acpi",
Expand Down Expand Up @@ -23877,6 +23877,12 @@
],
"selects": {}
},
"rustc_flags": {
"common": [
"--cfg=tokio_unstable"
],
"selects": {}
},
"version": "1.37.0"
},
"license": "MIT",
Expand Down
66 changes: 66 additions & 0 deletions oak_containers_agent/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# Copyright 2024 The Project Oak Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")

package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)

exports_files(["README.md"])

rust_library(
name = "lib",
srcs = glob(
["src/**"],
exclude = ["src/main.rs"],
),
compile_data = [":README.md"],
crate_name = "oak_containers_agent",
deps = [
"@oak_crates_index//:anyhow",
"@oak_crates_index//:http",
"@oak_crates_index//:nix",
"@oak_crates_index//:opentelemetry",
"@oak_crates_index//:opentelemetry-otlp",
"@oak_crates_index//:opentelemetry_sdk",
"@oak_crates_index//:procfs",
"@oak_crates_index//:tokio",
"@oak_crates_index//:tokio-stream",
"@oak_crates_index//:tonic",
"@oak_crates_index//:tower",
],
)

rust_binary(
name = "oak_containers_agent",
srcs = ["src/main.rs"],
compile_data = [":README.md"],
deps = [
":lib",
"@oak_crates_index//:anyhow",
"@oak_crates_index//:clap",
"@oak_crates_index//:http",
"@oak_crates_index//:nix",
"@oak_crates_index//:opentelemetry",
"@oak_crates_index//:opentelemetry-otlp",
"@oak_crates_index//:opentelemetry_sdk",
"@oak_crates_index//:procfs",
"@oak_crates_index//:tokio",
"@oak_crates_index//:tower",
],
)
36 changes: 36 additions & 0 deletions oak_hello_world_linux_init/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright 2024 The Project Oak Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

load("@rules_rust//rust:defs.bzl", "rust_binary")

package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)

exports_files(["README.md"])

rust_binary(
name = "oak_hello_world_linux_init",
srcs = glob(["src/**"]),
compile_data = [":README.md"],
deps = [
"@oak_crates_index//:anyhow",
"@oak_crates_index//:log",
"@oak_crates_index//:nix",
"@oak_crates_index//:simple_logger",
],
)

0 comments on commit ae50d2d

Please sign in to comment.