Skip to content

Commit

Permalink
Bazelify crates
Browse files Browse the repository at this point in the history
Update Rust version

Unwrap error manually as I could not figure out how to make anyhow
context work within 5 minutes of trying.

Bug: 349587439
Bug: 349587501
Change-Id: Ief79be5f9ed2eca8aa4a2e82d5a62d52d6f908ac
  • Loading branch information
tiziano88 committed Jul 4, 2024
1 parent f763693 commit 7df2e40
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 13 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo_no_std.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ dependencies = [
"hkdf",
"hpke",
"log",
"maplit",
"p256",
"pkcs8",
"primeorder",
Expand Down Expand Up @@ -553,6 +554,12 @@ version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"

[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"

[[package]]
name = "opaque-debug"
version = "0.3.1"
Expand Down
2 changes: 1 addition & 1 deletion bazel/crates/oak_crates_index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
#
"""
Defines the no_std crates repository.
Defines the std crates repository.
After being defined, it should be loaded using:
load("@oak_crates_index//:defs.bzl", oak_crate_repositories = "crate_repositories")
Expand Down
4 changes: 4 additions & 0 deletions bazel/crates/oak_no_std_crates_index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def oak_no_std_crates_index(cargo_lockfile, lockfile):
features = [],
version = "*",
),
"maplit": crate.spec(
features = [],
version = "*",
),
"p256": crate.spec(
default_features = False,
features = [
Expand Down
46 changes: 45 additions & 1 deletion cargo-no-std-bazel-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "042c964203d897aec6bb490e61ab62d9385669207bd03993bc7c36a169556cc7",
"checksum": "8067eab2b6523b268748a8ef5c70a84c1e174a05ce66217c98cf679826c59bc0",
"crates": {
"acpi 5.0.0": {
"name": "acpi",
Expand Down Expand Up @@ -1976,6 +1976,10 @@
"id": "log 0.4.21",
"target": "log"
},
{
"id": "maplit 1.0.2",
"target": "maplit"
},
{
"id": "p256 0.13.2",
"target": "p256"
Expand Down Expand Up @@ -3314,6 +3318,45 @@
],
"license_file": "LICENSE-APACHE"
},
"maplit 1.0.2": {
"name": "maplit",
"version": "1.0.2",
"package_url": "https://github.com/bluss/maplit",
"repository": {
"Http": {
"url": "https://static.crates.io/crates/maplit/1.0.2/download",
"sha256": "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
}
},
"targets": [
{
"Library": {
"crate_name": "maplit",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"include": [
"**/*.rs"
]
}
}
}
],
"library_target_name": "maplit",
"common_attrs": {
"compile_data_glob": [
"**"
],
"edition": "2015",
"version": "1.0.2"
},
"license": "MIT/Apache-2.0",
"license_ids": [
"Apache-2.0",
"MIT"
],
"license_file": "LICENSE-APACHE"
},
"opaque-debug 0.3.1": {
"name": "opaque-debug",
"version": "0.3.1",
Expand Down Expand Up @@ -6148,6 +6191,7 @@
"hkdf 0.12.4",
"hpke 0.11.0",
"log 0.4.21",
"maplit 1.0.2",
"p256 0.13.2",
"pkcs8 0.10.2",
"primeorder 0.13.6",
Expand Down
36 changes: 36 additions & 0 deletions oak_functions_sdk/tests/lookup_module/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_shared_library")

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

exports_files(["README.md"])

rust_shared_library(
name = "lookup_module",
srcs = glob(["src/*.rs"]),
platform = "//:wasm32-unknown-unknown",
deps = [
"//oak_functions_abi",
"//oak_functions_sdk",
"@oak_no_std_crates_index//:anyhow",
"@oak_no_std_crates_index//:maplit",
],
)
1 change: 0 additions & 1 deletion oak_functions_sdk/tests/lookup_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
anyhow = "*"
maplit = "*"
assert_matches = "*"
oak_functions_abi = { path = "../../../oak_functions_abi" }
oak_functions_sdk = { path = "../../../oak_functions_sdk" }
9 changes: 6 additions & 3 deletions oak_functions_sdk/tests/lookup_module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

//! Oak Functions ABI test.

#![feature(assert_matches)]

use core::assert_matches::assert_matches;
use std::collections::HashMap;

use anyhow::{anyhow, Context};
use assert_matches::assert_matches;
use anyhow::anyhow;
use maplit::hashmap;

type TestFn = fn(&str) -> ();
Expand All @@ -46,7 +48,8 @@ impl TestManager<'static> {
fn run_test(&self) -> anyhow::Result<()> {
let request = oak_functions_sdk::read_request()
.map_err(|error| anyhow!("couldn't read request: {:?}", error))?;
let test_name = String::from_utf8(request).context("couldn't parse request")?;
let test_name = String::from_utf8(request)
.map_err(|err| anyhow::anyhow!("couldn't parse request: {err}"))?;
let test = self
.tests
.get(&test_name as &str)
Expand Down
34 changes: 34 additions & 0 deletions oak_functions_sdk/tests/testing_module/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# 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_shared_library")

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

exports_files(["README.md"])

rust_shared_library(
name = "testing_module",
srcs = glob(["src/*.rs"]),
platform = "//:wasm32-unknown-unknown",
deps = [
"//oak_functions_abi",
"//oak_functions_sdk",
],
)

0 comments on commit 7df2e40

Please sign in to comment.