2024-03-03 09:25:19 +01:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
2024-01-16 21:23:18 +01:00
|
|
|
println!("cargo:rerun-if-changed=api/lua");
|
2024-01-13 04:48:07 +01:00
|
|
|
println!("cargo:rerun-if-changed=api/protocol");
|
|
|
|
|
|
|
|
let xdg = xdg::BaseDirectories::with_prefix("pinnacle").unwrap();
|
|
|
|
|
2024-01-31 00:15:08 +01:00
|
|
|
let proto_dir = xdg.place_data_file("protobuf").unwrap();
|
2024-03-03 09:25:19 +01:00
|
|
|
let default_config_dir = xdg.place_data_file("default_config").unwrap();
|
|
|
|
let default_lua_config_dir = default_config_dir.join("lua");
|
|
|
|
let default_rust_config_dir = default_config_dir.join("rust");
|
2024-01-13 04:48:07 +01:00
|
|
|
|
2024-01-31 00:15:08 +01:00
|
|
|
let remove_protos = format!("rm -r {proto_dir:?}");
|
|
|
|
let copy_protos = format!("cp -r ./api/protocol {proto_dir:?}");
|
2024-01-13 04:48:07 +01:00
|
|
|
|
2024-03-03 09:25:19 +01:00
|
|
|
let remove_default_config_dir = format!("rm -r {default_config_dir:?}");
|
|
|
|
|
|
|
|
let copy_default_lua_config =
|
|
|
|
format!("cp -r ./api/lua/examples/default {default_lua_config_dir:?}");
|
|
|
|
|
|
|
|
let copy_default_rust_config = format!(
|
|
|
|
"cp -LR ./api/rust/examples/default_config/for_copying {default_rust_config_dir:?}"
|
|
|
|
);
|
2024-01-16 06:37:17 +01:00
|
|
|
|
2024-03-03 09:25:19 +01:00
|
|
|
Command::new("/bin/sh")
|
2024-01-15 06:38:05 +01:00
|
|
|
.arg("-c")
|
|
|
|
.arg(&remove_protos)
|
2024-03-03 09:25:19 +01:00
|
|
|
.spawn()?
|
|
|
|
.wait()?;
|
2024-01-15 06:38:05 +01:00
|
|
|
|
2024-03-03 09:25:19 +01:00
|
|
|
Command::new("/bin/sh")
|
2024-01-13 04:48:07 +01:00
|
|
|
.arg("-c")
|
|
|
|
.arg(©_protos)
|
2024-03-03 09:25:19 +01:00
|
|
|
.spawn()?
|
|
|
|
.wait()?;
|
2024-01-13 04:48:07 +01:00
|
|
|
|
2024-03-03 09:25:19 +01:00
|
|
|
Command::new("/bin/sh")
|
2024-01-16 06:37:17 +01:00
|
|
|
.arg("-c")
|
2024-03-03 09:25:19 +01:00
|
|
|
.arg(&remove_default_config_dir)
|
|
|
|
.spawn()?
|
|
|
|
.wait()?;
|
2024-01-16 06:37:17 +01:00
|
|
|
|
2024-03-03 09:25:19 +01:00
|
|
|
std::fs::create_dir_all(&default_config_dir)?;
|
|
|
|
|
|
|
|
Command::new("/bin/sh")
|
2024-01-16 06:37:17 +01:00
|
|
|
.arg("-c")
|
2024-03-03 09:25:19 +01:00
|
|
|
.arg(©_default_lua_config)
|
|
|
|
.spawn()?
|
|
|
|
.wait()?;
|
|
|
|
|
|
|
|
Command::new("/bin/sh")
|
|
|
|
.arg("-c")
|
|
|
|
.arg(©_default_rust_config)
|
|
|
|
.spawn()?
|
|
|
|
.wait()?;
|
2024-01-16 06:37:17 +01:00
|
|
|
|
2024-01-16 21:23:18 +01:00
|
|
|
std::env::set_current_dir("api/lua").unwrap();
|
2024-03-03 09:25:19 +01:00
|
|
|
Command::new("luarocks")
|
2024-01-16 04:53:13 +01:00
|
|
|
.arg("make")
|
|
|
|
.arg("--local")
|
|
|
|
.spawn()
|
2024-01-31 00:15:08 +01:00
|
|
|
.expect("Luarocks is not installed")
|
2024-03-03 09:25:19 +01:00
|
|
|
.wait()?;
|
|
|
|
|
|
|
|
Ok(())
|
2023-09-22 02:57:26 +02:00
|
|
|
}
|