Support release mode in build.sh
Bug: 376852557
Test: ./build.sh -r
Change-Id: I8fe16a1b9f40954e93b2a39df401a95e3ff564f7
diff --git a/build/debian/build.sh b/build/debian/build.sh
index 7fc9035..df0e750 100755
--- a/build/debian/build.sh
+++ b/build/debian/build.sh
@@ -11,6 +11,7 @@
echo "Options:"
echo "-h Print usage and this help message and exit."
echo "-a ARCH Architecture of the image [default is aarch64]"
+ echo "-r Release mode build"
}
check_sudo() {
@@ -21,7 +22,7 @@
}
parse_options() {
- while getopts "ha:" option; do
+ while getopts "hra:" option; do
case ${option} in
h)
show_help
@@ -36,6 +37,9 @@
debian_arch="amd64"
fi
;;
+ r)
+ mode=release
+ ;;
*)
echo "Invalid option: $OPTARG"
exit
@@ -119,11 +123,17 @@
build_rust_binary_and_copy() {
pushd "$(dirname "$0")/../../guest/$1" > /dev/null
+ local release_flag=
+ local artifact_mode=debug
+ if [[ "$mode" == "release" ]]; then
+ release_flag="--release"
+ artifact_mode=release
+ fi
RUSTFLAGS="-C linker=${arch}-linux-gnu-gcc" cargo build \
--target "${arch}-unknown-linux-gnu" \
- --target-dir "${workdir}/$1"
+ --target-dir "${workdir}/$1" ${release_flag}
mkdir -p "${dst}/files/usr/local/bin/$1"
- cp "${workdir}/$1/${arch}-unknown-linux-gnu/debug/$1" "${dst}/files/usr/local/bin/$1/AVF"
+ cp "${workdir}/$1/${arch}-unknown-linux-gnu/${artifact_mode/$1" "${dst}/files/usr/local/bin/$1/AVF"
chmod 777 "${dst}/files/usr/local/bin/$1/AVF"
mkdir -p "${dst}/files/usr/share/doc/$1"
@@ -197,6 +207,7 @@
resources_dir=${debian_cloud_image}/src/debian_cloud_images/resources
arch=aarch64
debian_arch=arm64
+mode=debug
parse_options "$@"
check_sudo
install_prerequisites