From 7177fdc252dc1735d6af7487d736b65585c7b1a2 Mon Sep 17 00:00:00 2001 From: William Lyles <26171886+wilyle@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:35:38 -0700 Subject: [PATCH] Retrieve and build protobuf from remote URLs (#158) Currently, Freyja is using cargo git dependencies to reference the proto packages from other ESDV projects such as Ibeji. This has caused compatibility issues and needs to be updated. This PR makes a change to pull the content from a remote URL and build the proto files within the Freyja repo. Inspired by UProtocol: https://github.com/eclipse-uprotocol/up-rust/blob/main/build.rs Also makes a minor update to the install instructions in the README, which required updating the markdown-ci workflow due to a recent regression in the tool that it uses (see https://github.com/tcort/markdown-link-check/issues/304) Fixes #157 --- .accepted_words.txt | 2 + .github/workflows/markdown-ci.yml | 2 +- Cargo.lock | 212 +++++++++++++++--- Cargo.toml | 14 +- README.md | 15 +- build_common/Cargo.toml | 4 +- build_common/src/lib.rs | 42 ++++ proto/core_protobuf_data_access/Cargo.toml | 18 ++ proto/core_protobuf_data_access/build.rs | 30 +++ proto/core_protobuf_data_access/src/lib.rs | 20 ++ proto/samples_protobuf_data_access/Cargo.toml | 17 ++ proto/samples_protobuf_data_access/build.rs | 20 ++ proto/samples_protobuf_data_access/src/lib.rs | 18 ++ proto/service_discovery_proto/Cargo.toml | 17 ++ proto/service_discovery_proto/build.rs | 17 ++ proto/service_discovery_proto/src/lib.rs | 12 + 16 files changed, 424 insertions(+), 36 deletions(-) create mode 100644 proto/core_protobuf_data_access/Cargo.toml create mode 100644 proto/core_protobuf_data_access/build.rs create mode 100644 proto/core_protobuf_data_access/src/lib.rs create mode 100644 proto/samples_protobuf_data_access/Cargo.toml create mode 100644 proto/samples_protobuf_data_access/build.rs create mode 100644 proto/samples_protobuf_data_access/src/lib.rs create mode 100644 proto/service_discovery_proto/Cargo.toml create mode 100644 proto/service_discovery_proto/build.rs create mode 100644 proto/service_discovery_proto/src/lib.rs diff --git a/.accepted_words.txt b/.accepted_words.txt index f2a87ef3..4b1f7700 100644 --- a/.accepted_words.txt +++ b/.accepted_words.txt @@ -33,6 +33,7 @@ ci cli CloudAdapter CloudConnector +cmake com CONFIG config @@ -72,6 +73,7 @@ Freyja Freyja's freyja Freyr +gcc genpkey github githubusercontent diff --git a/.github/workflows/markdown-ci.yml b/.github/workflows/markdown-ci.yml index fcc3c2da..50283ae1 100644 --- a/.github/workflows/markdown-ci.yml +++ b/.github/workflows/markdown-ci.yml @@ -27,5 +27,5 @@ jobs: steps: - uses: actions/checkout@v2 - run: | - npm install markdown-link-check + npm install markdown-link-check@3.11.2 find . -type d \( -name node_modules -o -name .github \) -prune -o -type f -name '*.md' -print0 | xargs -0 -n1 node_modules/.bin/markdown-link-check --config ./tools/.markdownlinkcheck.json --quiet \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b9a0b467..051e2e01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,7 +249,7 @@ dependencies = [ "prost-types", "time", "tonic", - "tonic-build 0.11.0", + "tonic-build", ] [[package]] @@ -328,14 +328,12 @@ dependencies = [ [[package]] name = "core-protobuf-data-access" version = "0.1.0" -source = "git+https://github.com/eclipse-ibeji/ibeji#1ac110a11a7586b0f4d9b22f554da67a6369e792" dependencies = [ + "freyja-build-common", "prost", "prost-types", "serde", - "tokio", "tonic", - "tonic-build 0.11.0", ] [[package]] @@ -347,6 +345,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.11" @@ -485,12 +492,31 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fragile" version = "2.0.0" @@ -526,6 +552,10 @@ dependencies = [ [[package]] name = "freyja-build-common" version = "0.1.0" +dependencies = [ + "tonic-build", + "ureq", +] [[package]] name = "freyja-common" @@ -881,6 +911,16 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "in-memory-mock-cloud-adapter" version = "0.1.0" @@ -1028,7 +1068,7 @@ dependencies = [ "prost", "prost-types", "tonic", - "tonic-build 0.11.0", + "tonic-build", ] [[package]] @@ -1537,6 +1577,21 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "ron" version = "0.8.1" @@ -1578,6 +1633,37 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" + +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -1610,15 +1696,12 @@ dependencies = [ [[package]] name = "samples-protobuf-data-access" -version = "1.0.0" -source = "git+https://github.com/eclipse-ibeji/ibeji#1ac110a11a7586b0f4d9b22f554da67a6369e792" +version = "0.1.0" dependencies = [ + "freyja-build-common", "prost", "prost-types", - "serde", - "tokio", "tonic", - "tonic-build 0.11.0", ] [[package]] @@ -1664,12 +1747,11 @@ dependencies = [ [[package]] name = "service_discovery_proto" version = "0.1.0" -source = "git+https://github.com/eclipse-chariott/chariott#8b3789bb4c377569df730c851928dd56d0123ec5" dependencies = [ + "freyja-build-common", "prost", - "tokio", + "prost-types", "tonic", - "tonic-build 0.10.2", ] [[package]] @@ -1702,6 +1784,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "strum_macros" version = "0.26.2" @@ -1715,6 +1803,12 @@ dependencies = [ "syn", ] +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "2.0.52" @@ -1798,6 +1892,21 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.36.0" @@ -1922,19 +2031,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tonic-build" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" -dependencies = [ - "prettyplease", - "proc-macro2", - "prost-build", - "quote", - "syn", -] - [[package]] name = "tonic-build" version = "0.11.0" @@ -2030,18 +2126,67 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "2.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" +dependencies = [ + "base64", + "flate2", + "log", + "once_cell", + "rustls", + "rustls-pki-types", + "rustls-webpki", + "url", + "webpki-roots", +] + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "utf8parse" version = "0.2.1" @@ -2084,6 +2229,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "which" version = "4.4.2" @@ -2245,3 +2399,9 @@ checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Cargo.toml b/Cargo.toml index a4dcadcc..8df37d28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,13 +25,17 @@ members = [ "mocks/mock_mapping_service", "proc_macros", "proto/cloud_connector", + "proto/core_protobuf_data_access", "proto/mapping_service", + "proto/samples_protobuf_data_access", + "proto/service_discovery_proto", "test_common", ] [workspace.dependencies] # Freyja libraries from this workspace cloud-connector-proto = { path = "proto/cloud_connector" } +core-protobuf-data-access = { path = "proto/core_protobuf_data_access" } file-service-discovery-adapter = { path = "adapters/service_discovery/file_service_discovery_adapter" } freyja-build-common = { path = "build_common" } freyja-common = { path = "common" } @@ -50,11 +54,8 @@ mock-digital-twin = { path = "mocks/mock_digital_twin" } mqtt-data-adapter = { path = "adapters/data/mqtt_data_adapter" } proc-macros = { path = "proc_macros" } sample-grpc-data-adapter = { path = "adapters/data/sample_grpc_data_adapter" } - -# Other SDV projects. Versioning is handled by the Cargo.lock file -core-protobuf-data-access = { git = "https://github.com/eclipse-ibeji/ibeji" } -samples-protobuf-data-access = { git = "https://github.com/eclipse-ibeji/ibeji" } -service_discovery_proto = { git = "https://github.com/eclipse-chariott/chariott" } +samples-protobuf-data-access = { path = "proto/samples_protobuf_data_access" } +service_discovery_proto = { path = "proto/service_discovery_proto" } # crates.io dependencies async-trait = "0.1.77" @@ -81,4 +82,5 @@ tokio-stream = { version = "0.1.8", features = ["net"] } tonic = "0.11.0" tonic-build = "0.11.0" tower = { version = "0.4", features = ["util"] } -uuid = "1.7.0" \ No newline at end of file +uuid = "1.7.0" +ureq = "2.9.6" \ No newline at end of file diff --git a/README.md b/README.md index c1699cdd..9525cc8f 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,22 @@ For more information on Freyja's design and how it works, see [the design docume This guide uses `apt` as the package manager in the examples. You may need to substitute your own package manager in place of `apt` when going through these steps. -1. Install git and rust: +1. Install required packages. These packages are necessary to clone the repo, install the Rust toolchain, and build Freyja's dependencies: ```shell sudo apt update - sudo apt install -y git snapd + sudo apt install -y \ + git \ + snapd \ + gcc \ + protobuf-compiler \ + pkg-config libssl-dev \ + cmake + ``` + +1. Install the Rust Toolchain: + + ```shell sudo snap install rustup --classic ``` diff --git a/build_common/Cargo.toml b/build_common/Cargo.toml index becb2d38..6ba7354c 100644 --- a/build_common/Cargo.toml +++ b/build_common/Cargo.toml @@ -8,4 +8,6 @@ version = "0.1.0" edition = "2021" license = "MIT" -[dependencies] \ No newline at end of file +[dependencies] +tonic-build = { workspace = true } +ureq = { workspace = true } \ No newline at end of file diff --git a/build_common/src/lib.rs b/build_common/src/lib.rs index ab12baff..e2da078d 100644 --- a/build_common/src/lib.rs +++ b/build_common/src/lib.rs @@ -9,6 +9,8 @@ const CONFIG_FILE_STEM: &str = "CONFIG_FILE_STEM"; const RES_DIR: &str = "res"; const DEFAULT_CONFIG_EXT: &str = ".default.json"; +pub const SERDE_DERIVE_ATTRIBUTE: &str = "#[derive(serde::Deserialize, serde::Serialize)]"; + /// Expands to `env!("CONFIG_FILE_STEM")`. /// Since we cannot use a constant in the `env!` macro, /// this is the next best option to avoid duplicating the `"CONFIG_FILE_STEM"` literal. @@ -49,3 +51,43 @@ pub fn copy_config(config_file_stem: &str) { // Set the CONFIG_FILE_STEM environment variable for compilation println!("cargo:rustc-env={}={}", CONFIG_FILE_STEM, config_file_stem); } + +/// Compiles proto files from a remote source, such as an external repo. +/// +/// # Arguments +/// - `url`: the url for retrieving the proto file. +/// - `message_attributes`: a list of message attributes to add. +/// Note that passing values here typically adds implicit dependencies to the crate that exposes these interfaces. +pub fn compile_remote_proto( + url: String, + message_attributes: &[(&str, &str)], +) -> Result<(), Box> { + // Retrieve file and write to OUT_DIR + let out_dir = env::var(OUT_DIR).unwrap(); + let filename = url.rsplit('/').next().unwrap_or_default(); + let proto_dir = Path::new(&out_dir).join("proto"); + + std::fs::create_dir_all(&proto_dir)?; + + let target = proto_dir.join(filename); + + match ureq::get(&url).call() { + Ok(response) => { + let mut out_file = fs::File::create(&target)?; + + std::io::copy(&mut response.into_reader(), &mut out_file)?; + } + Err(e) => panic!("Unable to retrieve remote proto file: {e}"), + } + + // Compile protos + let mut builder = tonic_build::configure(); + + for (msg, attr) in message_attributes { + builder = builder.message_attribute(msg, attr); + } + + builder.compile(&[target], &[proto_dir])?; + + Ok(()) +} diff --git a/proto/core_protobuf_data_access/Cargo.toml b/proto/core_protobuf_data_access/Cargo.toml new file mode 100644 index 00000000..7c3f65c5 --- /dev/null +++ b/proto/core_protobuf_data_access/Cargo.toml @@ -0,0 +1,18 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +[package] +name = "core-protobuf-data-access" +version = "0.1.0" +edition = "2021" +license = "MIT" + +[dependencies] +prost = { workspace = true } +prost-types = { workspace = true } +serde = { workspace = true } +tonic = { workspace = true } + +[build-dependencies] +freyja-build-common = { workspace = true } \ No newline at end of file diff --git a/proto/core_protobuf_data_access/build.rs b/proto/core_protobuf_data_access/build.rs new file mode 100644 index 00000000..8fead16b --- /dev/null +++ b/proto/core_protobuf_data_access/build.rs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +use freyja_build_common::{compile_remote_proto, SERDE_DERIVE_ATTRIBUTE}; + +const IBEJI_INTERFACES_BASE_URI: &str = + "https://raw.githubusercontent.com/eclipse-ibeji/ibeji/main/interfaces"; + +fn main() -> Result<(), Box> { + compile_remote_proto( + format!( + "{IBEJI_INTERFACES_BASE_URI}/invehicle_digital_twin/v1/invehicle_digital_twin.proto" + ), + &[ + ("EndpointInfo", SERDE_DERIVE_ATTRIBUTE), + ("EntityAccessInfo", SERDE_DERIVE_ATTRIBUTE), + ], + )?; + compile_remote_proto( + format!("{IBEJI_INTERFACES_BASE_URI}/module/managed_subscribe/v1/managed_subscribe.proto"), + &[ + ("Constraint", SERDE_DERIVE_ATTRIBUTE), + ("CallbackPayload", SERDE_DERIVE_ATTRIBUTE), + ("SubscriptionInfo", SERDE_DERIVE_ATTRIBUTE), + ], + )?; + + Ok(()) +} diff --git a/proto/core_protobuf_data_access/src/lib.rs b/proto/core_protobuf_data_access/src/lib.rs new file mode 100644 index 00000000..2cb99f16 --- /dev/null +++ b/proto/core_protobuf_data_access/src/lib.rs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +// Re-export this library so consumers have access to the types used in generation +pub use prost_types; + +pub mod invehicle_digital_twin { + pub mod v1 { + tonic::include_proto!("invehicle_digital_twin"); + } +} + +pub mod module { + pub mod managed_subscribe { + pub mod v1 { + tonic::include_proto!("managed_subscribe"); + } + } +} diff --git a/proto/samples_protobuf_data_access/Cargo.toml b/proto/samples_protobuf_data_access/Cargo.toml new file mode 100644 index 00000000..3b12e562 --- /dev/null +++ b/proto/samples_protobuf_data_access/Cargo.toml @@ -0,0 +1,17 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +[package] +name = "samples-protobuf-data-access" +version = "0.1.0" +edition = "2021" +license = "MIT" + +[dependencies] +prost = { workspace = true } +prost-types = { workspace = true } +tonic = { workspace = true } + +[build-dependencies] +freyja-build-common = { workspace = true } \ No newline at end of file diff --git a/proto/samples_protobuf_data_access/build.rs b/proto/samples_protobuf_data_access/build.rs new file mode 100644 index 00000000..f9ec3613 --- /dev/null +++ b/proto/samples_protobuf_data_access/build.rs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +use freyja_build_common::compile_remote_proto; + +const IBEJI_SAMPLE_INTERFACES_BASE_URI: &str = + "https://raw.githubusercontent.com/eclipse-ibeji/ibeji/main/samples/interfaces"; +const SAMPLE_GRPC_INTERFACE_PATH: &str = "sample_grpc/v1"; + +fn main() -> Result<(), Box> { + compile_remote_proto( + format!("{IBEJI_SAMPLE_INTERFACES_BASE_URI}/{SAMPLE_GRPC_INTERFACE_PATH}/digital_twin_consumer.proto"), + &[])?; + compile_remote_proto( + format!("{IBEJI_SAMPLE_INTERFACES_BASE_URI}/{SAMPLE_GRPC_INTERFACE_PATH}/digital_twin_provider.proto"), + &[])?; + + Ok(()) +} diff --git a/proto/samples_protobuf_data_access/src/lib.rs b/proto/samples_protobuf_data_access/src/lib.rs new file mode 100644 index 00000000..a2d483fe --- /dev/null +++ b/proto/samples_protobuf_data_access/src/lib.rs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +// Re-export this library so consumers have access to the types used in generation +pub use prost_types; + +pub mod sample_grpc { + pub mod v1 { + pub mod digital_twin_consumer { + tonic::include_proto!("digital_twin_consumer"); + } + + pub mod digital_twin_provider { + tonic::include_proto!("digital_twin_provider"); + } + } +} diff --git a/proto/service_discovery_proto/Cargo.toml b/proto/service_discovery_proto/Cargo.toml new file mode 100644 index 00000000..56945b32 --- /dev/null +++ b/proto/service_discovery_proto/Cargo.toml @@ -0,0 +1,17 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +[package] +name = "service_discovery_proto" +version = "0.1.0" +edition = "2021" +license = "MIT" + +[dependencies] +prost = { workspace = true } +prost-types = { workspace = true } +tonic = { workspace = true } + +[build-dependencies] +freyja-build-common = { workspace = true } \ No newline at end of file diff --git a/proto/service_discovery_proto/build.rs b/proto/service_discovery_proto/build.rs new file mode 100644 index 00000000..b1d12004 --- /dev/null +++ b/proto/service_discovery_proto/build.rs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +use freyja_build_common::compile_remote_proto; + +const CHARIOTT_SERVICE_DISCOVERY_INTERFACES_BASE_URI: &str = + "https://raw.githubusercontent.com/eclipse-chariott/chariott/main/service_discovery/proto"; + +fn main() -> Result<(), Box> { + compile_remote_proto( + format!("{CHARIOTT_SERVICE_DISCOVERY_INTERFACES_BASE_URI}/core/v1/service_registry.proto"), + &[], + )?; + + Ok(()) +} diff --git a/proto/service_discovery_proto/src/lib.rs b/proto/service_discovery_proto/src/lib.rs new file mode 100644 index 00000000..d94f882f --- /dev/null +++ b/proto/service_discovery_proto/src/lib.rs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +// Re-export this library so consumers have access to the types used in generation +pub use prost_types; + +pub mod service_registry { + pub mod v1 { + tonic::include_proto!("service_registry"); + } +}