Starting to switch aliases and some convenience scripts from Buck to Bazel.
Change-Id: I2e0a0dac882af430b8628174f3f97a1777d3e643
diff --git a/tools/build/onos-blackduck-zip b/tools/build/onos-blackduck-zip
deleted file mode 100755
index 8760460..0000000
--- a/tools/build/onos-blackduck-zip
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Packages specific ONOS codebase with specific tag or branch
-# -----------------------------------------------------------------------------
-
-# Bail on any errors
-set -e
-
-# Initialize environment variables
-init() {
- # Check if ONOS_ROOT is defined
- [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1;
-
- # Setup some environmental context for developers
- if [ -z "${JAVA_HOME}" ]; then
- if [ -x /usr/libexec/java_home ]; then
- export JAVA_HOME=$(/usr/libexec/java_home -v 1.8);
- elif [ -d /usr/lib/jvm/java-8-oracle ]; then
- export JAVA_HOME="/usr/lib/jvm/java-8-oracle";
- elif [ -d /usr/lib/jvm/java-8-openjdk-amd64 ]; then
- export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64";
- fi
- fi
- # Check if mvn exists
- command -v mvn >/dev/null 2>&1 || {
- # Following the convention, the default location of maven shows as below.
- MAVEN=${MAVEN:-~/Applications/apache-maven-3.3.9};
- export PATH="$MAVEN/bin:$PATH";
- }
-}
-
-# checkout $TAG, build project and copy it to other location
-check_copy() {
- CHECK_TAG=`git checkout $TAG`
- if [[ $CHECK_TAG =~ "error" ]]; then
- echo "There is no branch or tag named $TAG in $ONOS_ROOT" >&2 && exit 1
- fi
- FOLDER=$CURRENT_PATH/onos-$TAG-blackduck
- [ -d "$FOLDER" ] && rm -r $FOLDER
- mkdir $FOLDER
- mvn clean install
- if [ $? -eq 0 ]; then
- cp -r -a * $FOLDER;
- if [ -d "$FOLDER/.git" ]; then
- rm -r $FOLDER/.git
- fi;
- else
- git checkout $CURRENT_TAG;
- rm -r $FOLDER
- echo "mvn compilation failed"
- fi
-}
-
-# Script entry point
-CURRENT_PATH=`pwd`
-TAG=${1:-'master'}
-
-init
-cd $ONOS_ROOT
-CURRENT_TAG=`git branch | awk '{print $2}'`
-check_copy
-cd $FOLDER
-zip -rq -m $CURRENT_PATH/onos-$TAG-blackduck.zip *
-cd ..
-rm -r $FOLDER
-
-cd $ONOS_ROOT
-git checkout $CURRENT_TAG
diff --git a/tools/build/onos-build b/tools/build/onos-build
index b3ff8d4..ef00940 100755
--- a/tools/build/onos-build
+++ b/tools/build/onos-build
@@ -3,5 +3,4 @@
# Builds the ONOS from source.
# -----------------------------------------------------------------------------
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-cd $ONOS_ROOT && onos-buck build onos && onos-buck test --only-failing
+SHLVL=1 bazel build //:onos
diff --git a/tools/build/onos-build-docs b/tools/build/onos-build-docs
index cdac83f..3be4c0a 100755
--- a/tools/build/onos-build-docs
+++ b/tools/build/onos-build-docs
@@ -1,11 +1,6 @@
#!/bin/bash
# -----------------------------------------------------------------------------
-# Builds the ONOS Java API docs.
+# Builds the aggregate ONOS Java API docs.
# -----------------------------------------------------------------------------
-set -e
-
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-. $ONOS_ROOT/tools/build/envDefaults
-
-onos-buck build //docs:external //docs:internal --show-output
+SHLVL=1 bazel build //docs:external //docs:internal
diff --git a/tools/build/onos-package b/tools/build/onos-package
index 9d3a747..aaa717a 100755
--- a/tools/build/onos-package
+++ b/tools/build/onos-package
@@ -1,7 +1,6 @@
#!/bin/bash
# -----------------------------------------------------------------------------
-# Packages ONOS distributable into onos.tar.gz, onos.zip or a deb file
+# Packages ONOS distributable into onos.tar.gz file
# -----------------------------------------------------------------------------
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-cd $ONOS_ROOT && onos-buck build onos --deep --show-output && onos-check-bits
+SHLVL=1 bazel build //:onos && onos-check-bits
diff --git a/tools/build/onos-package-test b/tools/build/onos-package-test
deleted file mode 100755
index 3f4fd41..0000000
--- a/tools/build/onos-package-test
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Packages ONOS test facilities into onos-test.tar.gz
-# -----------------------------------------------------------------------------
-
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-. $ONOS_ROOT/tools/build/envDefaults
-
-cd $ONOS_ROOT && onos-buck build //:onos-test --show-output && \
- rm -f $ONOS_TEST_TAR && \
- ln -s $ONOS_ROOT/buck-out/gen/onos-test/onos-test-*.tar.gz $ONOS_TEST_TAR
diff --git a/tools/dev/bash_profile b/tools/dev/bash_profile
index 985ed13..34c6b69 100644
--- a/tools/dev/bash_profile
+++ b/tools/dev/bash_profile
@@ -4,6 +4,7 @@
# Root of the ONOS source tree
export ONOS_ROOT=${ONOS_ROOT:-~/onos}
+
# This is a hack to remove symlinks from the ONOS_ROOT path. To be removed when
# the protobuf buck rules can handle symlinks
ONOS_ROOT=$(pushd $ONOS_ROOT >/dev/null && pwd -P && popd >/dev/null)
@@ -50,7 +51,7 @@
# Convenience utility to warp to various ONOS source projects
# e.g. 'o api', 'o dev', 'o'
function o {
- cd $(find $ONOS_ROOT/ -type d -and \( -name 'buck-out' -o -name '.git' -o -name 'target' -o -name 'gen-src' -o -name 'src' \) -prune -o -type d | \
+ cd $(find $ONOS_ROOT/ -type d -and \( -name 'bazel-*' -o -name 'buck-out' -o -name '.git' -o -name 'target' -o -name 'gen-src' -o -name 'src' \) -prune -o -type d | \
egrep "${1:-$ONOS_ROOT}" | awk '{print length($1)"\t"$1}' | sort -n | cut -f2 | head -n 1)
}
@@ -58,21 +59,13 @@
[ -z "$(which buck)" ] && alias buck="onos-buck"
# Short-hand for ONOS build, package and test.
-alias ob='onos-build'
-alias obf='(cd $ONOS_ROOT && onos-buck build onos)'
-alias obd='onos-build-docs'
-alias op='onos-package'
-alias ot='onos-test'
+alias op="SHLVL=1 bazel build //:onos"
+alias ot="bazel query 'tests(//...)' | SHLVL=1 xargs bazel test"
+alias ob="op && ot"
+alias obd="SHLVL=1 bazel build //docs:external //docs:internal"
-alias obr='while ! ob; do echo "retrying"; done'
-alias opr='while ! op; do echo "retrying"; done'
-
-alias deprecatedAlias='echo "This alias has been deprecated."'
-alias obi=deprecatedAlias
-alias obs=deprecatedAlias
-
-alias ok='NO_BUCKD=1 onos-buck run onos-local --'
-alias oh='onos localhost halt'
+alias ok="SHLVL=1 bazel run onos-local --"
+alias oh="onos localhost halt"
alias ol='onos-log'
alias ow='onos-watch'
@@ -105,8 +98,6 @@
# Short-hand for 'mvn clean install' for us lazy folk
alias mci='mvn clean install'
-alias mcis='mvn clean install -DskipTests -Dcheckstyle.skip'
-alias mis='mvn install -DskipTests -Dcheckstyle.skip'
# Git annotated one-line log
alias gil='git log --oneline --decorate=short'