Thomas Vachuska | ad37e37 | 2017-08-03 12:07:01 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Compiles Java code generated by the YANG compiler. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | sources=${1:-src} |
| 7 | classes=${2:-classes} |
| 8 | modelId=${3:-org.onosproject.model.unknown} |
| 9 | |
| 10 | # Stage the YANG sources and the YANG schema meta-data |
| 11 | mkdir -p $classes/yang/resources |
| 12 | cp $sources/schema/* $classes/yang/resources |
| 13 | |
| 14 | root=${root:-system} |
| 15 | op="$root/org/onosproject" |
| 16 | |
| 17 | function findLib() { |
| 18 | find $1/$2 -name "$2-*.jar" |
| 19 | } |
| 20 | |
| 21 | classPath="$(findLib $op onos-yang-model)" |
| 22 | classPath="$classPath:$(findLib $op onos-yang-runtime)" |
| 23 | classPath="$classPath:$(findLib $op onos-yang-compiler-api)" |
| 24 | classPath="$classPath:$(findLib $op onos-apps-yang)" |
| 25 | |
| 26 | package=${modelId//./\/} |
| 27 | mkdir -p $sources/src/$package |
| 28 | sed "s/PACKAGE/$modelId/g" $(dirname $0)/YangModelRegistrator.java \ |
| 29 | > $sources/src/$package/YangModelRegistrator.java |
| 30 | |
| 31 | # Compile the generated java code |
| 32 | find $sources/src -name '*.java' > $sources/javaFiles |
| 33 | javac -source 1.8 -target 1.8 \ |
| 34 | -sourcepath "$sources/src" -classpath "$classPath" -d "$classes" \ |
| 35 | @$sources/javaFiles |