Skip to content

Commit

Permalink
add build.rs that dlds the test resources
Browse files Browse the repository at this point in the history
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 <fandree@amazon.com>
  • Loading branch information
andreeaflorescu authored and jiangliu committed Dec 30, 2020
1 parent 2494ba5 commit b18d387
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .buildkite/hooks/post-checkout → .buildkite/download_resources.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

mkdir -p ${EXTRACT_PATH}

wget $DEB_URL -P ${TMP_PATH}
curl $DEB_URL -o ${DEB_PATH}
dpkg-deb -x ${DEB_PATH} ${EXTRACT_PATH}

mv ${BZIMAGE_PATH} "${SCRIPTPATH}/../src/loader/x86_64/bzimage/bzimage"
Expand Down
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::process::Command;

fn main() {
let command = "./.buildkite/download_resources.sh";
let status = Command::new(command).status().unwrap();
if !status.success() {
panic!("Cannot run build script");
}

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=.buildkite/download_resources.sh");
println!("cargo:rerun-if-changed=src/loader/x86_64/bzimage/bzimage");
}

0 comments on commit b18d387

Please sign in to comment.