Add build targets for Java lite runtime. (#3288)

* Add a protobuf_java_lite target for lite runtime.

* Add a cc_binary for javalite plugin.

* Add proto_lang_toolchain for Java lite.
This commit is contained in:
Feng Xiao 2017-06-30 13:51:58 -07:00 committed by GitHub
parent 432a7559c1
commit 45ff30697a
2 changed files with 99 additions and 3 deletions

101
BUILD
View file

@ -539,13 +539,100 @@ internal_gen_well_known_protos_java(
srcs = WELL_KNOWN_PROTOS,
)
java_library(
name = "protobuf_java_lite",
srcs = [
"java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java",
"java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java",
"java/core/src/main/java/com/google/protobuf/AbstractParser.java",
"java/core/src/main/java/com/google/protobuf/BooleanArrayList.java",
"java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java",
"java/core/src/main/java/com/google/protobuf/ByteOutput.java",
"java/core/src/main/java/com/google/protobuf/ByteString.java",
"java/core/src/main/java/com/google/protobuf/CodedInputStream.java",
"java/core/src/main/java/com/google/protobuf/CodedOutputStream.java",
"java/core/src/main/java/com/google/protobuf/DoubleArrayList.java",
"java/core/src/main/java/com/google/protobuf/ExperimentalApi.java",
"java/core/src/main/java/com/google/protobuf/ExtensionLite.java",
"java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java",
"java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java",
"java/core/src/main/java/com/google/protobuf/FieldSet.java",
"java/core/src/main/java/com/google/protobuf/FloatArrayList.java",
"java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java",
"java/core/src/main/java/com/google/protobuf/IntArrayList.java",
"java/core/src/main/java/com/google/protobuf/Internal.java",
"java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java",
"java/core/src/main/java/com/google/protobuf/LazyField.java",
"java/core/src/main/java/com/google/protobuf/LazyFieldLite.java",
"java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java",
"java/core/src/main/java/com/google/protobuf/LazyStringList.java",
"java/core/src/main/java/com/google/protobuf/LongArrayList.java",
"java/core/src/main/java/com/google/protobuf/MapEntryLite.java",
"java/core/src/main/java/com/google/protobuf/MapFieldLite.java",
"java/core/src/main/java/com/google/protobuf/MessageLite.java",
"java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java",
"java/core/src/main/java/com/google/protobuf/MessageLiteToString.java",
"java/core/src/main/java/com/google/protobuf/MutabilityOracle.java",
"java/core/src/main/java/com/google/protobuf/NioByteString.java",
"java/core/src/main/java/com/google/protobuf/Parser.java",
"java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java",
"java/core/src/main/java/com/google/protobuf/ProtocolStringList.java",
"java/core/src/main/java/com/google/protobuf/RopeByteString.java",
"java/core/src/main/java/com/google/protobuf/SmallSortedMap.java",
"java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java",
"java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java",
"java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java",
"java/core/src/main/java/com/google/protobuf/UnsafeUtil.java",
"java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java",
"java/core/src/main/java/com/google/protobuf/Utf8.java",
"java/core/src/main/java/com/google/protobuf/WireFormat.java",
],
visibility = ["//visibility:public"],
)
cc_binary(
name = "protoc_gen_javalite",
srcs = ["src/google/protobuf/compiler/java/java_lite_main.cc"],
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protoc_lib"],
)
java_library(
name = "protobuf_java",
srcs = glob([
"java/core/src/main/java/com/google/protobuf/*.java",
]) + [
srcs = [
"java/core/src/main/java/com/google/protobuf/AbstractMessage.java",
"java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java",
"java/core/src/main/java/com/google/protobuf/BlockingService.java",
"java/core/src/main/java/com/google/protobuf/Descriptors.java",
"java/core/src/main/java/com/google/protobuf/DynamicMessage.java",
"java/core/src/main/java/com/google/protobuf/Extension.java",
"java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java",
"java/core/src/main/java/com/google/protobuf/GeneratedMessage.java",
"java/core/src/main/java/com/google/protobuf/MapEntry.java",
"java/core/src/main/java/com/google/protobuf/MapField.java",
"java/core/src/main/java/com/google/protobuf/Message.java",
"java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java",
"java/core/src/main/java/com/google/protobuf/MessageReflection.java",
"java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java",
"java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java",
"java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java",
"java/core/src/main/java/com/google/protobuf/RpcCallback.java",
"java/core/src/main/java/com/google/protobuf/RpcChannel.java",
"java/core/src/main/java/com/google/protobuf/RpcController.java",
"java/core/src/main/java/com/google/protobuf/RpcUtil.java",
"java/core/src/main/java/com/google/protobuf/Service.java",
"java/core/src/main/java/com/google/protobuf/ServiceException.java",
"java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java",
"java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java",
"java/core/src/main/java/com/google/protobuf/TextFormat.java",
"java/core/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java",
"java/core/src/main/java/com/google/protobuf/TextFormatParseLocation.java",
"java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java",
"java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java",
":gen_well_known_protos_java",
],
deps = [":protobuf_java_lite"],
visibility = ["//visibility:public"],
)
@ -772,3 +859,11 @@ proto_lang_toolchain(
runtime = ":protobuf_java",
visibility = ["//visibility:public"],
)
proto_lang_toolchain(
name = "javalite_toolchain",
command_line = "--$(PLUGIN_OUT)=$(OUT)",
plugin = ":protoc_gen_javalite",
runtime = ":protobuf_java_lite",
visibility = ["//visibility:public"],
)

View file

@ -392,6 +392,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
printer->Print(
"}\n"
"// fall through\n"
"case GET_DEFAULT_INSTANCE: {\n"
" return DEFAULT_INSTANCE;\n"
"}\n"