-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into jc/ipc-stats
- Loading branch information
Showing
83 changed files
with
2,050 additions
and
1,536 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "build-vortex" | ||
version.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
keywords.workspace = true | ||
include.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
flatc = { workspace = true } | ||
prost-build = { workspace = true } | ||
walkdir = { workspace = true } | ||
|
||
[lints] | ||
workspace = true |
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,12 @@ | ||
# Build Vortex | ||
|
||
A crate containing configuration logic for Vortex build.rs files. | ||
|
||
## Usage | ||
|
||
## Features | ||
|
||
Depending on the enabled features, this script supports: | ||
|
||
* FlatBuffers | ||
* Protocol Buffers |
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,96 @@ | ||
use std::env; | ||
use std::ffi::OsStr; | ||
use std::fs::create_dir_all; | ||
use std::path::{Path, PathBuf}; | ||
use std::process::Command; | ||
|
||
use flatc::flatc; | ||
use walkdir::WalkDir; | ||
|
||
fn manifest_dir() -> PathBuf { | ||
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) | ||
.canonicalize() | ||
.expect("Failed to canonicalize CARGO_MANIFEST_DIR") | ||
} | ||
|
||
fn out_dir() -> PathBuf { | ||
PathBuf::from(env::var("OUT_DIR").unwrap()) | ||
.canonicalize() | ||
.expect("Failed to canonicalize OUT_DIR") | ||
} | ||
|
||
pub fn build() { | ||
// FlatBuffers | ||
if env::var("CARGO_FEATURE_FLATBUFFERS").ok().is_some() { | ||
build_flatbuffers(); | ||
} | ||
|
||
// Proto (prost) | ||
if env::var("CARGO_FEATURE_PROTO").ok().is_some() { | ||
build_proto(); | ||
} | ||
} | ||
|
||
pub fn build_proto() { | ||
let proto_dir = manifest_dir().join("proto"); | ||
let proto_files = walk_files(&proto_dir, "proto"); | ||
let proto_out = out_dir().join("proto"); | ||
|
||
create_dir_all(&proto_out).expect("Failed to create proto output directory"); | ||
|
||
prost_build::Config::new() | ||
.out_dir(&proto_out) | ||
.compile_protos(&proto_files, &[&proto_dir, &proto_dir.join("../../")]) | ||
.expect("Failed to compile protos"); | ||
} | ||
|
||
pub fn build_flatbuffers() { | ||
let flatbuffers_dir = manifest_dir().join("flatbuffers"); | ||
let fbs_files = walk_files(&flatbuffers_dir, "fbs"); | ||
check_call( | ||
Command::new(flatc()) | ||
.arg("--rust") | ||
.arg("--filename-suffix") | ||
.arg("") | ||
.arg("-I") | ||
.arg(flatbuffers_dir.join("../../")) | ||
.arg("--include-prefix") | ||
.arg("flatbuffers::deps") | ||
.arg("-o") | ||
.arg(out_dir().join("flatbuffers")) | ||
.args(fbs_files), | ||
) | ||
} | ||
|
||
/// Recursively walk for files with the given extension, adding them to rerun-if-changed. | ||
fn walk_files(dir: &Path, ext: &str) -> Vec<PathBuf> { | ||
WalkDir::new(dir) | ||
.into_iter() | ||
.filter_map(|e| e.ok()) | ||
.filter(|e| e.path().extension() == Some(OsStr::new(ext))) | ||
.map(|e| { | ||
rerun_if_changed(e.path()); | ||
e.path().to_path_buf() | ||
}) | ||
.collect() | ||
} | ||
|
||
fn rerun_if_changed(path: &Path) { | ||
println!( | ||
"cargo:rerun-if-changed={}", | ||
path.canonicalize() | ||
.unwrap_or_else(|_| panic!("failed to canonicalize {}", path.to_str().unwrap())) | ||
.to_str() | ||
.unwrap() | ||
); | ||
} | ||
|
||
fn check_call(command: &mut Command) { | ||
let name = command.get_program().to_str().unwrap().to_string(); | ||
let Ok(status) = command.status() else { | ||
panic!("Failed to launch {}", &name) | ||
}; | ||
if !status.success() { | ||
panic!("{} failed with status {}", &name, status.code().unwrap()); | ||
} | ||
} |
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
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
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.