-
Notifications
You must be signed in to change notification settings - Fork 1
/
cruxcompile
executable file
·73 lines (60 loc) · 1.35 KB
/
cruxcompile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Usage: ./compile "brewerslab integrationtest"
one=$1
NEW_PYTHON_PATH="blng:$PYTHONPATH"
yanglist=""
timeyangchanged=`stat -f %m yang`
timelastcompiled=`stat -f %m crux-example.xml`
if [ $timelastcompiled -gt $timeyangchanged ]
then
if [ -d .cache ]
then
echo "No changes in the yang - skipping compile"
exit 0
fi
fi
#rm -fr .cache
mkdir -p .cache
set -euo pipefail
IFS=$'\n\t'
echo "Creating YIN files...."
cd yang
for file in *.yang
do
yin=`echo $file | sed -e 's/.yang$//'`
timeyangchanged=`stat -f %m $file`
if [ -f ../.cache/$yin.yin ]
then
timelastcompiled=`stat -f %m ../.cache/$yin.yin`
else
timelastcompiled=0
fi
if [ $timelastcompiled -gt $timeyangchanged ]
then
echo " ($file) using cached version"
else
echo " $file"
pyang -f yin $file >../.cache/$yin.yin
pyang -f tree $file >$yin.txt
fi
yanglist="$yin $yanglist"
done
echo "Converting to CRUX files...."
cd ../
if [ "$one" = "" ]
then
yangmodules=$yanglist
else
yangmodules=$1
fi
timeyangchanged=`stat -f %m .cache`
timelastcompiled=`stat -f %m crux-example.xml`
if [ $timelastcompiled -lt $timeyangchanged ]
then
PYTHONPATH=$NEW_PYTHON_PATH python blng/Yang.py $yangmodules
echo "Combining into single document"
xmllint --format .cache/__crux-schema.xml >crux-example.xml
else
echo " Using cached version"
fi
echo " OK"