diff options
author | Jeremy Bettis <jbettis@google.com> | 2022-02-22 10:03:25 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-24 23:38:41 +0000 |
commit | 02e0147ca073cd7228be0509d0341cabb013e677 (patch) | |
tree | 6ab3264887f9ffa9a13d2ac54cf05c600ae247e6 | |
parent | 68dcfd9a742648565018f43fc5e0f2732cdb98bd (diff) | |
download | chrome-ec-02e0147ca073cd7228be0509d0341cabb013e677.tar.gz |
presubmit: Add warning on edit of non-zephyr code
Add presubmit to repo upload that will check that all C files in the cl
are actually used in the Zephyr EC. If any of the edited files are not
actually part of the Zephyr builds, print a warning message for the
user.
This is to satisfy the goal to prevent people from accidentally making
changes in a legacy EC driver when we've already migrated that code to
Zephyr.
I excluded the baseboard, board, and chip dirs, since they are clearly
not zephyr code. Excluded test and util since those aren't ec code. And
exclude the zephyr dir, since obviously that is zephyr code.
BRANCH=None
BUG=b:205759844
TEST=Edited several included and not-included files and made sure the
warning only applied to the non-included files.
Change-Id: Ida4f6702a1408004e3a98a057c6c472247feff25
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3481575
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r-- | PRESUBMIT.cfg | 1 | ||||
-rwxr-xr-x | util/migrated_files.sh | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg index b949d10c6d..c726f14214 100644 --- a/PRESUBMIT.cfg +++ b/PRESUBMIT.cfg @@ -28,3 +28,4 @@ config_option_check = util/config_option_check.py host_command_check = util/host_command_check.sh ec_commands_h = util/linux_ec_commands_h_check.sh zmake_preupload = zephyr/zmake/pre-upload.sh ${PRESUBMIT_FILES} +migrated_files = util/migrated_files.sh ${PRESUBMIT_FILES} diff --git a/util/migrated_files.sh b/util/migrated_files.sh new file mode 100755 index 0000000000..7652889074 --- /dev/null +++ b/util/migrated_files.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright 2022 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +mapfile -d '' cmakes < <(find zephyr \( -path zephyr/test -prune \) -o \ + -name CMakeLists.txt -print0) + +exit_code=0 + +for file in "$@"; do + ec_file="${file##**/platform/ec/}" + case "${ec_file}" in + baseboard/*|board/*|chip/*|test/*|util/*|zephyr/*) ;; + **.c) + if ! grep -q -F "\${PLATFORM_EC}/${ec_file}" "${cmakes[@]}" ; then + echo -n "WARNING: ${ec_file} is not used in Zephyr EC. Do not edit this" + echo -n " unless you also find the zephyr copy and fix the same code" + echo " there." + exit_code=1 + fi + ;; + esac +done + +exit "${exit_code}" |