-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement file identifier mappings (#364)
- Loading branch information
Showing
20 changed files
with
162 additions
and
100 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,21 +1,40 @@ | ||
// The custom build script, needed as we use protocolbuffers. | ||
// The custom build script, used to (1) generate the Rust classes for the | ||
// protobuf implementation and (2) use pbjson for proto3 JSON serialization. | ||
|
||
use std::{env, path::PathBuf}; | ||
|
||
fn main() -> Result<(), anyhow::Error> { | ||
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("protos"); | ||
let proto_files = [ | ||
"varfish/v1/clinvar.proto", | ||
"varfish/v1/sv.proto", | ||
"varfish/v1/worker.proto", | ||
] | ||
.iter() | ||
.map(|f| root.join(f)) | ||
.collect::<Vec<_>>(); | ||
|
||
// Tell cargo to recompile if any of these proto files are changed | ||
for proto_file in &proto_files { | ||
println!("cargo:rerun-if-changed={}", proto_file.display()); | ||
} | ||
|
||
let descriptor_path: PathBuf = | ||
PathBuf::from(env::var("OUT_DIR").unwrap()).join("proto_descriptor.bin"); | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-changed=src/proto/varfish/v1/clinvar.proto"); | ||
println!("cargo:rerun-if-changed=src/proto/varfish/v1/sv.proto"); | ||
prost_build::Config::new() | ||
.protoc_arg("-Isrc/proto") | ||
// Add serde serialization and deserialization to the generated code. | ||
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") | ||
// Skip serializing `None` values. | ||
.type_attribute(".", "#[serde_with::skip_serializing_none]") | ||
// Save descriptors to file | ||
.file_descriptor_set_path(&descriptor_path) | ||
// Override prost-types with pbjson-types | ||
.compile_well_known_types() | ||
.extern_path(".google.protobuf", "::pbjson_types") | ||
// Define the protobuf files to compile. | ||
.compile_protos( | ||
&[ | ||
"src/proto/varfish/v1/clinvar.proto", | ||
"src/proto/varfish/v1/sv.proto", | ||
], | ||
&["src/"], | ||
) | ||
.unwrap(); | ||
.compile_protos(&proto_files, &[root])?; | ||
|
||
let descriptor_set = std::fs::read(descriptor_path).unwrap(); | ||
pbjson_build::Builder::new() | ||
.register_descriptors(&descriptor_set)? | ||
.build(&[".varfish"])?; | ||
|
||
Ok(()) | ||
} |
File renamed without changes.
File renamed without changes.
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,27 @@ | ||
// Protocol buffers related to the worker. | ||
|
||
syntax = "proto3"; | ||
|
||
package varfish.v1.worker; | ||
|
||
// Protocol buffer for storing a list of file identifier mappings. | ||
message FileIdentifierMappings { | ||
// Protocol buffer for storing file identifier mapping for one file. | ||
message Mapping { | ||
// Protocol buffer to store one mapping entry. | ||
message Entry { | ||
// Identifier as given in input file. | ||
string src = 1; | ||
// Identifier to use in output file. | ||
string dst = 2; | ||
} | ||
|
||
// Path to the file to obtain mapping for, as given on the command line. | ||
string path = 1; | ||
// List of identifier mappings. | ||
repeated Entry entries = 2; | ||
} | ||
|
||
// One file per mapping. | ||
repeated Mapping mappings = 1; | ||
} |
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,6 +1,7 @@ | ||
//! VarFish Server Worker main executable | ||
pub mod common; | ||
pub mod pbs; | ||
pub mod seqvars; | ||
pub mod strucvars; | ||
|
||
|
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,19 @@ | ||
//! Data structures for (de-)serialization as generated by `prost-build`. | ||
/// Code generate for protobufs by `prost-build`. | ||
pub mod clinvar { | ||
include!(concat!(env!("OUT_DIR"), "/varfish.v1.clinvar.rs")); | ||
include!(concat!(env!("OUT_DIR"), "/varfish.v1.clinvar.serde.rs")); | ||
} | ||
|
||
/// Code generate for protobufs by `prost-build`. | ||
pub mod svs { | ||
include!(concat!(env!("OUT_DIR"), "/varfish.v1.svs.rs")); | ||
include!(concat!(env!("OUT_DIR"), "/varfish.v1.svs.serde.rs")); | ||
} | ||
|
||
/// Code generate for protobufs by `prost-build`. | ||
pub mod worker { | ||
include!(concat!(env!("OUT_DIR"), "/varfish.v1.worker.rs")); | ||
include!(concat!(env!("OUT_DIR"), "/varfish.v1.worker.serde.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
pub mod aggregate; | ||
pub mod ingest; | ||
pub mod pbs; | ||
pub mod query; | ||
pub mod txt_to_bin; |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.