Skip to content

Commit

Permalink
Setup BUILD for a no-op output service server.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 678271733
Change-Id: Id541ff8d7c6ed93c4087528e13df29eb024e2738
  • Loading branch information
coeuvre authored and copybara-github committed Sep 24, 2024
1 parent 0825634 commit c1734aa
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/main/protobuf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/tools/remote/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
25 changes: 25 additions & 0 deletions src/tools/remote/src/main/cpp/testonly_output_service/BUILD
Original file line number Diff line number Diff line change
@@ -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",
],
)
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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_
40 changes: 40 additions & 0 deletions src/tools/remote/src/main/cpp/testonly_output_service/main.cc
Original file line number Diff line number Diff line change
@@ -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 <iostream>
#include <memory>
#include <string>

#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<grpc::Server> server(builder.BuildAndStart());
std::cerr << "Server listening on " << server_address << std::endl;

server->Wait();
}

int main(int argc, char** argv) {
RunServer();
return 0;
}

0 comments on commit c1734aa

Please sign in to comment.