From 4de9c92a29f75e45a6aa30fab92de155fc4c8c10 Mon Sep 17 00:00:00 2001 From: Sasha Hilton Date: Fri, 24 Jul 2020 03:11:14 +0100 Subject: [PATCH] Update build.rs & publish.sh with minor fixes --- protocol/build.rs | 7 ++++++- publish.sh | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/protocol/build.rs b/protocol/build.rs index de0b03ba..cedf2acd 100644 --- a/protocol/build.rs +++ b/protocol/build.rs @@ -1,8 +1,10 @@ extern crate protobuf_codegen; // Does the business extern crate protobuf_codegen_pure; // Helper function +use std::env; use std::fs::{read_to_string, write}; use std::path::Path; +use std::path::PathBuf; use protobuf_codegen_pure::parse_and_typecheck; use protobuf_codegen_pure::Customize; @@ -28,9 +30,12 @@ fn main() { name = &line[4..len - 1]; // Remove keywords and semi-colon } + //let out_dir = env::var("OUT_DIR").is_err(); + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + // Build the paths to relevant files. let src_fname = &format!("proto/{}.proto", name); - let dest_fname = &format!("src/{}.rs", name); + let dest_fname = &out_dir.join(format!("{}.rs", name)); let src = Path::new(src_fname); let dest = Path::new(dest_fname); // Get the contents of the existing generated file. diff --git a/publish.sh b/publish.sh index b280fcda..fa3158bf 100755 --- a/publish.sh +++ b/publish.sh @@ -24,6 +24,10 @@ function updateVersion { crate_path=${crate_path//\/\///} sed -i '' "s/^version.*/version = \"$1\"/g" "$crate_path" echo "Path is $crate_path" + if [ "$CRATE" = "librespot" ] + then + cargo update + fi done } @@ -36,6 +40,19 @@ function get_crate_name { awk -v FS="name = " 'NF>1{print $2; exit}' Cargo.toml } +function remoteWait() { + IFS=: + secs=${1} + while [ $secs -gt 0 ] + do + sleep 1 & + printf "\rSleeping to allow packages to propagate on crates.io servers. Continuing in %2d second(s)." ${secs} + secs=$(( $secs - 1 )) + wait + done + echo +} + function publishCrates { for CRATE in "${crates[@]}" do @@ -58,7 +75,7 @@ function publishCrates { cargo publish fi echo "Successfully published $crate_name to crates.io" - # Should sleep here for 30 seconds to allow Crates.io time to push updated package to edge servers. + remoteWait 30 done }