70 lines
2.4 KiB
Rust
70 lines
2.4 KiB
Rust
use axum_connect_build::{axum_connect_codegen, AxumConnectGenSettings};
|
|
use std::env;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
fn main() {
|
|
// Set up the output directory for the generated Rust code
|
|
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
// Download the proto-def archive from the repository and extract it
|
|
// https://git.ok.software/ok/actions-proto-def/archive/main.tar.gz
|
|
// It's a tarball
|
|
let outfile = out_dir.join("proto-def.tar.gz");
|
|
let status = Command::new("curl")
|
|
.args(&[
|
|
"-L",
|
|
"-o",
|
|
outfile.to_str().unwrap(),
|
|
"https://ok.software/mirrors/actions-proto-def/archive/main.tar.gz",
|
|
])
|
|
.status()
|
|
.unwrap();
|
|
|
|
// Unpack the tarball
|
|
let status = Command::new("tar")
|
|
.args(&[
|
|
"-xzf",
|
|
outfile.to_str().unwrap(),
|
|
"--directory",
|
|
out_dir.to_str().unwrap(),
|
|
])
|
|
.status()
|
|
.unwrap();
|
|
|
|
// Check if protoc is installed
|
|
let status = Command::new("protoc").arg("--version").status();
|
|
match status {
|
|
Err(_) => panic!("protoc is not installed"),
|
|
_ => {}
|
|
}
|
|
let protos_dir = out_dir.join("actions-proto-def/proto");
|
|
let settings = AxumConnectGenSettings::from_directory_recursive(protos_dir.to_str().unwrap())
|
|
.expect("failed to glob protos");
|
|
axum_connect_codegen(settings).unwrap();
|
|
// // Create longer-lived values for the proto paths
|
|
// let ping_proto_path = out_dir.join("actions-proto-def/proto/ping/v1/services.proto");
|
|
// let runner_proto_path = out_dir.join("actions-proto-def/proto/runner/v1/services.proto");
|
|
|
|
// let proto_files = &[
|
|
// ping_proto_path.to_str().unwrap(),
|
|
// runner_proto_path.to_str().unwrap(),
|
|
// ];
|
|
|
|
// let includes_path = out_dir.join("actions-proto-def/proto/");
|
|
|
|
// // Compile the proto files
|
|
// // Compile the proto files using tonic_build
|
|
// tonic_build::configure()
|
|
// .out_dir(&out_dir)
|
|
// .compile(proto_files, &[includes_path])
|
|
// .unwrap();
|
|
|
|
// // Generate additional services and codecs as needed
|
|
// let descriptor_set_path = out_dir.join("descriptor.bin");
|
|
// tonic_build::configure()
|
|
// .file_descriptor_set_path(&descriptor_set_path)
|
|
// .compile(proto_files, &[includes_path])
|
|
// .unwrap();
|
|
}
|