build: Add bazel support to generate C++ gRPC definition (#33)
* build: Add bazel support to generate C++ gRPC definition
diff --git a/.bazelrc b/.bazelrc
new file mode 100644
index 0000000..bb24139
--- /dev/null
+++ b/.bazelrc
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+try-import %workspace%/user.bazelrc
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5864c77
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+# Bazel artifacts
+/bazel-bin
+/bazel-out
+/bazel-skywalking-data-collect-protocol
+/bazel-testlogs
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..e0d778b
--- /dev/null
+++ b/WORKSPACE
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+workspace(name = "skywalking_data_collect_protocol")
+
+load("//bazel:repositories.bzl", "skywalking_data_collect_protocol_dependencies")
+
+skywalking_data_collect_protocol_dependencies()
+
+load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
+
+rules_proto_dependencies()
+
+rules_proto_toolchains()
+
+load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
+
+grpc_deps()
+
+load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
+
+grpc_extra_deps()
diff --git a/bazel/BUILD b/bazel/BUILD
new file mode 100644
index 0000000..5f2cf4c
--- /dev/null
+++ b/bazel/BUILD
@@ -0,0 +1,17 @@
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl
new file mode 100644
index 0000000..481a762
--- /dev/null
+++ b/bazel/repositories.bzl
@@ -0,0 +1,41 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+def skywalking_data_collect_protocol_dependencies():
+ rules_proto()
+ com_github_grpc_grpc()
+
+def com_github_grpc_grpc():
+ http_archive(
+ name = "com_github_grpc_grpc",
+ sha256 = "3ccc4e5ae8c1ce844456e39cc11f1c991a7da74396faabe83d779836ef449bce",
+ urls = ["https://github.com/grpc/grpc/archive/v1.27.0.tar.gz"],
+ strip_prefix = "grpc-1.27.0",
+ )
+
+def rules_proto():
+ http_archive(
+ name = "rules_proto",
+ sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208",
+ strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz",
+ "https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz",
+ ],
+ )
diff --git a/common/BUILD b/common/BUILD
new file mode 100644
index 0000000..55d0e92
--- /dev/null
+++ b/common/BUILD
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+load("@rules_proto//proto:defs.bzl", "proto_library")
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"]) # Apache 2
+
+proto_library(
+ name = "common_protocol_proto_lib",
+ srcs = ["Common.proto"],
+)
diff --git a/language-agent/BUILD b/language-agent/BUILD
new file mode 100644
index 0000000..2fb5e97
--- /dev/null
+++ b/language-agent/BUILD
@@ -0,0 +1,42 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@rules_cc//cc:defs.bzl", "cc_proto_library")
+load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"]) # Apache 2
+
+proto_library(
+ name = "tracing_protocol_proto_lib",
+ srcs = ["Tracing.proto"],
+ deps = ["//common:common_protocol_proto_lib"],
+)
+
+cc_proto_library(
+ name = "tracing_protocol_cc_proto",
+ deps = [":tracing_protocol_proto_lib"],
+)
+
+cc_grpc_library(
+ name = "tracing_protocol_cc_grpc",
+ srcs = [":tracing_protocol_proto_lib"],
+ deps = [":tracing_protocol_cc_proto"],
+ grpc_only = True,
+)