blob: 7183414e2e1f37c076af44ab01afca592dd85709 [file] [log] [blame]
#!/bin/bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Returns 0 if there are no changes or untracked files, 1 otherwise.
# Show the diff on STDOUT if there's deviation.
is_clean() {
local output
output="$(git status --porcelain)" || return 1
test -z "$output" && return 0
echo Diff between the regenerated content and the content in this PR/the repository:
git diff
return 1
}
# Clean up the repo so that we can check further auto-generated stuff
cleanup() {
git clean -fxd >/dev/null
git reset --hard >/dev/null
}
# Run a command and then check the tree is still clean. Print a message if not.
gen_and_check_clean() {
thing="$1"
shift
"$@" || {
echo -n "##vso[task.logissue type=error]"
echo "Failed to auto-generate $thing. (command: '$@')"
echo
cleanup
return 1
}
is_clean || {
echo -n "##vso[task.logissue type=error]"
echo "Auto-generated $thing not up-to-date. Regenerate with '$@'."
echo
cleanup
return 1
}
}
# A specialized version of gen_and_check_clean for targets of the Makefile in hw
gen_hw_and_check_clean() {
gen_and_check_clean "$1" make -k -C hw "$2"
}
# Check generated files are up to date
bad=0
cleanup
gen_hw_and_check_clean "Register headers" regs || bad=1
gen_hw_and_check_clean "tops" top || bad=1
gen_hw_and_check_clean "OTP memory map" otp-mmap || bad=1
gen_hw_and_check_clean "LC state" lc-state-enc || bad=1
gen_and_check_clean \
"flash_ctrl code" \
hw/ip/flash_ctrl/util/flash_ctrl_gen.py || bad=1
gen_and_check_clean \
"secded primitive code" \
util/design/secded_gen.py --no_fpv || bad=1
gen_and_check_clean \
"DIFs" \
util/make_new_dif.py --mode=regen --only=autogen || bad=1
gen_and_check_clean "MUBI package" util/design/gen-mubi.py || bad=1
exit $bad