Debian Codegraph @

tools/beautify-archive

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/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 [scip-shell system . . `[`. -e $OLDARCHIVE ]; then
15 echoscip-shell system . . echo. "Warning: $OLDARCHIVE directory found, the files are maybe already beautified";
16 sleepscip-shell system . . sleep. 5;
17 fi
18 echoscip-shell system . . echo. ---- Producing beautified files in the beautification directory -------
19 if [scip-shell system . . `[`. -e $NEWARCHIVE ]; then rmscip-shell system . . rm. -r $NEWARCHIVE; fi
20 if [scip-shell system . . `[`. -e /tmp/$OLDARCHIVE.$$ ]; then rmscip-shell system . . rm. -r /tmp/$OLDARCHIVE.$$; fi
21 cpscip-shell system . . cp. -pr . /tmp/$OLDARCHIVE.$$
22 cpscip-shell system . . cp. -pr /tmp/$OLDARCHIVE.$$ $NEWARCHIVE
23 cd $NEWARCHIVE
24 rmscip-shell system . . rm. description || truescip-shell system . . true.
25 makescip-shell system . . make. clean
26 makescip-shell system . . make. COQFLAGS='-beautify -q $(OPT) $(COQLIBS) $(OTHERFLAGS)' || \
27 { echoscip-shell system . . echo. ---- Failed to beautify; exit 1; }
28 echoscip-shell system . . echo. -------- Upgrading files in the beautification directory --------------
29 beaufiles=`findscip-shell system . . find. . -name \*.v$BEAUTIFYSUFFIX`
30 for i in $beaufiles; do
31 j=`dirnamescip-shell system . . dirname. $i`/`basenamescip-shell system . . basename. $i .v$BEAUTIFYSUFFIX`.v
32 echoscip-shell system . . echo. Upgrading $j in the beautification directory
33 if [scip-shell system . . `[`. $i -nt $j ]; then mvscip-shell system . . mv. -f $i $j; fi
34 done
35 echoscip-shell system . . echo. ---- Recompiling beautified files in the beautification directory -----
36 makescip-shell system . . make. clean
37 makescip-shell system . . make. || { echoscip-shell system . . echo. ---- Failed to recompile; exit 1; }
38 echoscip-shell system . . echo. ----- Saving old files in directory $OLDARCHIVE -------------------------
39 /bin/rmscip-shell filesystem . . `/bin/rm`. -r ../$OLDARCHIVE
40 mvscip-shell system . . mv. /tmp/$OLDARCHIVE.$$ ../$OLDARCHIVE
41 echoscip-shell system . . echo. Saving $OLDARCHIVE files done
42 echoscip-shell system . . echo. --------- Upgrading files in current directory ------------------------
43 vfiles=`findscip-shell system . . find. . -name \*.v`
44 cd ..
45 for i in $vfiles; do
46 echoscip-shell system . . echo. Upgrading $i in current directory
47 if [scip-shell system . . `[`. $NEWARCHIVE/$i -nt $i ]; then mvscip-shell system . . mv. -f $NEWARCHIVE/$i $i; fi
48 done
49 echoscip-shell system . . echo. -------- Beautification completed -------------------------------------
50 echoscip-shell system . . echo. Old files are in directory '"'$OLDARCHIVE'"'
51 echoscip-shell system . . echo. New files are in current directory
52 echoscip-shell system . . echo. You can now remove the beautification directory '"'$NEWARCHIVE'"'