#!/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/*|common/fpsensor/*|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}"

#!/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/*|*fpsensor*|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}"

Exclude *fpsensor* from Zephyr migrate hook
[test] Exclude *fpsensor* from Zephyr migrate hook

Files from common/mock/fpsensor_* and include/mock/fpsensor_* were
still getting caught in the precommit hook. I initially considered
adding these paths to the exclusion list but it seemed to make more
sense to just exclude everything with fpsensor in the name, as FPMCU
presently does not support Zephyr.

BRANCH=none
BUG=none
TEST=util/migrated_files.sh common/mock/fpsensor_state_mock.c
     successfully ignores the file
TEST=util/migrated_files.sh common/mock/somethingelse.c
     successfully reports warning

Signed-off-by: Bobby Casey <a3c107f0b4efaee07148ab0813ba992bba562a69@google.com>
Change-Id: I40a87c2e44a1feeec9eae43046fcbf6978190356
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3838933
Reviewed-by: Tom Hughes <fc5c12f30a5ed2baa0581f44ee14ad1eb7b20d83@chromium.org>
Reviewed-by: Jeremy Bettis <4df7b5147fee087dca33c181f288ee7dbf56e022@chromium.org>
