Skip to content

Commit

Permalink
Merge pull request #8272 from deannagarcia/kotlinProtos
Browse files Browse the repository at this point in the history
Opensourcing kotlin protos
  • Loading branch information
deannagarcia committed Apr 21, 2021
2 parents 0fd8358 + f650807 commit 76188af
Show file tree
Hide file tree
Showing 71 changed files with 5,882 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codespell.yml
Expand Up @@ -12,5 +12,5 @@ jobs:
- uses: codespell-project/actions-codespell@master
with:
check_filenames: true
skip: ./.git,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal,./.github/workflows/codespell.yml
ignore_words_list: "alow,alse,ba,cleare,copyable,cloneable,dedup,dur,errorprone,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,OptIn"
skip: ./.git,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal,./github/workflows/codespell.yml
ignore_words_list: "alow,alse,ba,cleare,copyable,cloneable,dedup,dur,errorprone,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin"
1 change: 1 addition & 0 deletions BUILD
Expand Up @@ -403,6 +403,7 @@ cc_library(
"src/google/protobuf/compiler/java/java_generator.cc",
"src/google/protobuf/compiler/java/java_generator_factory.cc",
"src/google/protobuf/compiler/java/java_helpers.cc",
"src/google/protobuf/compiler/java/java_kotlin_generator.cc",
"src/google/protobuf/compiler/java/java_map_field.cc",
"src/google/protobuf/compiler/java/java_map_field_lite.cc",
"src/google/protobuf/compiler/java/java_message.cc",
Expand Down
29 changes: 29 additions & 0 deletions Makefile.am
Expand Up @@ -530,6 +530,35 @@ java_EXTRA_DIST=
java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \
java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \
java/core/src/test/proto/com/google/protobuf/wrappers_test.proto \
java/kotlin/generate-sources-build.xml \
java/kotlin/generate-test-sources-build.xml \
java/kotlin/pom.xml \
java/kotlin/src/main/kotlin/com/google/protobuf/DslList.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/DslMap.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/DslProxy.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/ExtendableMessageExtensions.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/ExtendableMessageLiteExtensions.kt\
java/kotlin/src/main/kotlin/com/google/protobuf/ExtensionList.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/OnlyForUseByGeneratedProtoCode.kt\
java/kotlin/src/main/kotlin/com/google/protobuf/ProtoDslMarker.kt \
java/kotlin/src/main/kotlin/com/google/protobuf/UnmodifiableCollections.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/DslListTest.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/DslMapTest.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/ExtendableMessageExtensionsTest.kt\
java/kotlin/src/test/kotlin/com/google/protobuf/ExtensionListTest.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/Proto2Test.kt \
java/kotlin/src/test/kotlin/com/google/protobuf/Proto3Test.kt \
java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto2.proto \
java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto3.proto \
java/kotlin/src/test/proto/com/google/protobuf/example_extensible_message.proto \
java/kotlin/src/test/proto/com/google/protobuf/multiple_files_proto3.proto \
java/kotlin-lite/generate-sources-build.xml \
java/kotlin-lite/generate-test-sources-build.xml \
java/kotlin-lite/lite.awk \
java/kotlin-lite/pom.xml \
java/kotlin-lite/process-lite-sources-build.xml \
java/kotlin-lite/src/test/kotlin/com/google/protobuf/ExtendableMessageLiteExtensionsTest.kt\
java/kotlin-lite/src/test/kotlin/com/google/protobuf/Proto2LiteTest.kt \
java/lite.md \
java/lite/BUILD \
java/lite/generate-sources-build.xml \
Expand Down
1 change: 1 addition & 0 deletions cmake/extract_includes.bat.in
Expand Up @@ -26,6 +26,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\cshar
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h" include\google\protobuf\compiler\csharp\csharp_names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h" include\google\protobuf\compiler\importer.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h" include\google\protobuf\compiler\java\java_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_kotlin_generator.h" include\google\protobuf\compiler\java\java_kotlin_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h" include\google\protobuf\compiler\java\java_names.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h" include\google\protobuf\compiler\js\js_generator.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\well_known_types_embed.h" include\google\protobuf\compiler\js\well_known_types_embed.h
Expand Down
1 change: 1 addition & 0 deletions cmake/libprotoc.cmake
Expand Up @@ -45,6 +45,7 @@ set(libprotoc_files
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_kotlin_generator.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.cc
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.cc
Expand Down
5 changes: 5 additions & 0 deletions java/README.md
Expand Up @@ -178,3 +178,8 @@ The complete documentation for Protocol Buffers is available via the
web at:

https://developers.google.com/protocol-buffers/

## Kotlin Protocol Buffers

Code to support more idiomatic Kotlin protocol buffers has been added to the
repository, and Kotlin support will be launched in the next numbered release.
19 changes: 19 additions & 0 deletions java/kotlin-lite/generate-sources-build.xml
@@ -0,0 +1,19 @@
<project name="generate-sources">
<echo message="Running protoc ..."/>
<mkdir dir="${generated.sources.dir}"/>
<exec executable="${protoc}">
<arg value="--kotlin_out=lite:${generated.sources.dir}"/>
<arg value="--proto_path=${protobuf.source.dir}"/>
<arg value="${protobuf.source.dir}/google/protobuf/any.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/api.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/duration.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/empty.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/field_mask.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/source_context.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/struct.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/timestamp.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/type.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/wrappers.proto"/>
</exec>
</project>

34 changes: 34 additions & 0 deletions java/kotlin-lite/generate-test-sources-build.xml
@@ -0,0 +1,34 @@
<project name="generate-test-sources">
<mkdir dir="${generated.testsources.dir}"/>
<exec executable="${protoc}">
<arg value="--java_out=lite:${generated.testsources.dir}"/>
<arg value="--proto_path=${protobuf.source.dir}"/>
<arg value="--proto_path=${protobuf.basedir}/java/kotlin/${test.proto.dir}"/>
<arg value="--experimental_allow_proto3_optional"/>
<arg value="${protobuf.source.dir}/google/protobuf/map_lite_unittest.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_import.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_import_lite.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_import_public.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_import_public_lite.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_lite.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_proto3.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/evil_names_proto2.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/evil_names_proto3.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/example_extensible_message.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/multiple_files_proto3.proto"/>
</exec>
<exec executable="${protoc}">
<arg value="--kotlin_out=lite:${generated.testsources.dir}"/>
<arg value="--proto_path=${protobuf.source.dir}"/>
<arg value="--proto_path=${protobuf.basedir}/java/kotlin/${test.proto.dir}"/>
<arg value="--experimental_allow_proto3_optional"/>
<arg value="${protobuf.source.dir}/google/protobuf/map_lite_unittest.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_lite.proto"/>
<arg value="${protobuf.source.dir}/google/protobuf/unittest_proto3.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/evil_names_proto2.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/evil_names_proto3.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/example_extensible_message.proto"/>
<arg value="${protobuf.basedir}/java/kotlin/${test.proto.dir}/com/google/protobuf/multiple_files_proto3.proto"/>
</exec>
</project>
25 changes: 25 additions & 0 deletions java/kotlin-lite/lite.awk
@@ -0,0 +1,25 @@
# Remove code enclosed by "BEGIN FULL-RUNTIME" and "END FULL-RUNTIME" to
# create the lite-only version of a test file.

BEGIN {
in_full_runtime = 0;
}

/BEGIN FULL-RUNTIME/ {
in_full_runtime = 1;
next;
}

/END FULL-RUNTIME/ {
in_full_runtime = 0;
next;
}

in_full_runtime {
# Skip full runtime code path.
next;
}

{
print;
}

0 comments on commit 76188af

Please sign in to comment.