mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-27 12:29:30 +00:00
Get rid of all transport types and settle on Protobuf (#25)
* Get rid of all transport types and settle on Protobuf hope i don't regret this * Update Cargo.toml * Update agent.py
This commit is contained in:
parent
643a47953e
commit
0a6e975ca5
38 changed files with 1484 additions and 685 deletions
38
crates/djls-ipc/build.rs
Normal file
38
crates/djls-ipc/build.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
struct Version(&'static str);
|
||||
|
||||
impl Version {
|
||||
fn collect_protos(&self, proto_root: &Path) -> Vec<PathBuf> {
|
||||
fs::read_dir(proto_root.join(self.0))
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
.filter(|entry| entry.path().extension().and_then(|s| s.to_str()) == Some("proto"))
|
||||
.map(|entry| entry.path())
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
const VERSIONS: &[Version] = &[Version("v1")];
|
||||
|
||||
fn main() {
|
||||
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let workspace_root = manifest_dir.parent().unwrap().parent().unwrap();
|
||||
let proto_dir = workspace_root.join("proto");
|
||||
|
||||
let mut protos = Vec::new();
|
||||
for version in VERSIONS {
|
||||
protos.extend(version.collect_protos(&proto_dir));
|
||||
}
|
||||
|
||||
prost_build::Config::new()
|
||||
.compile_protos(
|
||||
&protos
|
||||
.iter()
|
||||
.map(|p| p.to_str().unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
&[proto_dir],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue