forked from jamestiotio/sparrow-cantrip-full
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preupload-clippy.sh
executable file
·67 lines (59 loc) · 2.3 KB
/
preupload-clippy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/bash
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Wrapper script for running cargo clippy check for preupload.
set -ex
if [[ -z ${ROOTDIR} ]]; then
echo "Source build/setup.sh first"
exit 1
fi
# TODO(sleffler): Replace the following with `make -C ${ROOTDIR}/build cantrip-clippy`
RUST_TARGET=${RUST_TARGET:-riscv32imac-unknown-none-elf}
CONFIG_PLATFORM=${CONFIG_PLATFORM:-CONFIG_PLAT_SPARROW}
export CANTRIP_TARGET_ARCH=${CANTRIP_TARGET_ARCH:-"riscv32-unknown-elf"}
CANTRIP_OUT_DIR="${OUT}/cantrip/${CANTRIP_TARGET_ARCH}"
mkdir -p "${CANTRIP_OUT_DIR}/clippy"
# HACK: sel4-config needs a path to the kernel build which could be
# in debug or release. Check the debug kernel first.
export SEL4_OUT_DIR=${SEL4_OUT_DIR:-"${CANTRIP_OUT_DIR}/debug/kernel"}
if [[ ! -d "${SEL4_OUT_DIR}/gen_config" ]]; then
export SEL4_OUT_DIR="${CANTRIP_OUT_DIR}/release/kernel"
if [[ ! -d "${SEL4_OUT_DIR}/gen_config" ]]; then
echo "No kernel build found at ${CANTRIP_OUT_DIR}; build cantrip-bundle-debug first."
exit 1
fi
fi
declare -a CRATE_LIST=(
apps/system/components/DebugConsole
apps/system/components/MailboxDriver
apps/system/components/MemoryManager
apps/system/components/MlCoordinator
apps/system/components/ProcessManager
apps/system/components/SDKRuntime
apps/system/components/SecurityCoordinator
apps/system/components/TimerService
apps/system/components/UARTDriver
)
# Run clippy that fails at warnings.
for crate in ${CRATE_LIST[@]}; do
pushd ${crate} > /dev/null
${CARGO_HOME}/bin/cargo +${CANTRIP_RUST_VERSION} clippy \
-Z unstable-options -Z avoid-dev-deps \
--target ${RUST_TARGET} --features=${CONFIG_PLATFORM} \
--target-dir ${CANTRIP_OUT_DIR}/clippy -- \
-D warnings \
-A clippy::uninlined_format_args
popd > /dev/null
done