Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 156 lines (127 sloc) 3.533 kB
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored
1 #!/usr/bin/env bash
fccc685 Initial open-source release
MLstate authored
2
3 # This script is used for generating opa files and packages dependency graphs
4 # It is meant to be called from any directory containing some .opx/ directories
5 # it also looks for dot files in any found opx directory (MLSTATELIBS + current directory)
6 # and call odeplink for adding hyper links.
7 # it generates a directory _opadep/ in the current directory.
8
9 OPADEP=_opadep
10
11 # subdirectory of packages
12 # <!> Keep synchronized with compiler/installDir
13 OPA_PACKAGES='lib/opa/stdlib'
14
15 help() {
16 cat <<EOF
17 opadep.sh: generate OPA packages dependency graphs.
a8578f5 @aszlig [fix] compilerlib: Spelling corrections.
aszlig authored
18 Packages are expected to be found in the following folders :
19 . all packages previously compiled in the current path
fccc685 Initial open-source release
MLstate authored
20 MLSTATELIBS/$OPA_PACKAGES all installed packages
21
22 it generates a folder $OPADEP/ containing the resulting graphs.
23
24 Options:
25 --help|-h|help displays this help
26 -o <directory> specify a custom directory instead of $OPADEP
27 -I <directory> add directory to include packages
28 -n do not compute dependencies, assume that the index was already generated
29 -d add some log for debug
30
31 EOF
32 }
33
34 COMPUTE=true
35 DEBUG=false
36 INCLUDES=''
37 OPAINCLUDES=''
38
39 while [ "$#" -gt 0 ]; do
40 case "$1" in
41 # h
42 -h|--help|help)
43 help
44 exit 0
45 ;;
46
47 -d)
48 DEBUG=true
49 ;;
50
51 -o)
52 if [ -z "$2" ]; then warn "Error: option $1 requires an argument"; exit 1; fi
53 shift
54 OPADEP="$1"
55 ;;
56
57 -I)
58 if [ -z "$2" ]; then warn "Error: option $1 requires an argument"; exit 1; fi
59 shift
60 INCLUDES="$INCLUDES $1"
61 OPAINCLUDES="$OPAINCLUDES -I $1"
62 ;;
63
64 -n)
65 COMPUTE=false
66 ;;
67
68 *)
69 echo "[!] error: unknown option $1"
70 help
71 exit 1
72 esac
73 shift
74 done
75
76
77 if [ "$COMPUTE" = true ] ; then
78 tmp=$(mktemp /tmp/fileXXXXX)
79 rm $tmp
80 all="$tmp".opa
81
82 cat > $all <<EOF
83 import *
84 EOF
85
86 echo "odep: Global Dependencies Graph"
87 opa --verbose-build $OPAINCLUDES --odep $all
88 fi
89
90 echo "creating directory $OPADEP"
91 mkdir -p $OPADEP
92
93 cp *.dot $OPADEP/.
94
95 echo "odep: Get Subgraphs From Packages"
96 ALLOPX=''
97 LOCATIONS="$MLSTATELIBS/$OPA_PACKAGES . $INCLUDES"
98
99 for loc in $LOCATIONS ; do
100 if [ "$DEBUG" = true ] ; then
101 echo "checking for opx in loc: $loc"
102 fi
103 opx=$(find $loc -maxdepth 1 -name '*.opx')
104 if [ "$DEBUG" = true ] ; then
105 echo "finding: $opx"
106 fi
107 ALLOPX="$ALLOPX $opx"
108 done
109
110 for opx in $ALLOPX ; do
111 if [ "$DEBUG" = true ] ; then
112 echo "checking for dot in $opx"
113 ls $opx/*.dot
114 else
115 ls $opx/*.dot 1> /dev/null 2> /dev/null
116 fi
117 code=$?
118 if [ "$code" = 0 ] ; then
119 if [ "$DEBUG" = true ] ; then
120 cp -v $opx/*.dot $OPADEP/.
121 else
122 cp $opx/*.dot $OPADEP/.
123 fi
124 fi
125 done
126
127 cd $OPADEP
128 ROOT=$(pwd)
129
130 echo "opadep: Transitive Reduction"
131 mkdir -p full
132 mkdir -p tred
133 for dot in *.dot ; do
134 # transitive reduction
135 tred $dot > tred/$dot 2> /dev/null
136 mv $dot full/$dot
137 done
138
139 echo "opadep: DOT to SVG (+odeplink)"
140 cd full
141 for dot in *.dot ; do
142 base=$(basename $dot .dot)
143 dot -Tsvg $dot > $base.svg
144 done
145 odeplink *.svg
146
147 cd $ROOT
148 cd tred
149 for dot in *.dot ; do
150 base=$(basename $dot .dot)
151 dot -Tsvg $dot > $base.svg
152 done
153 odeplink *.svg
154
a8578f5 @aszlig [fix] compilerlib: Spelling corrections.
aszlig authored
155 echo "opadep: Successful generation of graphs in $OPADEP/"
Something went wrong with that request. Please try again.