[WIP] Attempt at building grpc and p4runtime protocols with Bazel

STILL NOT WORKING AT RUNTIME

Change-Id: I1f9e60b12a12e09edad2a714ec2921a4f71c6d35
diff --git a/protocols/grpc/BUCK b/protocols/grpc/BUCK
index e5e65e1..093ea7d 100644
--- a/protocols/grpc/BUCK
+++ b/protocols/grpc/BUCK
@@ -16,16 +16,16 @@
     '//lib:protobuf-java-3.2.0',
     # Lazily adding all netty-related packages.
     # Some of them might not be necessary.
-    '//lib:netty',
-    '//lib:netty-buffer',
-    '//lib:netty-codec',
-    '//lib:netty-codec-http',
-    '//lib:netty-codec-http2',
-    '//lib:netty-common',
-    '//lib:netty-handler',
-    '//lib:netty-transport',
-    '//lib:netty-transport-native-epoll',
-    '//lib:netty-resolver',
+    '//lib:io_netty_netty',
+    '//lib:io_netty_netty_buffer',
+    '//lib:io_netty_netty_codec',
+    '//lib:io_netty_netty_codec-http',
+    '//lib:io_netty_netty_codec-http2',
+    '//lib:io_netty_netty_common',
+    '//lib:io_netty_netty_handler',
+    '//lib:io_netty_netty_transport',
+    '//lib:io_netty_netty_transport-native-epoll',
+    '//lib:io_netty_netty_resolver',
 ]
 
 onos_app (
diff --git a/protocols/grpc/BUILD b/protocols/grpc/BUILD
new file mode 100644
index 0000000..53c351f
--- /dev/null
+++ b/protocols/grpc/BUILD
@@ -0,0 +1,36 @@
+
+BUNDLES = [
+    "//protocols/grpc/proto:dummy_java_grpc",
+    "//protocols/grpc/proto:dummy_java_proto",
+    "//protocols/grpc/api:onos-protocols-grpc-api",
+    "//protocols/grpc/ctl:onos-protocols-grpc-ctl",
+    # gRPC dependencies
+    "@io_grpc_grpc_java//core",
+    "@io_grpc_grpc_java//stub",
+    "@io_grpc_grpc_java//netty",
+    "@io_grpc_grpc_java//auth",
+    "@io_grpc_grpc_java//protobuf",
+    "@io_grpc_grpc_java//protobuf-lite",
+    "@com_google_protobuf//:protobuf_java",
+    # Lazily adding all netty-related packages.
+    # Some of them might not be necessary.
+    "@io_netty_netty//jar",
+    "@io_netty_netty_buffer//jar",
+    "@io_netty_netty_codec//jar",
+    "@io_netty_netty_codec_http//jar",
+    "@io_netty_netty_codec_http2//jar",
+    "@io_netty_netty_common//jar",
+    "@io_netty_netty_handler//jar",
+    "@io_netty_netty_transport//jar",
+    "@io_netty_netty_transport_native_epoll//jar",
+    "@io_netty_netty_resolver//jar",
+]
+
+onos_app (
+    app_name = "org.onosproject.protocols.grpc",
+    title = "RPC Protocol Subsystem",
+    category = "rotocol",
+    url = "ttp://onosproject.org",
+    description = "Exposes APIs to operate with gRPC channels",
+    included_bundles = BUNDLES,
+)
diff --git a/protocols/grpc/api/BUILD b/protocols/grpc/api/BUILD
new file mode 100644
index 0000000..f7fee65
--- /dev/null
+++ b/protocols/grpc/api/BUILD
@@ -0,0 +1,3 @@
+osgi_jar (
+    deps = CORE_DEPS + ["@io_grpc_grpc_java//core"],
+)
diff --git a/protocols/grpc/ctl/BUILD b/protocols/grpc/ctl/BUILD
new file mode 100644
index 0000000..2d199ef
--- /dev/null
+++ b/protocols/grpc/ctl/BUILD
@@ -0,0 +1,8 @@
+osgi_jar (
+    deps = CORE_DEPS + [
+        "//protocols/grpc/api:onos-protocols-grpc-api",
+        "//protocols/grpc/proto:dummy_java_grpc",
+        "//protocols/grpc/proto:dummy_java_proto",
+        "@io_grpc_grpc_java//core"
+    ],
+)
diff --git a/protocols/grpc/proto/BUILD b/protocols/grpc/proto/BUILD
new file mode 100644
index 0000000..bebc0ef
--- /dev/null
+++ b/protocols/grpc/proto/BUILD
@@ -0,0 +1,39 @@
+load("//tools/build/bazel:osgi_java_library.bzl", "wrapped_osgi_jar")
+load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
+
+wrapped_osgi_jar(
+    name = "dummy_java_grpc",
+    jar = ":dummy_java_grpc_native",
+    deps = [
+        "@io_grpc_grpc_java//stub",
+        "@io_grpc_grpc_java//core",
+        "@io_grpc_grpc_java//protobuf"
+    ],
+    visibility = ["//visibility:public"],
+)
+
+wrapped_osgi_jar(
+    name = "dummy_java_proto",
+    jar = ":dummy_java_proto_native",
+    deps = [
+        "@com_google_protobuf//:protobuf_java",
+    ],
+    visibility = ["//visibility:public"],
+)
+
+java_proto_library(
+    name = "dummy_java_proto_native",
+    deps = [":dummy_proto"],
+    visibility = ["//visibility:public"],
+)
+
+java_grpc_library(
+    name = "dummy_java_grpc_native",
+    srcs = [":dummy_proto"],
+    deps = [":dummy_java_proto_native"],
+)
+
+proto_library(
+    name = "dummy_proto",
+    srcs = ["dummy.proto"],
+)