File: make-depends.sh

package info (click to toggle)
rocq-stdlib 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 11,828 kB
  • sloc: python: 2,928; sh: 444; makefile: 319; javascript: 24; ml: 2
file content (51 lines) | stat: -rwxr-xr-x 1,766 bytes parent folder | download
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
#!/bin/bash

# this should be called from root as
# % dev/tools/make-depends.sh

THEORIES="theories"

declare -A FILE_PKG

# Associate each *.v source file to its corresponding <pkg>,
# according to theories/Make.<pkg>
FILE_PKG["All.v"]="all"
for makefile in theories/Make.* ; do
    PKG=${makefile#theories/Make.}
    for f in $(cat ${makefile} | sed -e 's/#.*//;s/-.*//' | grep -v '^[ \t]*$') ; do
        f=$(echo ${f} | sed -e 's,/_[^/]*,,')
        if [ -n ${FILE_PKG[${f}]:-""} ] ; then
            echo "Error: File ${f} appears in both theories/Make.${FILE_PKG[${f}]} and theories/Make.${PKG}."
            exit 1
        fi
        FILE_PKG[${f}]=${PKG}
    done
done

# Check that each *.v file in theories appears in some <pkg>
for f in $(find ${THEORIES} -name "*.v") ; do
    f=$(echo ${f} | sed -e "s,${THEORIES}/,,")
    if [ -z ${FILE_PKG[${f}]} ] ; then
        echo "Error: File ${f} is not listed in any theories/Make.* file."
        exit 1
    fi
done

# Retrieve dependencies and build graph
(echo "digraph stdlib_deps {";
echo "node [shape=rectangle, style=filled, color=\"#ff540a\", URL=\"#\\N\"];";
rocq dep -Q ${THEORIES} Stdlib ${THEORIES} | sed -n -e 's,/,.,g;s/[.]vo.*: [^ ]*v//p' | \
    while read src dst; do
        src=${src#theories.}
        srcf="$(echo ${src%.vo} | tr '.' '/').v"
        for d in $dst; do
            d=${d#theories.}
            df="$(echo ${d%.vo} | tr '.' '/').v"
            if [ -z ${FILE_PKG[${df}]:-""} ] ; then continue ; fi
            # File dependencies
            # echo "\"(${src}) ${FILE_PKG[${srcf}]}\" -> \"${FILE_PKG[${df}]} (${d%.vo})\" ;"
            # Subcomponent dependencies
            echo "\"${FILE_PKG[${srcf}]}\" -> \"${FILE_PKG[${df}]}\" ;"
        done
    done
echo "}") | tred