mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-22 11:22:59 +03:00
build: get it working
This commit is contained in:
parent
275fa494ec
commit
a9df137402
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1403,7 +1403,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build_package"
|
||||
name = "build_packages"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
|
@ -26,7 +26,7 @@ members = [
|
||||
"kinode/packages/terminal/help", "kinode/packages/terminal/hi", "kinode/packages/terminal/kfetch",
|
||||
"kinode/packages/terminal/kill", "kinode/packages/terminal/m", "kinode/packages/terminal/top",
|
||||
"kinode/packages/terminal/net_diagnostics", "kinode/packages/terminal/peer", "kinode/packages/terminal/peers",
|
||||
"kinode/packages/tester/tester", "scripts/build_package",
|
||||
"kinode/packages/tester/tester", "scripts/build_packages",
|
||||
]
|
||||
default-members = ["lib"]
|
||||
resolver = "2"
|
||||
|
@ -2,21 +2,24 @@ use std::path::PathBuf;
|
||||
|
||||
const CANONICAL_PACKAGES_ZIP_PATH: &str = "../target/packages.zip";
|
||||
|
||||
macro_rules! p {
|
||||
($($tokens: tt)*) => {
|
||||
println!("cargo:warning={}", format!($($tokens)*))
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let path_to_packages_zip = match std::env::var("PATH_TO_PACKAGES_ZIP") {
|
||||
Err(_) => {
|
||||
let build_package_script_path = PathBuf::from("../scripts/build_package");
|
||||
let mut child = std::process::Command::new("cargo")
|
||||
.arg("run")
|
||||
.current_dir(&build_package_script_path)
|
||||
.spawn()?;
|
||||
let result = child.wait()?;
|
||||
if !result.success() {
|
||||
return Err(anyhow::anyhow!("Failed to build packages."));
|
||||
}
|
||||
CANONICAL_PACKAGES_ZIP_PATH.to_string()
|
||||
}
|
||||
Ok(env_var) => env_var,
|
||||
Err(_) => {
|
||||
let canonical_path = PathBuf::from(CANONICAL_PACKAGES_ZIP_PATH);
|
||||
if canonical_path.exists() {
|
||||
p!("No path given via PATH_TO_PACKAGES_ZIP envvar. Defaulting to path of `kinode/target/packages.zip`.");
|
||||
CANONICAL_PACKAGES_ZIP_PATH.to_string()
|
||||
} else {
|
||||
return Err(anyhow::anyhow!("You must build packages.zip with scripts/build_packages or set PATH_TO_PACKAGES_ZIP to point to your desired pacakges.zip (default path at kinode/target/packages.zip was not populated)."));
|
||||
}
|
||||
}
|
||||
};
|
||||
let path = PathBuf::from(&path_to_packages_zip);
|
||||
if !path.exists() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "build_package"
|
||||
name = "build_packages"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
@ -70,7 +70,7 @@ fn build_and_zip_package(
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let matches = Command::new("build_package")
|
||||
let matches = Command::new("build_packages")
|
||||
.about("Build the core Kinode packages.")
|
||||
.arg(
|
||||
Arg::new("FEATURES")
|
||||
@ -167,8 +167,7 @@ fn main() -> anyhow::Result<()> {
|
||||
Ok((entry_path, zip_filename, zip_contents)) => {
|
||||
let metadata_path = entry_path.join("metadata.json");
|
||||
let metadata_contents = fs::read_to_string(&metadata_path)?;
|
||||
let metadata_contents: serde_json::Value =
|
||||
serde_json::from_str(&metadata_contents)?;
|
||||
let metadata_contents: serde_json::Value = serde_json::from_str(&metadata_contents)?;
|
||||
file_to_metadata.insert(zip_filename.clone(), metadata_contents);
|
||||
let zip_path = target_packages_dir.join(&zip_filename);
|
||||
fs::write(&zip_path, &zip_contents)?;
|
Loading…
Reference in New Issue
Block a user