From cc24c35c5be1967de520df60015a661b1dd6eb4c Mon Sep 17 00:00:00 2001 From: Eric Kunze Date: Tue, 24 Aug 2021 14:11:47 -0700 Subject: Use pre-commit to catch out of date headers Signed-off-by: Eric Kunze Change-Id: I65983e5ddee7e4b1870530c2fb947177f5d4ca48 --- .pre-commit-config.yaml | 11 ++++++++++- regenerate_headers.sh | 14 ++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55d630f..4b4af7a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,15 @@ repos: - id: black exclude: python/tosa +- repo: local + hooks: + - id: regenerate-headers + name: regenerate-headers + language: system + entry: ./regenerate_headers.sh + pass_filenames: false + always_run: true + - repo: local hooks: - id: clang-format @@ -32,4 +41,4 @@ repos: language: system entry: clang-format types: ["c++"] - args: ["-i"] \ No newline at end of file + args: ["-i"] diff --git a/regenerate_headers.sh b/regenerate_headers.sh index a7d2141..9fef94b 100755 --- a/regenerate_headers.sh +++ b/regenerate_headers.sh @@ -14,22 +14,24 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Bail if any of the commands fail +set -e if test -f "third_party/flatbuffers/flatc"; then echo "Found flatc, skip building..." else echo "flatc not found, building now..." - pushd third_party/flatbuffers/ + pushd third_party/flatbuffers/ > /dev/null cmake . make flatc -j8 - popd + popd > /dev/null fi -pushd include/ +pushd include/ > /dev/null ../third_party/flatbuffers/flatc --cpp ../schema/tosa.fbs -popd -pushd python/ +popd > /dev/null +pushd python/ > /dev/null ../third_party/flatbuffers/flatc --python ../schema/tosa.fbs -popd +popd > /dev/null -- cgit v1.2.1