Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/.idea/
/.vscode/
logs/
/runtime/conf/ya-runtime-vm.json
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pnet = "0.33"

[build-dependencies]
anyhow = "1.0"
serde_json = "1.0"

[lib]
name = "ya_runtime_vm"
Expand Down
28 changes: 25 additions & 3 deletions runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use anyhow::Context;
use serde_json::{Map, Value};
use std::env;
use std::fs::File;
use std::ops::Not;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::process::Command;

static RERUN_IF_CHANGED: &str = "cargo:rerun-if-changed";

fn main() -> anyhow::Result<()> {
fn make_init(root_dir: &Path) -> anyhow::Result<()> {
// skip build for CI
if env::var("CI").is_ok() {
return Ok(());
}

let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let init_dir = root_dir.join("init-container").canonicalize().unwrap();
let include_dir = init_dir.join("include");
let src_dir = init_dir.join("src");
Expand Down Expand Up @@ -52,3 +53,24 @@ fn main() -> anyhow::Result<()> {
);
Ok(())
}

fn update_conf(root_dir: &Path, version: String) {
let fname = root_dir.join("conf/ya-runtime-vm.json.in");
let fin = File::open(fname).unwrap();
let fname = root_dir.join("conf/ya-runtime-vm.json");
let fout = File::create(fname).unwrap();

let mut json: Vec<Map<String, Value>> = serde_json::from_reader(fin).unwrap();
json[0].insert(String::from("version"), Value::from(version));
serde_json::to_writer_pretty(fout, &json).unwrap();
}

fn main() -> anyhow::Result<()> {
let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let version = env::var("CARGO_PKG_VERSION").unwrap();

make_init(&root_dir)?;
update_conf(&root_dir, version);

Ok(())
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"name": "vm",
"version": "0.5.0",
"version": "@VERSION@",
"supervisor-path": "exe-unit",
"runtime-path": "ya-runtime-vm/ya-runtime-vm",
"description": "vm runtime",
Expand Down
Loading