diff --git a/src/main/protobuf/BUILD b/src/main/protobuf/BUILD index 177d778bde7322..82e40cbb4c37c8 100644 --- a/src/main/protobuf/BUILD +++ b/src/main/protobuf/BUILD @@ -287,6 +287,11 @@ java_library_srcs( deps = [":bazel_output_service_java_proto"], ) +cc_proto_library( + name = "bazel_output_service_cc_proto", + deps = [":bazel_output_service_proto"], +) + proto_library( name = "bazel_output_service_rev2_proto", srcs = ["bazel_output_service_rev2.proto"], @@ -300,15 +305,26 @@ java_proto_library( deps = [":bazel_output_service_rev2_proto"], ) +java_library_srcs( + name = "bazel_output_service_rev2_java_proto_srcs", + deps = [":bazel_output_service_rev2_java_proto"], +) + +cc_proto_library( + name = "bazel_output_service_rev2_cc_proto", + deps = [":bazel_output_service_rev2_proto"], +) + java_grpc_library( name = "bazel_output_service_java_grpc", srcs = [":bazel_output_service_proto"], deps = [":bazel_output_service_java_proto"], ) -java_library_srcs( - name = "bazel_output_service_rev2_java_proto_srcs", - deps = [":bazel_output_service_rev2_java_proto"], +cc_grpc_library( + name = "bazel_output_service_cc_grpc", + srcs = [":bazel_output_service_proto"], + deps = [":bazel_output_service_cc_proto"], ) proto_library( diff --git a/src/tools/remote/BUILD b/src/tools/remote/BUILD index 2e25e9edb6c2f0..222fc3c473dcab 100644 --- a/src/tools/remote/BUILD +++ b/src/tools/remote/BUILD @@ -8,6 +8,7 @@ package( filegroup( name = "srcs", srcs = glob(["**"]) + [ + "//src/tools/remote/src/main/cpp/testonly_output_service:srcs", "//src/tools/remote/src/main/java/com/google/devtools/build/remote/worker:srcs", "//src/tools/remote/src/test/java/com/google/devtools/build/remote/worker:srcs", ], diff --git a/src/tools/remote/src/main/cpp/testonly_output_service/BUILD b/src/tools/remote/src/main/cpp/testonly_output_service/BUILD new file mode 100644 index 00000000000000..9d8ef25c4d9d85 --- /dev/null +++ b/src/tools/remote/src/main/cpp/testonly_output_service/BUILD @@ -0,0 +1,25 @@ +package( + default_applicable_licenses = ["//:license"], + default_visibility = ["//:__subpackages__"], +) + +filegroup( + name = "srcs", + srcs = glob(["**"]), + visibility = ["//src:__subpackages__"], +) + +cc_binary( + name = "testonly_output_service", + srcs = [ + "bazel_output_service_impl.cc", + "bazel_output_service_impl.h", + "main.cc", + ], + deps = [ + "//src/main/protobuf:bazel_output_service_cc_grpc", + "//src/main/protobuf:bazel_output_service_cc_proto", + "//src/main/protobuf:bazel_output_service_rev2_cc_proto", + "//third_party/grpc:grpc++_unsecure", + ], +) diff --git a/src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.cc b/src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.cc new file mode 100644 index 00000000000000..9fc944261bc636 --- /dev/null +++ b/src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.cc @@ -0,0 +1,15 @@ +// Copyright 2024 The Bazel Authors. All rights reserved. +// +// Licensed 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. + +#include "src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.h" diff --git a/src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.h b/src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.h new file mode 100644 index 00000000000000..5a9f312f4a2b97 --- /dev/null +++ b/src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.h @@ -0,0 +1,23 @@ +// Copyright 2024 The Bazel Authors. All rights reserved. +// +// Licensed 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. + +#ifndef BAZEL_SRC_TOOLS_REMOTE_SRC_MAIN_CPP_OUTPUT_SERVICE_BAZEL_OUTPUT_SERVICE_IMPL_H_ +#define BAZEL_SRC_TOOLS_REMOTE_SRC_MAIN_CPP_OUTPUT_SERVICE_BAZEL_OUTPUT_SERVICE_IMPL_H_ + +#include "src/main/protobuf/bazel_output_service.grpc.pb.h" + +class BazelOutputServiceImpl + : public bazel_output_service::BazelOutputService::Service {}; + +#endif // BAZEL_SRC_TOOLS_REMOTE_SRC_MAIN_CPP_OUTPUT_SERVICE_BAZEL_OUTPUT_SERVICE_IMPL_H_ diff --git a/src/tools/remote/src/main/cpp/testonly_output_service/main.cc b/src/tools/remote/src/main/cpp/testonly_output_service/main.cc new file mode 100644 index 00000000000000..6d96ed51d5d448 --- /dev/null +++ b/src/tools/remote/src/main/cpp/testonly_output_service/main.cc @@ -0,0 +1,40 @@ +// Copyright 2024 The Bazel Authors. All rights reserved. +// +// Licensed 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. + +#include +#include +#include + +#include "src/tools/remote/src/main/cpp/testonly_output_service/bazel_output_service_impl.h" +#include "grpcpp/security/server_credentials.h" +#include "grpcpp/server_builder.h" + +static void RunServer() { + BazelOutputServiceImpl service; + + std::string server_address = "0.0.0.0:8080"; + + grpc::ServerBuilder builder; + builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); + builder.RegisterService(&service); + std::unique_ptr server(builder.BuildAndStart()); + std::cerr << "Server listening on " << server_address << std::endl; + + server->Wait(); +} + +int main(int argc, char** argv) { + RunServer(); + return 0; +}