mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:48:28 +02:00
Protoc sidecar
This commit is contained in:
33
src-tauri/Cargo.lock
generated
33
src-tauri/Cargo.lock
generated
@@ -1699,6 +1699,7 @@ dependencies = [
|
|||||||
"protoc-bin-vendored",
|
"protoc-bin-vendored",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"tauri",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tonic",
|
"tonic",
|
||||||
@@ -1763,9 +1764,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "h2"
|
name = "h2"
|
||||||
version = "0.3.21"
|
version = "0.3.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833"
|
checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"fnv",
|
"fnv",
|
||||||
@@ -1773,7 +1774,7 @@ dependencies = [
|
|||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http",
|
"http",
|
||||||
"indexmap 1.9.3",
|
"indexmap 2.1.0",
|
||||||
"slab",
|
"slab",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
@@ -2974,6 +2975,16 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "os_pipe"
|
||||||
|
version = "1.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57119c3b893986491ec9aa85056780d3a0f3cf4da7cc09dd3650dbd6c6738fb9"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "overload"
|
name = "overload"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@@ -4164,6 +4175,16 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shared_child"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signature"
|
name = "signature"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
@@ -4197,9 +4218,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.11.2"
|
version = "1.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
|
checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
@@ -4776,6 +4797,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"open",
|
"open",
|
||||||
"os_info",
|
"os_info",
|
||||||
|
"os_pipe",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
@@ -4787,6 +4809,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"serialize-to-javascript",
|
"serialize-to-javascript",
|
||||||
|
"shared_child",
|
||||||
"state",
|
"state",
|
||||||
"sys-locale",
|
"sys-locale",
|
||||||
"tar",
|
"tar",
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ tauri = { version = "1.5.4", features = [
|
|||||||
"os-all",
|
"os-all",
|
||||||
"protocol-asset",
|
"protocol-asset",
|
||||||
"shell-open",
|
"shell-open",
|
||||||
|
"shell-sidecar",
|
||||||
"updater",
|
"updater",
|
||||||
"window-close",
|
"window-close",
|
||||||
"window-maximize",
|
"window-maximize",
|
||||||
|
|||||||
@@ -20,3 +20,4 @@ hyper = { version = "0.14" }
|
|||||||
hyper-rustls = { version = "0.24.0", features = ["http2"] }
|
hyper-rustls = { version = "0.24.0", features = ["http2"] }
|
||||||
protoc-bin-vendored = "3.0.0"
|
protoc-bin-vendored = "3.0.0"
|
||||||
uuid = { version = "1.7.0", features = ["v4"] }
|
uuid = { version = "1.7.0", features = ["v4"] }
|
||||||
|
tauri = { version = "1.5.4", features = ["process-command-api"]}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
use std::env::temp_dir;
|
use std::env::temp_dir;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use hyper::client::HttpConnector;
|
|
||||||
use hyper::Client;
|
use hyper::Client;
|
||||||
|
use hyper::client::HttpConnector;
|
||||||
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
|
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
|
||||||
use log::{debug, warn};
|
use log::{debug, info, warn};
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
use prost_reflect::{DescriptorPool, MethodDescriptor};
|
use prost_reflect::{DescriptorPool, MethodDescriptor};
|
||||||
use prost_types::{FileDescriptorProto, FileDescriptorSet};
|
use prost_types::{FileDescriptorProto, FileDescriptorSet};
|
||||||
|
use tauri::api::process::{Command, CommandEvent};
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use tokio_stream::StreamExt;
|
use tokio_stream::StreamExt;
|
||||||
use tonic::body::BoxBody;
|
use tonic::body::BoxBody;
|
||||||
use tonic::codegen::http::uri::PathAndQuery;
|
use tonic::codegen::http::uri::PathAndQuery;
|
||||||
use tonic::transport::Uri;
|
|
||||||
use tonic::Request;
|
use tonic::Request;
|
||||||
|
use tonic::transport::Uri;
|
||||||
use tonic_reflection::pb::server_reflection_client::ServerReflectionClient;
|
use tonic_reflection::pb::server_reflection_client::ServerReflectionClient;
|
||||||
use tonic_reflection::pb::server_reflection_request::MessageRequest;
|
use tonic_reflection::pb::server_reflection_request::MessageRequest;
|
||||||
use tonic_reflection::pb::server_reflection_response::MessageResponse;
|
use tonic_reflection::pb::server_reflection_response::MessageResponse;
|
||||||
@@ -27,36 +27,67 @@ pub async fn fill_pool_from_files(paths: Vec<PathBuf>) -> Result<DescriptorPool,
|
|||||||
let mut pool = DescriptorPool::new();
|
let mut pool = DescriptorPool::new();
|
||||||
let random_file_name = format!("{}.desc", uuid::Uuid::new_v4());
|
let random_file_name = format!("{}.desc", uuid::Uuid::new_v4());
|
||||||
let desc_path = temp_dir().join(random_file_name);
|
let desc_path = temp_dir().join(random_file_name);
|
||||||
let bin = protoc_bin_vendored::protoc_bin_path().unwrap();
|
|
||||||
|
|
||||||
let mut cmd = Command::new(bin.clone());
|
let mut args = vec![
|
||||||
cmd.arg("--include_imports")
|
"--include_imports".to_string(),
|
||||||
.arg("--include_source_info")
|
"--include_source_info".to_string(),
|
||||||
.arg("-o")
|
"-o".to_string(),
|
||||||
.arg(&desc_path);
|
desc_path.to_string_lossy().to_string(),
|
||||||
|
];
|
||||||
|
|
||||||
for p in paths {
|
for p in paths {
|
||||||
if p.as_path().exists() {
|
if p.as_path().exists() {
|
||||||
cmd.arg(p.as_path().to_string_lossy().as_ref());
|
args.push(p.to_string_lossy().to_string());
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parent = p.as_path().parent();
|
let parent = p.as_path().parent();
|
||||||
if let Some(parent_path) = parent {
|
if let Some(parent_path) = parent {
|
||||||
cmd.arg("-I").arg(parent_path);
|
args.push("-I".to_string());
|
||||||
cmd.arg("-I").arg(parent_path.parent().unwrap());
|
args.push(parent_path.to_string_lossy().to_string());
|
||||||
|
args.push("-I".to_string());
|
||||||
|
args.push(parent_path.parent().unwrap().to_string_lossy().to_string());
|
||||||
} else {
|
} else {
|
||||||
debug!("ignoring {:?} since it does not exist.", parent)
|
debug!("ignoring {:?} since it does not exist.", parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = cmd.output().map_err(|e| e.to_string())?;
|
let (mut rx, _child) = Command::new_sidecar("protoc")
|
||||||
if !output.status.success() {
|
.expect("protoc not found")
|
||||||
return Err(format!(
|
.args(args)
|
||||||
"protoc failed: {}",
|
.spawn()
|
||||||
String::from_utf8_lossy(&output.stderr)
|
.expect("protoc failed to start");
|
||||||
));
|
|
||||||
|
while let Some(event) = rx.recv().await {
|
||||||
|
match event {
|
||||||
|
CommandEvent::Stdout(line) => {
|
||||||
|
info!("protoc stdout: {}", line);
|
||||||
|
}
|
||||||
|
CommandEvent::Stderr(line) => {
|
||||||
|
info!("protoc stderr: {}", line);
|
||||||
|
}
|
||||||
|
CommandEvent::Error(e) => {
|
||||||
|
return Err(e.to_string());
|
||||||
|
}
|
||||||
|
CommandEvent::Terminated(c) => {
|
||||||
|
match c.code {
|
||||||
|
Some(0) => {
|
||||||
|
// success
|
||||||
|
}
|
||||||
|
Some(code) => {
|
||||||
|
return Err(format!(
|
||||||
|
"protoc failed with exit code: {}",
|
||||||
|
code,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err("protoc failed with no exit code".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let bytes = fs::read(desc_path.as_path())
|
let bytes = fs::read(desc_path.as_path())
|
||||||
|
|||||||
BIN
src-tauri/protoc-vendored/protoc-aarch64-apple-darwin
Executable file
BIN
src-tauri/protoc-vendored/protoc-aarch64-apple-darwin
Executable file
Binary file not shown.
BIN
src-tauri/protoc-vendored/protoc-x86_64-apple-darwin
Executable file
BIN
src-tauri/protoc-vendored/protoc-x86_64-apple-darwin
Executable file
Binary file not shown.
BIN
src-tauri/protoc-vendored/protoc-x86_64-pc-windows-msvc.exe
Executable file
BIN
src-tauri/protoc-vendored/protoc-x86_64-pc-windows-msvc.exe
Executable file
Binary file not shown.
BIN
src-tauri/protoc-vendored/protoc-x86_64-unknown-linux-gnu
Executable file
BIN
src-tauri/protoc-vendored/protoc-x86_64-unknown-linux-gnu
Executable file
Binary file not shown.
@@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "Yaak",
|
"productName": "Yaak",
|
||||||
"version": "2024.3.0-beta.1"
|
"version": "2024.3.0-beta.2"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"windows": [],
|
"windows": [],
|
||||||
@@ -32,7 +32,13 @@
|
|||||||
},
|
},
|
||||||
"shell": {
|
"shell": {
|
||||||
"all": false,
|
"all": false,
|
||||||
"open": true
|
"open": true,
|
||||||
|
"sidecar": true,
|
||||||
|
"scope": [
|
||||||
|
{ "name": "protoc", "sidecar": true,
|
||||||
|
"args": true
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"window": {
|
"window": {
|
||||||
"close": true,
|
"close": true,
|
||||||
@@ -56,7 +62,9 @@
|
|||||||
"active": true,
|
"active": true,
|
||||||
"category": "DeveloperTool",
|
"category": "DeveloperTool",
|
||||||
"copyright": "",
|
"copyright": "",
|
||||||
"externalBin": [],
|
"externalBin": [
|
||||||
|
"protoc-vendored/protoc"
|
||||||
|
],
|
||||||
"icon": [
|
"icon": [
|
||||||
"icons/release/32x32.png",
|
"icons/release/32x32.png",
|
||||||
"icons/release/128x128.png",
|
"icons/release/128x128.png",
|
||||||
|
|||||||
Reference in New Issue
Block a user