-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathgenerate_coqproject.sh
More file actions
executable file
·60 lines (51 loc) · 1.77 KB
/
Copy pathgenerate_coqproject.sh
File metadata and controls
executable file
·60 lines (51 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## List tracked .v files
if [ -e .git ]; then
TRACKED_V_FILES="$(git ls-files "*.v")"
else
# This is expected when building using dune, so don't print the warning in that case:
if [ "$GENERATE_COQPROJECT_FOR_DUNE" != "true" ]; then
echo "Warning: Not a git clone, using find instead" >&2
fi
TRACKED_V_FILES="$(find theories contrib test -type f -name "*.v")"
fi
## List untracked .v files
#UNTRACKED_V_FILES=$(git ls-files --others --exclude-standard "*.v")
## Combine untracked and tracked .v files
printf -v UNSORTED_V_FILES '%s\n%s' "$TRACKED_V_FILES" "$UNTRACKED_V_FILES"
## Sort combined .v files
SORTED_V_FILES=$(echo "$UNSORTED_V_FILES" | sort)
## _CoqProject header
COQPROJECT_HEADER=\
"###############################################################################
# WARNING: This file is autogenerated by the generate_coqproject.sh script
# found in etc/. It is set to be untracked by git.
###############################################################################
-R theories HoTT
-Q contrib HoTT.Contrib
-Q test HoTT.Tests
-arg -noinit
-arg -indices-matter
-arg -allow-rewrite-rules
-arg -native-compiler -arg no
"
## Add additional lines when building with dune
if [ "$GENERATE_COQPROJECT_FOR_DUNE" == "true" ]; then
COQPROJECT_HEADER="$COQPROJECT_HEADER
# Dune compatibility
-R _build/default/theories HoTT
-Q _build/default/contrib HoTT.Contrib
-Q _build/default/test HoTT.Tests
"
fi
## Store new _CoqProject in a variable
printf -v NEW_COQPROJECT '%s\n%s' "$COQPROJECT_HEADER" "$SORTED_V_FILES"
## Look for exisitng _CoqProject
if test -f "_CoqProject"; then
OLD_COQPROJECT=$(cat _CoqProject)
## If it is the same don't overwrite
if [ "$NEW_COQPROJECT" == "$OLD_COQPROJECT" ]; then
exit 0
fi
fi
## Overwrite _CoqProject
echo "$NEW_COQPROJECT" > _CoqProject