From 0f2248ef68f507e68dec06c0f6e68e2c2c1df0fb Mon Sep 17 00:00:00 2001
From: Ralf Jung <jung@mpi-sws.org>
Date: Thu, 3 Jun 2021 12:18:57 +0200
Subject: [PATCH] move our style checks into separate file

---
 Makefile.coq.local |  6 +++---
 coq-lint.sh        | 12 ++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
 create mode 100755 coq-lint.sh

diff --git a/Makefile.coq.local b/Makefile.coq.local
index ad626496..50fa0800 100644
--- a/Makefile.coq.local
+++ b/Makefile.coq.local
@@ -7,12 +7,12 @@ MAKE_REF:=
 # Run tests interleaved with main build.  They have to be in the same target for this.
 real-all: style $(if $(NO_TEST),,test)
 
-style: $(VFILES)
-# Make sure everything imports the options, and all Instance/Argument/Hint are qualified.
+style: $(VFILES) coq-lint.sh
+# Make sure everything imports the options, and some general linting.
 	$(SHOW)"Performing some style checks..."
 	$(HIDE)for FILE in $(VFILES); do \
 	  if ! fgrep -q 'From stdpp Require Import options.' "$$FILE"; then echo "ERROR: $$FILE does not import 'options'."; echo; exit 1; fi ; \
-	  if egrep -n '^\s*((Existing\s+|Program\s+)Instance|Arguments|Remove|Hint\s+(Extern|Constructors|Resolve|Immediate|Mode|Opaque|Transparent|Unfold)|(Open|Close)\s+Scope|Opaque|Transparent)\b' "$$FILE"; then echo "ERROR: $$FILE contains 'Instance'/'Arguments'/'Hint' or another side-effect without locality (see above)."; echo "Please add 'Global' or 'Local' as appropriate."; echo; exit 1; fi \
+	  ./coq-lint.sh "$$FILE"; \
 	done
 .PHONY: style
 
diff --git a/coq-lint.sh b/coq-lint.sh
new file mode 100755
index 00000000..18a36ade
--- /dev/null
+++ b/coq-lint.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+set -e
+## A simple shell script checking for some common Coq issues.
+
+FILE="$1"
+
+if egrep -n '^\s*((Existing\s+|Program\s+)Instance|Arguments|Remove|Hint\s+(Extern|Constructors|Resolve|Immediate|Mode|Opaque|Transparent|Unfold)|(Open|Close)\s+Scope|Opaque|Transparent)\b' "$FILE"; then
+    echo "ERROR: $FILE contains 'Instance'/'Arguments'/'Hint' or another side-effect without locality (see above)."
+    echo "Please add 'Global' or 'Local' as appropriate."
+    echo
+    exit 1
+fi
-- 
GitLab