-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(hermes): Remove git from build, vendor WH & Google protos (#2097)
* chore: remove git from build script, vendor wormhole and google protobufs * chore: update gitignore * fix: address pr comments
- Loading branch information
1 parent
059b7b9
commit d3cc7df
Showing
43 changed files
with
6,635 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,3 @@ | |
src/network/p2p.pb.go | ||
src/network/p2p.proto | ||
tools/ | ||
|
||
# Ignore Wormhole cloned repo | ||
wormhole*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,28 @@ | ||
use std::{ | ||
env, | ||
path::PathBuf, | ||
process::Command, | ||
}; | ||
use std::path::PathBuf; | ||
|
||
/// Custom build script to compile and include the wormhole protobufs into the source. | ||
/// The wormhole protobufs are vendored from the Wormhole git repository at https://github.com/wormhole-foundation/wormhole.git | ||
/// They reference other protobufs from the Google API repository at https://github.com/googleapis/googleapis.git , which are also vendored. | ||
/// Our copies live in `proto/vendor`. | ||
fn main() { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
let proto_dir = PathBuf::from("proto/vendor"); | ||
|
||
// Print OUT_DIR for debugging build issues. | ||
println!("OUT_DIR={}", out_dir.display()); | ||
// Tell cargo to recompile if any .proto files change | ||
println!("cargo:rerun-if-changed=proto/"); | ||
|
||
// We'll use git to pull in protobuf dependencies. This trick lets us use the Rust OUT_DIR | ||
// directory as a mini-repo with wormhole and googleapis as remotes, so we can copy out the | ||
// TREEISH paths we want. | ||
let protobuf_setup = r#" | ||
set -e | ||
git init . | ||
git clean -df | ||
git remote add wormhole https://github.com/wormhole-foundation/wormhole.git || true | ||
git remote add googleapis https://github.com/googleapis/googleapis.git || true | ||
git fetch --depth=1 wormhole main | ||
git fetch --depth=1 googleapis master | ||
git reset | ||
rm -rf proto/ | ||
git read-tree --prefix=proto/ -u wormhole/main:proto | ||
git read-tree --prefix=proto/google/api/ -u googleapis/master:google/api | ||
"#; | ||
|
||
// Run each command to prepare the OUT_DIR with the protobuf definitions. We need to make sure | ||
// to change the working directory to OUT_DIR, otherwise git will complain. | ||
let output = Command::new("sh") | ||
.args(["-c", protobuf_setup]) | ||
.current_dir(&out_dir) | ||
.output() | ||
.expect("failed to run protobuf setup commands"); | ||
if !output.status.success() { | ||
panic!( | ||
"failed to setup protobuf definitions: {}", | ||
String::from_utf8_lossy(&output.stderr) | ||
); | ||
} | ||
|
||
// We build the resulting protobuf definitions using Rust's prost_build crate, which generates | ||
// Rust code from the protobuf definitions. | ||
// Build the wormhole and google protobufs using Rust's prost_build crate. | ||
// The generated Rust code is placed in the OUT_DIR (env var set by cargo). | ||
// `network/wormhole.rs` then includes the generated code into the source while compilation is happening. | ||
tonic_build::configure() | ||
.build_server(false) | ||
.compile( | ||
&[ | ||
out_dir.join("proto/spy/v1/spy.proto"), | ||
out_dir.join("proto/gossip/v1/gossip.proto"), | ||
out_dir.join("proto/node/v1/node.proto"), | ||
out_dir.join("proto/publicrpc/v1/publicrpc.proto"), | ||
proto_dir.join("spy/v1/spy.proto"), | ||
proto_dir.join("gossip/v1/gossip.proto"), | ||
proto_dir.join("node/v1/node.proto"), | ||
proto_dir.join("publicrpc/v1/publicrpc.proto"), | ||
], | ||
&[out_dir.join("proto")], | ||
&[proto_dir], | ||
) | ||
.expect("failed to compile protobuf definitions"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## API Protos | ||
|
||
This folder contains the schema of the configuration model for Google's | ||
internal API serving platform, which handles routing, quotas, monitoring, | ||
logging, and the like. | ||
|
||
Google refers to this configuration colloquially as the "service config", | ||
and the `service.proto` file in this directory is the entry point for | ||
understanding these. | ||
|
||
## Using these protos | ||
|
||
To be honest, we probably open sourced way too much of this (basically by | ||
accident). There are a couple files in here you are most likely to be | ||
interested in: `http.proto`, `documentation.proto`, `auth.proto`, and | ||
`annotations.proto`. | ||
|
||
### HTTP and REST | ||
|
||
The `http.proto` file contains the `Http` message (which then is wrapped | ||
in an annotation in `annotations.proto`), which provides a specification | ||
for REST endpoints and verbs (`GET`, `POST`, etc.) on RPC methods. | ||
We recommend use of this annotation for describing the relationship | ||
between RPCs and REST endpoints. | ||
|
||
### Documentation | ||
|
||
The `documentation.proto` file contains a `Documentation` message which | ||
provides a mechanism to fully describe an API, allowing a tool to build | ||
structured documentation artifacts. | ||
|
||
### Authentication | ||
|
||
The `auth.proto` file contains descriptions of both authentication rules | ||
and authentication providers, allowing you to describe what your services | ||
expect and accept from clients. |
31 changes: 31 additions & 0 deletions
31
apps/hermes/server/proto/vendor/google/api/annotations.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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. | ||
|
||
syntax = "proto3"; | ||
|
||
package google.api; | ||
|
||
import "google/api/http.proto"; | ||
import "google/protobuf/descriptor.proto"; | ||
|
||
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; | ||
option java_multiple_files = true; | ||
option java_outer_classname = "AnnotationsProto"; | ||
option java_package = "com.google.api"; | ||
option objc_class_prefix = "GAPI"; | ||
|
||
extend google.protobuf.MethodOptions { | ||
// See `HttpRule`. | ||
HttpRule http = 72295728; | ||
} |
Oops, something went wrong.