From 9aed297536cfb910c2614ddafde8b3f23ad05a73 Mon Sep 17 00:00:00 2001 From: Jason LeBrun Date: Wed, 29 May 2024 01:01:20 +0000 Subject: [PATCH] Build oak_client with bazel Change-Id: Ia7289c4f2c7de54355485359dc105db858680635 --- Cargo.bazel.lock | 1 + WORKSPACE | 1 + cargo-bazel-lock.json | 8 ++++- oak_client/BUILD | 68 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 oak_client/BUILD diff --git a/Cargo.bazel.lock b/Cargo.bazel.lock index 94a95abe571..86601070f01 100644 --- a/Cargo.bazel.lock +++ b/Cargo.bazel.lock @@ -723,6 +723,7 @@ dependencies = [ "coset", "curve25519-dalek", "ecdsa", + "futures-util", "getrandom", "goblin", "hex", diff --git a/WORKSPACE b/WORKSPACE index 8256f8559fc..eb8289861ab 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -475,6 +475,7 @@ crates_repository( ], version = "*", ), + "futures-util": crate.spec(version = "*"), "getrandom": crate.spec( version = "*", ), diff --git a/cargo-bazel-lock.json b/cargo-bazel-lock.json index 3806dd13689..7ac8aeebd61 100644 --- a/cargo-bazel-lock.json +++ b/cargo-bazel-lock.json @@ -1,5 +1,5 @@ { - "checksum": "87666e043302a436f42f430e49d01477dc8bac0050d2afbab59f1c5e74216c93", + "checksum": "9872a2c4b34b30e31ccb5db846832f1a2642beec9fa9266f82f20c3db29bbf54", "crates": { "acpi 5.0.0": { "name": "acpi", @@ -4379,6 +4379,10 @@ "id": "ecdsa 0.16.9", "target": "ecdsa" }, + { + "id": "futures-util 0.3.30", + "target": "futures_util" + }, { "id": "getrandom 0.2.12", "target": "getrandom" @@ -5808,6 +5812,7 @@ "alloc", "async-await", "async-await-macro", + "default", "futures-macro", "futures-sink", "sink", @@ -19318,6 +19323,7 @@ "coset 0.3.7", "curve25519-dalek 4.1.1", "ecdsa 0.16.9", + "futures-util 0.3.30", "getrandom 0.2.12", "goblin 0.8.0", "hex 0.4.3", diff --git a/oak_client/BUILD b/oak_client/BUILD new file mode 100644 index 00000000000..a13a50189c0 --- /dev/null +++ b/oak_client/BUILD @@ -0,0 +1,68 @@ +# +# 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_client", + srcs = [ + "src/client.rs", + "src/lib.rs", + "src/transport.rs", + "src/verifier.rs", + ], + proc_macro_deps = [ + "@oak_crates_index//:async-trait", + ], + deps = [ + ":build", + "//oak_attestation_verification", + "//oak_crypto", + "//oak_proto_rust", + "@oak_crates_index//:anyhow", + "@oak_crates_index//:futures-util", + "@oak_crates_index//:prost", + "@oak_crates_index//:tonic", + ], +) + +cargo_build_script( + name = "build", + srcs = [ + "build.rs", + ], + build_script_env = { + "PROTOC": "$(execpath @com_google_protobuf//:protoc)", + }, + crate_features = ["bazel"], + data = [ + "//proto/session:messages_proto", + "//proto/session:service_streaming_proto", + ], + tools = [ + "@com_google_protobuf//:protoc", + ], + deps = [ + "//oak_grpc_utils", + "@oak_crates_index//:prost-build", + ], +)