aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-10-04 14:47:16 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-10-04 14:47:16 +0000
commit142aefbe0eb5fb995e54973c5077c2315ed19da3 (patch)
tree3f224c69e5eea8905a266a3c3f0d810c12081fa2
parent1e388ee1bddcb47de1a51f28fd4ccdf9228d2cfc (diff)
parent9a75a3d63509ed634a2730fead8a89a5c6e167aa (diff)
downloadprotobuf-142aefbe0eb5fb995e54973c5077c2315ed19da3.tar.gz
Snap for 10900817 from 9a75a3d63509ed634a2730fead8a89a5c6e167aa to sdk-release
Change-Id: I9fde2c770b9cf2947bc916870c498c6f33ccc26f
-rw-r--r--Android.bp6
-rw-r--r--BUILD.bazel32
-rw-r--r--java/Android.bp17
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc47
4 files changed, 80 insertions, 22 deletions
diff --git a/Android.bp b/Android.bp
index ab335caf6..e4e3b2894 100644
--- a/Android.bp
+++ b/Android.bp
@@ -707,6 +707,12 @@ filegroup {
}
filegroup {
+ name: "libprotobuf-internal-java-full-srcs",
+ srcs: ["java/core/src/main/java/**/*.java"],
+ path: "java",
+}
+
+filegroup {
name: "libprotobuf-internal-protos",
srcs: [
"src/google/protobuf/descriptor.proto",
diff --git a/BUILD.bazel b/BUILD.bazel
index 8e5ef8fd6..10f2a5d7c 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -16,6 +16,7 @@
# from Android.bp. The BUILD file in this folder is unused, it's from
# the protocol-buffers github repo.
load("//build/bazel/rules/python:py_proto.bzl", "py_proto_library")
+load("//build/bazel/rules/java:proto.bzl", "java_proto_sources_gen")
py_library(
name = "libprotobuf-python",
@@ -47,7 +48,7 @@ genrule(
name = "libprotobuf-python-copy-protos",
srcs = [":libprotobuf-python-proto-gen"],
outs = ["python/" + f + "_pb2.py" for f in proto_filenames],
- cmd = "cp -rf $(BINDIR)/external/protobuf/_virtual_imports/libprotobuf-proto/google $(BINDIR)/external/protobuf/python/"
+ cmd = "cp -rf $(BINDIR)/external/protobuf/libprotobuf-python-proto-gen_proto_gen/google $(BINDIR)/external/protobuf/python/"
)
py_proto_library(
@@ -60,3 +61,32 @@ proto_library(
srcs = ["src/" + f + ".proto" for f in proto_filenames],
strip_import_prefix = "src",
)
+
+java_library(
+ name = "libprotobuf-java-full",
+ java_version = "1.7",
+ srcs = [
+ ":libprotobuf-internal-java-full-srcs",
+ ":libprotobuf-java-full_proto_gen",
+ ],
+ target_compatible_with = select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ }),
+)
+
+java_library(
+ name = "libprotobuf-java-full-neverlink",
+ exports = [":libprotobuf-java-full"],
+ java_version = "1.7",
+ neverlink = True,
+ target_compatible_with = select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ }),
+)
+
+java_proto_sources_gen(
+ name = "libprotobuf-java-full_proto_gen",
+ deps = [":libprotobuf-internal-protos_proto"],
+)
diff --git a/java/Android.bp b/java/Android.bp
new file mode 100644
index 000000000..877467e6b
--- /dev/null
+++ b/java/Android.bp
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// 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.
+
+package {
+ default_applicable_licenses: ["external_protobuf_license"],
+}
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 5e9a2c418..607bfe4da 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -2213,6 +2213,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
output_filenames.push_back(descriptor_set_out_name_);
}
+ // Create the depfile, even if it will be empty.
int fd;
do {
fd = open(dependency_out_name_.c_str(),
@@ -2224,30 +2225,34 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
return false;
}
- io::FileOutputStream out(fd);
- io::Printer printer(&out, '$');
+ // Only write to the depfile if there is at least one output_filename.
+ // Otherwise, the depfile will be malformed.
+ if (!output_filenames.empty()) {
+ io::FileOutputStream out(fd);
+ io::Printer printer(&out, '$');
- for (int i = 0; i < output_filenames.size(); i++) {
- printer.Print(output_filenames[i].c_str());
- if (i == output_filenames.size() - 1) {
- printer.Print(":");
- } else {
- printer.Print(" \\\n");
+ for (size_t i = 0; i < output_filenames.size(); i++) {
+ printer.Print(output_filenames[i].c_str());
+ if (i == output_filenames.size() - 1) {
+ printer.Print(":");
+ } else {
+ printer.Print(" \\\n");
+ }
}
- }
- for (int i = 0; i < file_set.file_size(); i++) {
- const FileDescriptorProto& file = file_set.file(i);
- const std::string& virtual_file = file.name();
- std::string disk_file;
- if (source_tree &&
- source_tree->VirtualFileToDiskFile(virtual_file, &disk_file)) {
- printer.Print(" $disk_file$", "disk_file", disk_file);
- if (i < file_set.file_size() - 1) printer.Print("\\\n");
- } else {
- std::cerr << "Unable to identify path for file " << virtual_file
- << std::endl;
- return false;
+ for (int i = 0; i < file_set.file_size(); i++) {
+ const FileDescriptorProto& file = file_set.file(i);
+ const std::string& virtual_file = file.name();
+ std::string disk_file;
+ if (source_tree &&
+ source_tree->VirtualFileToDiskFile(virtual_file, &disk_file)) {
+ printer.Print(" $disk_file$", "disk_file", disk_file);
+ if (i < file_set.file_size() - 1) printer.Print("\\\n");
+ } else {
+ std::cerr << "Unable to identify path for file " << virtual_file
+ << std::endl;
+ return false;
+ }
}
}