Skip to content

Commit b8f81cc

Browse files
add build.rs that dlds the test resources
To be able to run the unit tests seamlessly on any dev machine, we need to have the test resources downloaded. This can be achieved by calling the post-checkout script. Since this does not need to be executed when running with Buildkite, but all the time, the script is now moved to .buildkite/download_resources.sh and it is no longer a Buildkite hook, but rather a regular bash script. The script is called from build.rs so that it is transparent to the user when the resources are downloaded. The disadvantage with this approach is that the resources will be downloaded even when calling cargo build, and not only for cargo test. This can be updated in the future once cargo adds support for identifying the build profile in build scripts. Tracking issue: rust-lang/cargo#4001 To be able to run this with the rust-vmm-container, the script needs to be updated such that it uses curl instead of wget (wget is not available in the container). Signed-off-by: Andreea Florescu <[email protected]>
1 parent 10e282a commit b8f81cc

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.buildkite/hooks/post-checkout renamed to .buildkite/download_resources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
1313

1414
mkdir -p ${EXTRACT_PATH}
1515

16-
wget $DEB_URL -P ${TMP_PATH}
16+
curl $DEB_URL -o ${DEB_PATH}
1717
dpkg-deb -x ${DEB_PATH} ${EXTRACT_PATH}
1818

1919
mv ${BZIMAGE_PATH} "${SCRIPTPATH}/../src/loader/x86_64/bzimage/bzimage"

build.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use std::process::Command;
2+
3+
fn main() {
4+
let command = "./.buildkite/download_resources.sh";
5+
let status = Command::new(command).status().unwrap();
6+
if !status.success() {
7+
panic!("Cannot run build script");
8+
}
9+
10+
println!("cargo:rerun-if-changed=build.rs");
11+
println!("cargo:rerun-if-changed=.buildkite/download_resources.sh");
12+
println!("cargo:rerun-if-changed=src/loader/x86_64/bzimage/bzimage");
13+
}

0 commit comments

Comments
 (0)