Debian Codegraph @

tools/beautify-archive

raw symbols SCIP
1 #!/bin/sh
2
3 #This script compiles and beautifies an archive, check the correctness
4 #of beautified files, then replace the original files by the
5 #beautified ones, keeping a copy of original files in $OLDARCHIVE.
6 #The script assumes:
7 #- that the archive provides a Makefile built by coq_makefile,
8 #- that coqc is in the path or that variables COQTOP and COQBIN are set.
9
10 OLDARCHIVE=old_files
11 NEWARCHIVE=beautify_files
12 BEAUTIFYSUFFIX=.beautified
13
14 if [ -e $OLDARCHIVE ]; then
15 echo "Warning: $OLDARCHIVE directory found, the files are maybe already beautified";
16 sleep 5;
17 fi
18 echo ---- Producing beautified files in the beautification directory -------
19 if [ -e $NEWARCHIVE ]; then rm -r $NEWARCHIVE; fi
20 if [ -e /tmp/$OLDARCHIVE.$$ ]; then rm -r /tmp/$OLDARCHIVE.$$; fi
21 cp -pr . /tmp/$OLDARCHIVE.$$
22 cp -pr /tmp/$OLDARCHIVE.$$ $NEWARCHIVE
23 cd $NEWARCHIVE
24 rm description || true
25 make clean
26 make COQFLAGS='-beautify -q $(OPT) $(COQLIBS) $(OTHERFLAGS)' || \
27 { echo ---- Failed to beautify; exit 1; }
28 echo -------- Upgrading files in the beautification directory --------------
29 beaufiles=`find . -name \*.v$BEAUTIFYSUFFIX`
30 for i in $beaufiles; do
31 j=`dirname $i`/`basename $i .v$BEAUTIFYSUFFIX`.v
32 echo Upgrading $j in the beautification directory
33 if [ $i -nt $j ]; then mv -f $i $j; fi
34 done
35 echo ---- Recompiling beautified files in the beautification directory -----
36 make clean
37 make || { echo ---- Failed to recompile; exit 1; }
38 echo ----- Saving old files in directory $OLDARCHIVE -------------------------
39 /bin/rm -r ../$OLDARCHIVE
40 mv /tmp/$OLDARCHIVE.$$ ../$OLDARCHIVE
41 echo Saving $OLDARCHIVE files done
42 echo --------- Upgrading files in current directory ------------------------
43 vfiles=`find . -name \*.v`
44 cd ..
45 for i in $vfiles; do
46 echo Upgrading $i in current directory
47 if [ $NEWARCHIVE/$i -nt $i ]; then mv -f $NEWARCHIVE/$i $i; fi
48 done
49 echo -------- Beautification completed -------------------------------------
50 echo Old files are in directory '"'$OLDARCHIVE'"'
51 echo New files are in current directory
52 echo You can now remove the beautification directory '"'$NEWARCHIVE'"'