Skip to content

Commit

Permalink
Rebuild common on version change
Browse files Browse the repository at this point in the history
Do not fetch library updates with xtask publish
  • Loading branch information
zmerp committed Aug 23, 2020
1 parent a6ef7c7 commit c36d4e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions alvr/common/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{fs, path::Path};

fn get_version(dir_name: &str) -> String {
let cargo_data = toml::from_slice::<toml::Value>(
&fs::read(Path::new("..").join(dir_name).join("Cargo.toml")).unwrap(),
)
.unwrap();
let cargo_path = Path::new("..").join(dir_name).join("Cargo.toml");
println!("cargo:rerun-if-changed={}", cargo_path.to_string_lossy());

let cargo_data = toml::from_slice::<toml::Value>(&fs::read(cargo_path).unwrap()).unwrap();

cargo_data["package"]["version"].as_str().unwrap().into()
}
Expand Down
14 changes: 9 additions & 5 deletions alvr/xtask/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use fs_extra::{self as fsx, dir as dirx};
use pico_args::Arguments;
use std::{
env,
error::Error,
fs,
io::{Read, Write},
path::{Path, PathBuf},
process::{Command, Stdio}, io::{Write, Read}, env,
process::{Command, Stdio},
};

const HELP_STR: &str = r#"
Expand Down Expand Up @@ -169,7 +171,7 @@ fn zip_dir(dir: &Path) -> BResult {
Ok(())
}

pub fn build_server(is_release: bool) -> BResult {
pub fn build_server(is_release: bool, fetch_crates: bool) -> BResult {
let build_type = if is_release { "release" } else { "debug" };
let build_flag = if is_release { "--release" } else { "" };

Expand All @@ -182,7 +184,9 @@ pub fn build_server(is_release: bool) -> BResult {
reset_server_build_folder()?;
fs::create_dir_all(&driver_dst_dir)?;

run("cargo update")?;
if fetch_crates {
run("cargo update")?;
}

run(&format!(
"cargo build -p alvr_server_driver -p alvr_web_server -p alvr_server_bootstrap {}",
Expand Down Expand Up @@ -264,7 +268,7 @@ pub fn build_client(is_release: bool) -> BResult {
}

pub fn build_publish() -> BResult {
build_server(true)?;
build_server(true, false)?;
build_client(true)?;
zip_dir(&server_build_dir())?;

Expand Down Expand Up @@ -312,7 +316,7 @@ fn main() {

if args.finish().is_ok() {
match subcommand.as_str() {
"build-server" => ok_or_exit(build_server(is_release)),
"build-server" => ok_or_exit(build_server(is_release, true)),
"build-client" => ok_or_exit(build_client(is_release)),
"publish" => ok_or_exit(build_publish()),
"clean" => remove_build_dir(),
Expand Down

0 comments on commit c36d4e0

Please sign in to comment.