-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Signal protobuf files and compile them to Rust.
It would be cleaner to yield the compiled files OUT_DIR, but that gets ugly very fast because of rust-lang/rust#48250.
- Loading branch information
Showing
10 changed files
with
578 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/proto/*.rs |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::path::Path; | ||
|
||
use protoc_rust::Customize; | ||
|
||
fn main() { | ||
let protobuf = Path::new(env!("CARGO_MANIFEST_DIR")).join("protobuf"); | ||
|
||
let input: Vec<_> = protobuf | ||
.read_dir() | ||
.expect("protobuf directory") | ||
.filter_map(|entry| { | ||
let entry = entry.expect("readable protobuf directory"); | ||
let path = entry.path(); | ||
if Some("proto") | ||
== path.extension().and_then(std::ffi::OsStr::to_str) | ||
{ | ||
assert!(path.is_file()); | ||
println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); | ||
Some(path.to_str().unwrap().to_string()) | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect(); | ||
|
||
let input: Vec<&str> = input.iter().map(String::as_ref).collect(); | ||
|
||
protoc_rust::run(protoc_rust::Args { | ||
out_dir: "src/proto", | ||
input: &input, | ||
includes: &[protobuf.to_str().unwrap()], | ||
customize: Customize { | ||
..Default::default() | ||
}, | ||
}) | ||
.expect("protoc"); | ||
} |
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 @@ | ||
/** | ||
* Copyright (C) 2014-2016 Open Whisper Systems | ||
* | ||
* Licensed according to the LICENSE file in this repository. | ||
*/ | ||
syntax = "proto2"; | ||
|
||
package signalservice; | ||
|
||
option java_package = "org.whispersystems.signalservice.internal.push"; | ||
option java_outer_classname = "ProvisioningProtos"; | ||
|
||
message ProvisionEnvelope { | ||
optional bytes publicKey = 1; | ||
optional bytes body = 2; // Encrypted ProvisionMessage | ||
} | ||
|
||
message ProvisionMessage { | ||
optional bytes identityKeyPublic = 1; | ||
optional bytes identityKeyPrivate = 2; | ||
optional string number = 3; | ||
optional string uuid = 8; | ||
optional string provisioningCode = 4; | ||
optional string userAgent = 5; | ||
optional bytes profileKey = 6; | ||
optional bool readReceipts = 7; | ||
optional uint32 provisioningVersion = 9; | ||
} | ||
|
||
enum ProvisioningVersion { | ||
option allow_alias = true; | ||
|
||
INITIAL = 0; | ||
TABLET_SUPPORT = 1; | ||
CURRENT = 1; | ||
} |
Oops, something went wrong.