Skip to content

Commit

Permalink
Build oak_containers_sdk with bazel
Browse files Browse the repository at this point in the history
Fixed: 342280628

Change-Id: I8a8016e3fa78a5e307a7bcef8ad203b0125e75d4
  • Loading branch information
jblebrun committed May 23, 2024
1 parent ecaad4c commit 04e524d
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ dependencies = [
"tokio-util",
"tonic",
"tonic-build",
"tower",
"uart_16550",
"virtio-drivers",
"walkdir",
Expand Down Expand Up @@ -2595,6 +2596,7 @@ version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
"log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
Expand Down
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ crates_repository(
"tokio-util": crate.spec(version = "*"),
"tonic": crate.spec(version = "*"),
"tonic-build": crate.spec(version = "*"),
"tower": crate.spec(version = "*"),
"uart_16550": crate.spec(version = "*"),
"virtio-drivers": crate.spec(version = "*"),
"walkdir": crate.spec(version = "*"),
Expand Down
14 changes: 13 additions & 1 deletion cargo-bazel-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "452f3d48019e281e163f2eedbe30f2a65c93d237850779ef9383209df1373d78",
"checksum": "cf72206d8060287b076fedaeccc63131ecb47e453b310a56cb0a4c11f1900455",
"crates": {
"acpi 5.0.0": {
"name": "acpi",
Expand Down Expand Up @@ -4547,6 +4547,10 @@
"id": "tonic-build 0.11.0",
"target": "tonic_build"
},
{
"id": "tower 0.4.13",
"target": "tower"
},
{
"id": "uart_16550 0.3.0",
"target": "uart_16550"
Expand Down Expand Up @@ -15768,12 +15772,14 @@
"__common",
"balance",
"buffer",
"default",
"discover",
"futures-core",
"futures-util",
"indexmap",
"limit",
"load",
"log",
"make",
"pin-project",
"pin-project-lite",
Expand Down Expand Up @@ -15959,13 +15965,18 @@
"common": [
"attributes",
"default",
"log",
"std",
"tracing-attributes"
],
"selects": {}
},
"deps": {
"common": [
{
"id": "log 0.4.21",
"target": "log"
},
{
"id": "pin-project-lite 0.2.14",
"target": "pin_project_lite"
Expand Down Expand Up @@ -19360,6 +19371,7 @@
"tokio-util 0.7.11",
"tonic 0.11.0",
"tonic-build 0.11.0",
"tower 0.4.13",
"uart_16550 0.3.0",
"virtio-drivers 0.7.1",
"walkdir 2.5.0",
Expand Down
70 changes: 70 additions & 0 deletions oak_containers_sdk/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# 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//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_library")

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

rust_library(
name = "oak_containers_sdk",
srcs = [
"src/crypto.rs",
"src/lib.rs",
"src/orchestrator_client.rs",
],
proc_macro_deps = [
"@oak_crates_index//:async-trait",
],
deps = [
":build",
"//oak_attestation",
"//oak_crypto",
"//oak_proto_rust",
"@oak_crates_index//:anyhow",
"@oak_crates_index//:prost",
"@oak_crates_index//:prost-types",
"@oak_crates_index//:tokio",
"@oak_crates_index//:tokio-stream",
"@oak_crates_index//:tonic",
"@oak_crates_index//:tower",
],
)

cargo_build_script(
name = "build",
srcs = [
"build.rs",
],
build_script_env = {
"PROTOC": "$(execpath @com_google_protobuf//:protoc)",
},
crate_features = ["bazel"],
data = [
"//proto/containers:interfaces_proto",
"//proto/containers:orchestrator_crypto_proto",
"//proto/crypto:crypto_proto",
"//proto/session:messages_proto",
"@com_google_protobuf//:protoc",
],
deps = [
"//oak_grpc_utils",
"@oak_crates_index//:prost-build",
],
)
2 changes: 1 addition & 1 deletion oak_containers_sdk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"../proto/session/messages.proto",
"../proto/containers/orchestrator_crypto.proto",
],
&[".."],
&["..", "../external/com_google_protobuf/src/google/protobuf/_virtual_imports/empty_proto"],
CodegenOptions { build_client: true, ..Default::default() },
)?;

Expand Down

0 comments on commit 04e524d

Please sign in to comment.