Skip to content

Commit

Permalink
Build oak_debug_service with Bazel
Browse files Browse the repository at this point in the history
Build oak_debug_service with Bazel

BUG: 349587481
Change-Id: Iefac6a0e037994efafb452066809ddf62708ce5f
  • Loading branch information
dingelish committed Jul 2, 2024
1 parent 6852bb3 commit c3b78f0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
60 changes: 60 additions & 0 deletions oak_debug_service/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# 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_debug_service",
srcs = glob(["src/**"]),
deps = [
":build",
"@oak_crates_index//:pprof",
"@oak_crates_index//:prost",
"@oak_crates_index//:prost-types",
"@oak_crates_index//:tokio",
"@oak_crates_index//:tonic",
],
)

cargo_build_script(
name = "build",
srcs = [
"build.rs",
],
build_script_env = {
"PROTOC": "$(execpath @com_google_protobuf//:protoc)",
# Needed by `oak_proto_build_utils::get_common_proto_path`
"DESCRIPTOR_PROTO_PATH": "$(location @com_google_protobuf//:descriptor_proto_srcs)",
},
crate_features = ["bazel"],
data = [
"//proto/oak_debug/service:oak_debug_proto",
"@com_google_protobuf//:descriptor_proto_srcs",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:protoc",
"@com_google_protobuf//:well_known_type_protos",
],
deps = [
"//oak_grpc_utils",
"//oak_proto_build_utils",
],
)
8 changes: 7 additions & 1 deletion oak_debug_service/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ use oak_grpc_utils::{generate_grpc_code, CodegenOptions};

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for exchanging messages with clients.
#[cfg(not(feature = "bazel"))]
let included_protos = vec![std::path::PathBuf::from("..")];
#[cfg(feature = "bazel")]
let included_protos = oak_proto_build_utils::get_common_proto_path();

// Generate gRPC code for Orchestrator services.
generate_grpc_code(
&["../proto/oak_debug/service/oak_debug.proto"],
&[".."],
&included_protos,
CodegenOptions { build_server: true, ..Default::default() },
)?;

Expand Down

0 comments on commit c3b78f0

Please sign in to comment.