Evan Benn has uploaded this change for review.

View Change

test_build.sh: Add build_rust

Add a function to check the rust projects. cargo test, fmt, and clippy
are run to check unit tests, code format, and lint. The rust packages
are built against the just compiled 'all' variant of libflashrom. cargo
is run offline so that jenkins works. The tests are only run if cargo
is installed.

BUG=b:242935799
BRANCH=None
TEST=./test_build.sh

Change-Id: I728f5b856a9161b87b96207f4c3965e7493c33d1
Signed-off-by: Evan Benn <evanbenn@chromium.org>
---
M test_build.sh
1 file changed, 44 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/70/69770/1
diff --git a/test_build.sh b/test_build.sh
index 69d3a34..31a0199 100755
--- a/test_build.sh
+++ b/test_build.sh
@@ -53,6 +53,7 @@

for programmer in ${meson_programmer_opts}; do
programmer_dir="${build_dir}/${programmer}"
+ install_dir="${PWD}/${programmer_dir}/install"

# In case of clang analyzer we don't want to run it on
# each programmer individually. Thus, just return here.
@@ -60,12 +61,34 @@
return
fi

- meson ${programmer_dir} ${meson_opts} -Dprogrammer=${programmer}
+ meson ${programmer_dir} ${meson_opts} -Dprogrammer=${programmer} --prefix=${install_dir}
ninja ${ninja_opts} -C ${programmer_dir}
ninja ${ninja_opts} -C ${programmer_dir} test
+
+ if [ "${programmer}" = "all" ]; then
+ # build_rust requires an installed header and library to link against.
+ ninja ${ninja_opts} -C ${programmer_dir} install
+ PKG_CONFIG_PATH="${install_dir}/lib/x86_64-linux-gnu/pkgconfig"
+ LD_LIBRARY_PATH="${install_dir}/lib/x86_64-linux-gnu"
+ fi
done
}

+build_rust () (
+ # Run in a subshell so the exports do not affect other functions
+ export PKG_CONFIG_PATH
+ export LD_LIBRARY_PATH
+ do_for_rust () {
+ git ls-files | grep Cargo.toml \
+ | xargs -r -L1 sh -xc "cargo $* --manifest-path \$0"
+ }
+ # A manual initial run without --offline is required if the dependencies are
+ # not already installed
+ do_for_rust test --offline
+ do_for_rust fmt --check
+ do_for_rust clippy --offline --examples --tests --no-deps
+)

build_make
build_meson
+hash cargo && build_rust

To view, visit change 69770. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I728f5b856a9161b87b96207f4c3965e7493c33d1
Gerrit-Change-Number: 69770
Gerrit-PatchSet: 1
Gerrit-Owner: Evan Benn <evanbenn@google.com>
Gerrit-MessageType: newchange