blob: 9e590d7c6f387b47901de717f5792d8a28945815 [file] [log] [blame]
Thomas Vachuska692dcb02017-03-15 09:13:50 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Patches lib/BUCK file to use locally built YANG tools.
4# -----------------------------------------------------------------------------
5
Ray Milkeyd82b5822017-11-30 10:54:16 -08006BVER=2.3.1
Yuta HIGUCHI74681b52017-11-15 14:50:51 -08007SVER=2.4-SNAPSHOT
Thomas Vachuska692dcb02017-03-15 09:13:50 -07008
Yuta HIGUCHI4421dd22017-08-10 18:08:37 -07009YANG_TOOLS_ROOT=${YANG_TOOLS_ROOT:-~/onos-yang-tools}
Thomas Vachuska692dcb02017-03-15 09:13:50 -070010
11rm -f $ONOS_ROOT/lib/yang/* 2>/dev/null
12mkdir -p $ONOS_ROOT/lib/yang
13
14awk '
15 BEGIN { m = 0; y = 0; }
16 /^(remote_jar|prebuilt_jar)/ { s = $0; m = 1; next; }
17 { if (m) { s = s "\n" $0; } else { print $0; } }
18 /onos-yang-.*('$BVER'|'$SVER')/ { y = 1; }
19 /^\)/ { if (m && !y) { print s; } y = 0; m = 0; }
20' $ONOS_ROOT/lib/BUCK > /tmp/BUCK
21mv /tmp/BUCK $ONOS_ROOT/lib/BUCK
22
23for yl in $(egrep "onos-yang-.*$BVER" $ONOS_ROOT/lib/deps.json); do
24 n=$(echo $yl | cut -d\" -f2)
25 m=$(echo $yl | cut -d\" -f4)
Thomas Vachuska411de782017-07-18 14:22:38 -070026 m=${m/$BVER/$SVER}
Thomas Vachuska692dcb02017-03-15 09:13:50 -070027 j=$(find $YANG_TOOLS_ROOT -name $n-$SVER.jar)
28 s=yang/$(basename $j)
29 cp $j $ONOS_ROOT/lib/$s
30
31 # echo $n, $m, $j
32
33 cat <<EOF >>$ONOS_ROOT/lib/BUCK
34prebuilt_jar (
35 name = '$n',
36 binary_jar = '$s',
37 maven_coords = '${m#mvn:*}',
38 visibility = [ 'PUBLIC' ],
39)
40
41EOF
42done
Thomas Vachuskac32dfba2017-07-18 16:01:40 -070043
Yuta HIGUCHI9e11b092017-08-11 13:51:47 -070044YANG_PLUGIN_SRC=$YANG_TOOLS_ROOT/compiler/plugin/buck/target/onos-yang-compiler-buck-plugin-$SVER.jar
45if [ ! -f "$YANG_PLUGIN_SRC" ]; then
46 mvn -f $YANG_TOOLS_ROOT/pom.xml -am -pl :onos-yang-compiler-buck-plugin install -DskipTests -Dcheckstyle.skip
47fi
Thomas Vachuskac32dfba2017-07-18 16:01:40 -070048# Patch the YANG BUCK plugin
Yuta HIGUCHI9e11b092017-08-11 13:51:47 -070049cp -p $YANG_PLUGIN_SRC \
Thomas Vachuskac32dfba2017-07-18 16:01:40 -070050 $ONOS_ROOT/bin/plugins/yang.jar