diff --git a/BUILD b/BUILD index e437626514..568fd4ce25 100644 --- a/BUILD +++ b/BUILD @@ -2,6 +2,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library", native_cc_proto_library = "cc_proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") load("@rules_python//python:defs.bzl", "py_library") load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library") @@ -1445,3 +1446,140 @@ internal_gen_kt_protos( visibility = ["//java:__subpackages__"], deps = [":kt_proto3_unittest"], ) + +################################################################################ +# Packaging rules +################################################################################ + +# Files included in all source distributions +pkg_files( + name = "common_dist_files", + srcs = glob([ + "*.bzl", + "cmake/*.cmake", + "cmake/*.in", + "editors/*", + + # Several of these files are generated by autogen.sh, so using + # glob() lets us ignore them if they are missing. (This is not good + # practice, though.) + "Makefile.in", + "aclocal.m4", + "ar-lib", + "compile", + "config*", + "depcomp", + "install-sh", + "ltmain.sh", + "m4/*.m4", + "missing", + "protobuf*.pc.in", + "test-driver", + ]) + [ + "BUILD", + "CHANGES.txt", + "CMakeLists.txt", + "CONTRIBUTORS.txt", + "LICENSE", + "Makefile.am", + "README.md", + "WORKSPACE", + "autogen.sh", + "build_files_updated_unittest.sh", + "cmake/CMakeLists.txt", + "cmake/README.md", + "generate_descriptor_proto.sh", + "maven_install.json", + "update_file_lists.sh", + "//third_party:zlib.BUILD", + "//util/python:BUILD", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) + +# Conformance tests +pkg_files( + name = "conformance_dist_files", + srcs = glob( + ["conformance/**/*"], + exclude = [ + # The following are not in autotools dist: + "conformance/autoload.php", + "conformance/conformance_nodejs.js", + "conformance/conformance_test_runner.sh", + "conformance/failure_list_java_lite.txt", + "conformance/failure_list_jruby.txt", + "conformance/text_format_failure_list_*.txt", + "conformance/update_failure_list.py", + ], + ), + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) + +# C++ runtime +pkg_files( + name = "cpp_dist_files", + srcs = glob( + ["src/**/*"], + exclude = [ + "src/google/protobuf/compiler/objectivec/method_dump.sh", # not in autotools dist + ], + ), + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) + +# Additional files for C# +pkg_files( + name = "csharp_dist_files", + srcs = [ + "global.json", + ], + visibility = ["//pkg:__pkg__"], +) + +# Additional files for ObjC +pkg_files( + name = "objectivec_dist_files", + srcs = [ + "Protobuf.podspec", + ], + visibility = ["//pkg:__pkg__"], +) + +# Additional files for PHP +pkg_files( + name = "php_dist_files", + srcs = [ + "composer.json", + ], + visibility = ["//pkg:__pkg__"], +) + +# Python runtime +pkg_files( + name = "python_dist_files", + srcs = glob([ + "python/google/**/*.proto", + "python/google/**/*.py", + "python/google/protobuf/internal/*.cc", + "python/google/protobuf/pyext/*.cc", + "python/google/protobuf/pyext/*.h", + ]) + [ + "python/MANIFEST.in", + "python/README.md", + "python/google/protobuf/proto_api.h", + "python/google/protobuf/pyext/README", + "python/google/protobuf/python_protobuf.h", + "python/mox.py", + "python/release.sh", + "python/setup.cfg", + "python/setup.py", + "python/stubout.py", + "python/tox.ini", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) diff --git a/Makefile.am b/Makefile.am index dcc210797e..ea8ff17a55 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,6 +9,9 @@ AUTOMAKE_OPTIONS = foreign SUBDIRS = . src # Always include third_party directories in distributions. +# +# Note that distribution artifacts will be produced by Bazel in the future. +# See pkg/BUILD for overall definitions. DIST_SUBDIRS = src conformance benchmarks third_party/googletest # Build gmock before we build protobuf tests. We don't add gmock to SUBDIRS @@ -48,6 +51,7 @@ clean-local: pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = protobuf.pc protobuf-lite.pc +# Note: please keep this in sync with the dist_files rule in csharp/BUILD. csharp_EXTRA_DIST= \ global.json \ csharp/.editorconfig \ @@ -279,6 +283,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf/UnknownFieldSet.cs \ csharp/src/Google.Protobuf/UnsafeByteOperations.cs +# Note: please keep this in sync with the dist_files rules under java/.../BUILD. java_EXTRA_DIST= \ java/README.md \ java/bom/pom.xml \ @@ -607,6 +612,7 @@ java_EXTRA_DIST= java/util/src/test/java/com/google/protobuf/util/ValuesTest.java \ java/util/src/test/proto/com/google/protobuf/util/json_test.proto +# Note: please keep this in sync with the dist_files rule in objectivec/BUILD. objectivec_EXTRA_DIST= \ objectivec/.clang-format \ objectivec/BUILD \ @@ -815,6 +821,7 @@ objectivec_EXTRA_DIST= \ objectivec/Tests/UnitTests-Info.plist \ Protobuf.podspec +# Note: please keep this in sync with the dist_files rule in php/BUILD. php_EXTRA_DIST= \ php/README.md \ php/REFCOUNTING.md \ @@ -838,7 +845,7 @@ php_EXTRA_DIST= \ php/ext/google/protobuf/package.xml \ php/ext/google/protobuf/php-upb.c \ php/ext/google/protobuf/php-upb.h \ - php/ext/google/protobuf/php_protobuf.h \ + php/ext/google/protobuf/php_protobuf.h \ php/ext/google/protobuf/protobuf.c \ php/ext/google/protobuf/protobuf.h \ php/ext/google/protobuf/wkt.inc \ @@ -1011,6 +1018,7 @@ php_EXTRA_DIST= \ php/tests/WellKnownTest.php \ php/tests/WrapperTypeSettersTest.php +# Note: please keep this in sync with the python_dist_files rule in BUILD. python_EXTRA_DIST= \ python/MANIFEST.in \ python/google/__init__.py \ @@ -1134,6 +1142,7 @@ python_EXTRA_DIST= \ python/tox.ini \ python/README.md +# Note: please keep this in sync with the dist_files rule in ruby/BUILD. ruby_EXTRA_DIST= \ ruby/Gemfile \ ruby/.gitignore \ @@ -1209,6 +1218,7 @@ ruby_EXTRA_DIST= \ ruby/tests/type_errors.rb \ ruby/travis-test.sh +# Note: please keep this in sync with the dist_files rule in js/BUILD. js_EXTRA_DIST= \ js/README.md \ js/binary/arith.js \ @@ -1392,6 +1402,7 @@ js_EXTRA_DIST= \ all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(php_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST) +# Note: please keep this in sync with the common_dist_files rule in BUILD. EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ autogen.sh \ generate_descriptor_proto.sh \ @@ -1425,6 +1436,7 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ compiler_config_setting.bzl \ build_files_updated_unittest.sh \ cc_proto_blacklist_test.bzl \ + csharp/BUILD \ editors/README.txt \ editors/proto.vim \ editors/protobuf-mode.el \ @@ -1449,15 +1461,17 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ examples/list_people.dart \ examples/list_people.py \ examples/pubspec.yaml \ + internal.bzl \ + js/BUILD \ maven_install.json \ + php/BUILD \ protobuf.bzl \ protobuf_deps.bzl \ protobuf_release.bzl \ protobuf_version.bzl \ + ruby/BUILD \ third_party/zlib.BUILD \ - util/python/BUILD \ - internal.bzl - + util/python/BUILD # Deletes all the files generated by autogen.sh. MAINTAINERCLEANFILES = \ diff --git a/benchmarks/BUILD b/benchmarks/BUILD index 8e6063ba83..2f7b4c749f 100644 --- a/benchmarks/BUILD +++ b/benchmarks/BUILD @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") proto_library( @@ -63,3 +64,36 @@ java_proto_library( "google_size_proto", ], ) + +pkg_files( + name = "dist_files", + srcs = glob( + [ + "*", + "python/*.cc", + "util/*.cc", + ], + exclude = [ + "__init__.py", # not in autotools dist + "BUILD", + "go/*", + ], + ), + strip_prefix = strip_prefix.from_root(""), +) + +# Convenience filegroup for all files that should be packaged. +pkg_filegroup( + name = "all_dist_files", + srcs = [ + ":dist_files", + "//benchmarks/cpp:dist_files", + # "//benchmarks/datasets:dist_files", # not in autotools dist + "//benchmarks/datasets/google_message1/proto2:dist_files", + "//benchmarks/datasets/google_message1/proto3:dist_files", + "//benchmarks/datasets/google_message2:dist_files", + "//benchmarks/datasets/google_message3:dist_files", + "//benchmarks/datasets/google_message4:dist_files", + ], + visibility = ["//pkg:__pkg__"], +) diff --git a/benchmarks/cpp/BUILD b/benchmarks/cpp/BUILD index b744f896ad..ba93f641e5 100644 --- a/benchmarks/cpp/BUILD +++ b/benchmarks/cpp/BUILD @@ -1,4 +1,5 @@ load("@rules_cc//cc:defs.bzl", "cc_binary") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") cc_binary( name = "cpp", @@ -13,3 +14,10 @@ cc_binary( "@com_github_google_benchmark//:benchmark_main", ], ) + +pkg_files( + name = "dist_files", + srcs = ["cpp_benchmark.cc"], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//benchmarks:__pkg__"], +) diff --git a/benchmarks/datasets/BUILD b/benchmarks/datasets/BUILD index f29a27650b..1cb11bddad 100644 --- a/benchmarks/datasets/BUILD +++ b/benchmarks/datasets/BUILD @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_java//java:defs.bzl", "java_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") filegroup( @@ -57,3 +58,10 @@ java_library( "//benchmarks/datasets/google_message4:benchmark_message4_java_proto", ], ) + +pkg_files( + name = "dist_files", + srcs = ["BUILD"], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//benchmarks:__pkg__"], +) diff --git a/benchmarks/datasets/google_message1/proto2/BUILD b/benchmarks/datasets/google_message1/proto2/BUILD index d4d38cec22..e3159327b9 100644 --- a/benchmarks/datasets/google_message1/proto2/BUILD +++ b/benchmarks/datasets/google_message1/proto2/BUILD @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") filegroup( @@ -42,3 +43,10 @@ java_proto_library( "benchmark_message1_proto2_proto", ], ) + +pkg_files( + name = "dist_files", + srcs = glob(["*.proto"]), + strip_prefix = strip_prefix.from_root(""), + visibility = ["//benchmarks:__pkg__"], +) diff --git a/benchmarks/datasets/google_message1/proto3/BUILD b/benchmarks/datasets/google_message1/proto3/BUILD index c2d627acd8..2628d020aa 100644 --- a/benchmarks/datasets/google_message1/proto3/BUILD +++ b/benchmarks/datasets/google_message1/proto3/BUILD @@ -1,6 +1,7 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") filegroup( name = "datasets", @@ -42,3 +43,10 @@ java_proto_library( "benchmark_message1_proto3_proto", ], ) + +pkg_files( + name = "dist_files", + srcs = glob(["*.proto"]), + strip_prefix = strip_prefix.from_root(""), + visibility = ["//benchmarks:__pkg__"], +) diff --git a/benchmarks/datasets/google_message2/BUILD b/benchmarks/datasets/google_message2/BUILD index 1ca87fb64f..a3208d08c3 100644 --- a/benchmarks/datasets/google_message2/BUILD +++ b/benchmarks/datasets/google_message2/BUILD @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") filegroup( @@ -42,3 +43,10 @@ java_proto_library( "benchmark_message2_proto", ], ) + +pkg_files( + name = "dist_files", + srcs = glob(["*.proto"]), + strip_prefix = strip_prefix.from_root(""), + visibility = ["//benchmarks:__pkg__"], +) diff --git a/benchmarks/datasets/google_message3/BUILD b/benchmarks/datasets/google_message3/BUILD index 9a00294464..130c8749b3 100644 --- a/benchmarks/datasets/google_message3/BUILD +++ b/benchmarks/datasets/google_message3/BUILD @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") filegroup( @@ -48,3 +49,10 @@ java_proto_library( "benchmark_message3_proto", ], ) + +pkg_files( + name = "dist_files", + srcs = glob(["*.proto"]), + strip_prefix = strip_prefix.from_root(""), + visibility = ["//benchmarks:__pkg__"], +) diff --git a/benchmarks/datasets/google_message4/BUILD b/benchmarks/datasets/google_message4/BUILD index b23a4c955c..9c7190d93b 100644 --- a/benchmarks/datasets/google_message4/BUILD +++ b/benchmarks/datasets/google_message4/BUILD @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("@rules_java//java:defs.bzl", "java_proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") filegroup( @@ -43,3 +44,10 @@ java_proto_library( "benchmark_message4_proto", ], ) + +pkg_files( + name = "dist_files", + srcs = glob(["*.proto"]), + strip_prefix = strip_prefix.from_root(""), + visibility = ["//benchmarks:__pkg__"], +) diff --git a/csharp/BUILD b/csharp/BUILD new file mode 100644 index 0000000000..6d31ba0cc6 --- /dev/null +++ b/csharp/BUILD @@ -0,0 +1,34 @@ +# Protobuf C# runtime +# +# See also code generation logic under /src/google/protobuf/compiler/csharp. + +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + +pkg_files( + name = "dist_files", + srcs = glob([ + "keys/*", + "protos/*", + "src/**/*.cs*", # .cs and .csproj + ]) + [ + ".editorconfig", + ".gitignore", + "BUILD", + "CHANGES.txt", + "Google.Protobuf.Tools.nuspec", + "Google.Protobuf.Tools.targets", + "NuGet.Config", + "README.md", + "build_packages.bat", + "build_tools.sh", + "buildall.bat", + "buildall.sh", + "generate_protos.sh", + "install_dotnet_sdk.ps1", + "src/Google.Protobuf.Benchmarks/wrapper_benchmark_messages.proto", + "src/Google.Protobuf.Test/testprotos.pb", + "src/Google.Protobuf.sln", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) diff --git a/examples/BUILD b/examples/BUILD index 7d15e83ab4..358a1529bc 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -6,6 +6,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library") load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") # For each .proto file, a proto_library target should be defined. This target @@ -103,3 +104,34 @@ java_binary( main_class = "ListPeople", deps = [":addressbook_java_lite_proto"], ) + +# Files included in all source distributions +pkg_files( + name = "dist_files", + srcs = [ + "AddPerson.java", + "BUILD", + "CMakeLists.txt", + "ListPeople.java", + "Makefile", + "README.md", + "WORKSPACE", + "add_person.cc", + "add_person.dart", + "add_person.py", + "addressbook.proto", + "go/cmd/add_person/add_person.go", + "go/cmd/add_person/add_person_test.go", + "go/cmd/list_people/list_people.go", + "go/cmd/list_people/list_people_test.go", + "go/go.mod", + "go/go.sum", + "list_people.cc", + "list_people.dart", + "list_people.py", + "pubspec.yaml", + ], + prefix = "examples/", + strip_prefix = strip_prefix.from_root(""), + visibility = ["//visibility:public"], +) diff --git a/java/BUILD b/java/BUILD index 4a1cdc2c0f..c084db6390 100644 --- a/java/BUILD +++ b/java/BUILD @@ -1,3 +1,5 @@ +load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") + test_suite( name = "tests", tests = [ @@ -12,9 +14,40 @@ test_suite( filegroup( name = "release", srcs = [ - "//java/core:release", # contains lite. + "//java/core:release", # contains lite. "//java/kotlin:release", "//java/kotlin-lite:release", "//java/util:release", - ] + ], +) + +################################################################################ +# Packaging rules +################################################################################ + +pkg_files( + name = "dist_files", + srcs = [ + "BUILD", + "README.md", + "bom/pom.xml", + "lite.md", + "pom.xml", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) + +pkg_filegroup( + name = "all_dist_files", + srcs = [ + ":dist_files", + "//java/core:dist_files", + "//java/internal:dist_files", + "//java/kotlin:dist_files", + "//java/kotlin-lite:dist_files", + "//java/lite:dist_files", + "//java/util:dist_files", + ], + visibility = ["//pkg:__pkg__"], ) diff --git a/java/core/BUILD b/java/core/BUILD index 011fb1c7e1..685ebd0981 100644 --- a/java/core/BUILD +++ b/java/core/BUILD @@ -1,6 +1,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") load("@rules_java//java:defs.bzl", "java_library", "java_lite_proto_library", "java_proto_library") load("@rules_jvm_external//:defs.bzl", "java_export") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") load("//:internal.bzl", "conformance_test") load("//:protobuf_version.bzl", "PROTOBUF_VERSION") @@ -175,9 +176,6 @@ filegroup( proto_lang_toolchain( name = "toolchain", - command_line = "--java_out=$(OUT)", - runtime = ":core", - visibility = ["//visibility:public"], # keep this in sync w/ WELL_KNOWN_PROTO_MAP in //:BUILD blacklisted_protos = [ "//:any_proto", @@ -193,6 +191,9 @@ proto_lang_toolchain( "//:type_proto", "//:wrappers_proto", ], + command_line = "--java_out=$(OUT)", + runtime = ":core", + visibility = ["//visibility:public"], ) proto_library( @@ -226,6 +227,7 @@ java_library( "src/test/java/com/google/protobuf/TestUtil.java", "src/test/java/com/google/protobuf/TestUtilLite.java", ], + visibility = ["//java:__subpackages__"], deps = [ ":core", ":generic_test_protos_java_proto", @@ -233,7 +235,6 @@ java_library( "@maven//:com_google_guava_guava", "@maven//:junit_junit", ], - visibility = ["//java:__subpackages__"], ) test_suite( @@ -336,8 +337,8 @@ java_library( ":rewrite_javalite_test_util", ], visibility = [ - "//java/lite:__pkg__", "//java/kotlin-lite:__pkg__", + "//java/lite:__pkg__", ], deps = [ ":generic_test_protos_java_proto_lite", @@ -411,3 +412,20 @@ junit_tests( "@maven//:org_mockito_mockito_core", ], ) + +pkg_files( + name = "dist_files", + srcs = glob([ + "src/main/java/com/google/protobuf/*.java", + "src/test/java/**/*.java", + "src/test/proto/**/*.proto", + ]) + [ + "BUILD", + "generate-sources-build.xml", + "generate-test-sources-build.xml", + "pom.xml", + "pom_template.xml", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//java:__pkg__"], +) diff --git a/java/internal/BUILD b/java/internal/BUILD index 4f542ecee1..d2e0b538ff 100644 --- a/java/internal/BUILD +++ b/java/internal/BUILD @@ -1 +1,13 @@ -package(default_visibility = ["//java:__subpackages__"]) \ No newline at end of file +package(default_visibility = ["//java:__subpackages__"]) + +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + +pkg_files( + name = "dist_files", + srcs = [ + "BUILD", + "testing.bzl", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//java:__pkg__"], +) diff --git a/java/kotlin-lite/BUILD b/java/kotlin-lite/BUILD index fd0c103166..18914441c9 100644 --- a/java/kotlin-lite/BUILD +++ b/java/kotlin-lite/BUILD @@ -1,6 +1,7 @@ load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") load("@rules_java//java:defs.bzl", "java_lite_proto_library") load("@rules_jvm_external//:kt_defs.bzl", "kt_jvm_export") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("//:protobuf_version.bzl", "PROTOBUF_VERSION") load("//:protobuf.bzl", "internal_gen_kt_protos") @@ -21,14 +22,18 @@ kt_jvm_library( "//:gen_well_known_protos_kotlinlite", ], deps = [ - "//java/lite", "//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", "//java/kotlin:shared_runtime", + "//java/lite", ], ) kt_jvm_export( name = "kotlin-lite_mvn", + deploy_env = [ + "@com_github_jetbrains_kotlin//:kotlin-stdlib", + "//java/lite", + ], maven_coordinates = "com.google.protobuf:protobuf-kotlin-lite:%s" % PROTOBUF_VERSION, pom_template = "//java/kotlin-lite:pom_template.xml", resources = ["//:well_known_protos"], @@ -39,10 +44,6 @@ kt_jvm_export( "//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", "//java/kotlin:shared_runtime", ], - deploy_env = [ - "@com_github_jetbrains_kotlin//:kotlin-stdlib", - "//java/lite", - ], ) filegroup( @@ -59,9 +60,9 @@ filegroup( test_suite( name = "tests", tests = [ - "test_lite_extensions", "proto2_test_lite", "proto3_test_lite", + "test_lite_extensions", ], ) @@ -71,9 +72,9 @@ kt_jvm_library( deps = [ ":example_extensible_message_java_proto_lite", ":lite_extensions", - "//java/lite", "//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", "//java/kotlin:shared_runtime", + "//java/lite", "@com_github_jetbrains_kotlin//:kotlin-test", "@maven//:com_google_truth_truth", "@maven//:junit_junit", @@ -82,8 +83,8 @@ kt_jvm_library( java_test( name = "test_lite_extensions", - runtime_deps = [":test_lite_extensions_library"], test_class = "com.google.protobuf.kotlin.ExtendableMessageLiteExtensionsTest", + runtime_deps = [":test_lite_extensions_library"], ) java_lite_proto_library( @@ -93,8 +94,8 @@ java_lite_proto_library( internal_gen_kt_protos( name = "gen_evil_names_proto2_lite", - deps = ["//java/kotlin:evil_names_proto2"], lite = True, + deps = ["//java/kotlin:evil_names_proto2"], ) java_lite_proto_library( @@ -104,8 +105,8 @@ java_lite_proto_library( internal_gen_kt_protos( name = "gen_evil_names_proto3_lite", - deps = ["//java/kotlin:evil_names_proto3"], lite = True, + deps = ["//java/kotlin:evil_names_proto3"], ) java_lite_proto_library( @@ -126,10 +127,10 @@ kt_jvm_library( ], deps = [ ":evil_names_proto2_java_proto_lite", - "//java/lite:lite", + "//:java_lite_test_protos", "//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", "//java/kotlin:shared_runtime", - "//:java_lite_test_protos", + "//java/lite", ], ) @@ -143,10 +144,10 @@ kt_jvm_library( deps = [ ":evil_names_proto3_java_proto_lite", ":multiple_files_proto3_java_proto_lite", - "//java/lite:lite", + "//:java_lite_test_protos", "//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests", "//java/kotlin:shared_runtime", - "//:java_lite_test_protos", + "//java/lite", ], ) @@ -163,8 +164,8 @@ kt_jvm_library( java_test( name = "proto2_test_lite", - runtime_deps = [":proto2_test_lite_library"], test_class = "com.google.protobuf.kotlin.Proto2LiteTest", + runtime_deps = [":proto2_test_lite_library"], ) kt_jvm_library( @@ -180,6 +181,24 @@ kt_jvm_library( java_test( name = "proto3_test_lite", - runtime_deps = [":proto3_test_lite_library"], test_class = "com.google.protobuf.kotlin.Proto3Test", + runtime_deps = [":proto3_test_lite_library"], +) + +pkg_files( + name = "dist_files", + srcs = glob([ + "src/main/kotlin/com/google/protobuf/*.kt", + "src/test/kotlin/**/*.kt", + ]) + [ + "BUILD", + "generate-sources-build.xml", + "generate-test-sources-build.xml", + "lite.awk", + "pom.xml", + "pom_template.xml", + "process-lite-sources-build.xml", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//java:__pkg__"], ) diff --git a/java/kotlin/BUILD b/java/kotlin/BUILD index 1da4de535c..c8aae0a047 100644 --- a/java/kotlin/BUILD +++ b/java/kotlin/BUILD @@ -1,12 +1,13 @@ load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_jvm_external//:kt_defs.bzl", "kt_jvm_export") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") load("//:protobuf_version.bzl", "PROTOBUF_VERSION") load("//:protobuf.bzl", "internal_gen_kt_protos") exports_files([ - "src/test/kotlin/com/google/protobuf/Proto3Test.kt", + "src/test/kotlin/com/google/protobuf/Proto3Test.kt", ]) # Kotlin generated protos depend on this and only this. @@ -36,34 +37,34 @@ kt_jvm_library( kt_jvm_library( name = "bytestring_lib", srcs = ["src/main/kotlin/com/google/protobuf/ByteStrings.kt"], - deps = ["//java/lite"], visibility = ["//java:__subpackages__"], + deps = ["//java/lite"], ) kt_jvm_library( name = "full_extensions", srcs = [ - "src/main/kotlin/com/google/protobuf/Anies.kt", - "src/main/kotlin/com/google/protobuf/ExtendableMessageExtensions.kt", + "src/main/kotlin/com/google/protobuf/Anies.kt", + "src/main/kotlin/com/google/protobuf/ExtendableMessageExtensions.kt", ], deps = ["//java/core"], ) kt_jvm_export( name = "kotlin_mvn", + deploy_env = [ + "@com_github_jetbrains_kotlin//:kotlin-stdlib", + "//java/core", + ], maven_coordinates = "com.google.protobuf:protobuf-kotlin:%s" % PROTOBUF_VERSION, pom_template = "//java/kotlin:pom_template.xml", resources = ["//:well_known_protos"], runtime_deps = [ - ":bytestring_lib", - ":full_extensions", - ":only_for_use_in_proto_generated_code_its_generator_and_tests", - ":shared_runtime", - ":well_known_protos_kotlin", - ], - deploy_env = [ - "@com_github_jetbrains_kotlin//:kotlin-stdlib", - "//java/core", + ":bytestring_lib", + ":full_extensions", + ":only_for_use_in_proto_generated_code_its_generator_and_tests", + ":shared_runtime", + ":well_known_protos_kotlin", ], ) @@ -82,10 +83,10 @@ test_suite( name = "tests", tests = [ "bytestring_test", - "shared_tests", - "test_extensions", "proto2_test", "proto3_test", + "shared_tests", + "test_extensions", ], ) @@ -103,8 +104,8 @@ kt_jvm_library( java_test( name = "bytestring_test", - runtime_deps = [":bytestring_test_library"], test_class = "com.google.protobuf.kotlin.ByteStringsTest", + runtime_deps = [":bytestring_test_library"], ) proto_library( @@ -131,31 +132,31 @@ kt_jvm_library( ":only_for_use_in_proto_generated_code_its_generator_and_tests", ":shared_runtime", "@com_github_jetbrains_kotlin//:kotlin-test", - "@maven//:com_google_truth_truth", "@maven//:com_google_guava_guava_testlib", + "@maven//:com_google_truth_truth", "@maven//:junit_junit", ], ) java_test( name = "shared_tests", - runtime_deps = [":shared_tests_library"], test_class = "com.google.protobuf.kotlin.DslListTest", + runtime_deps = [":shared_tests_library"], ) kt_jvm_library( name = "test_extensions_library", srcs = [ - "src/test/kotlin/com/google/protobuf/AniesTest.kt", - "src/test/kotlin/com/google/protobuf/ExtendableMessageExtensionsTest.kt", + "src/test/kotlin/com/google/protobuf/AniesTest.kt", + "src/test/kotlin/com/google/protobuf/ExtendableMessageExtensionsTest.kt", ], deps = [ ":example_extensible_message_java_proto", ":full_extensions", - "//java/core:core", ":kotlin_unittest", ":only_for_use_in_proto_generated_code_its_generator_and_tests", ":shared_runtime", + "//java/core", "@com_github_jetbrains_kotlin//:kotlin-test", "@maven//:com_google_truth_truth", "@maven//:junit_junit", @@ -164,8 +165,8 @@ kt_jvm_library( java_test( name = "test_extensions", - runtime_deps = [":test_extensions_library"], test_class = "com.google.protobuf.kotlin.ExtendableMessageExtensionsTest", + runtime_deps = [":test_extensions_library"], ) proto_library( @@ -224,11 +225,11 @@ kt_jvm_library( ], deps = [ ":evil_names_proto2_java_proto", - "//java/core:core", ":only_for_use_in_proto_generated_code_its_generator_and_tests", ":shared_runtime", ":well_known_protos_kotlin", "//:java_test_protos", + "//java/core", ], ) @@ -242,10 +243,10 @@ kt_jvm_library( deps = [ ":evil_names_proto3_java_proto", ":multiple_files_proto3_java_proto", - "//java/core:core", ":only_for_use_in_proto_generated_code_its_generator_and_tests", ":shared_runtime", "//:java_test_protos", + "//java/core", ], ) @@ -262,8 +263,8 @@ kt_jvm_library( java_test( name = "proto2_test", - runtime_deps = [":proto2_test_library"], test_class = "com.google.protobuf.kotlin.Proto2Test", + runtime_deps = [":proto2_test_library"], ) kt_jvm_library( @@ -279,8 +280,8 @@ kt_jvm_library( java_test( name = "proto3_test", - runtime_deps = [":proto3_test_library"], test_class = "com.google.protobuf.kotlin.Proto3Test", + runtime_deps = [":proto3_test_library"], ) kt_jvm_library( @@ -289,8 +290,25 @@ kt_jvm_library( "//:gen_well_known_protos_kotlin", ], deps = [ - "//java/core", - ":only_for_use_in_proto_generated_code_its_generator_and_tests", - ":shared_runtime", + ":only_for_use_in_proto_generated_code_its_generator_and_tests", + ":shared_runtime", + "//java/core", ], ) + +pkg_files( + name = "dist_files", + srcs = glob([ + "src/main/kotlin/com/google/protobuf/*.kt", + "src/test/kotlin/**/*.kt", + "src/test/proto/**/*.proto", + ]) + [ + "BUILD", + "generate-sources-build.xml", + "generate-test-sources-build.xml", + "pom.xml", + "pom_template.xml", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//java:__pkg__"], +) diff --git a/java/lite/BUILD b/java/lite/BUILD index fac19f609c..6ff858e3f6 100644 --- a/java/lite/BUILD +++ b/java/lite/BUILD @@ -1,4 +1,5 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain") load("//:internal.bzl", "conformance_test") load("//java/internal:testing.bzl", "junit_tests") @@ -21,9 +22,6 @@ alias( proto_lang_toolchain( name = "toolchain", - command_line = "--java_out=lite:$(OUT)", - runtime = ":lite", - visibility = ["//visibility:public"], # keep this in sync w/ LITE_WELL_KNOWN_PROTO_MAP in //:BUILD blacklisted_protos = [ "//:any_proto", @@ -37,6 +35,9 @@ proto_lang_toolchain( "//:type_proto", "//:wrappers_proto", ], + command_line = "--java_out=lite:$(OUT)", + runtime = ":lite", + visibility = ["//visibility:public"], ) test_suite( @@ -76,3 +77,20 @@ junit_tests( "@maven//:junit_junit", ], ) + +pkg_files( + name = "dist_files", + srcs = glob([ + "**/*.java", + ]) + [ + "BUILD", + "generate-sources-build.xml", + "generate-test-sources-build.xml", + "lite.awk", + "pom.xml", + "pom_template.xml", + "process-lite-sources-build.xml", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//java:__pkg__"], +) diff --git a/java/util/BUILD b/java/util/BUILD index 753fabb712..820adb9a01 100644 --- a/java/util/BUILD +++ b/java/util/BUILD @@ -1,5 +1,6 @@ load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_jvm_external//:defs.bzl", "java_export") +load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") load("//:protobuf_version.bzl", "PROTOBUF_VERSION") load("//java/internal:testing.bzl", "junit_tests") @@ -23,11 +24,11 @@ java_library( # Bazel users, don't depend on this target, use :util. java_export( name = "util_mvn", + deploy_env = ["//java/core"], maven_coordinates = "com.google.protobuf:protobuf-java-util:%s" % PROTOBUF_VERSION, pom_template = "pom_template.xml", visibility = ["//java:__pkg__"], runtime_deps = [":util"], - deploy_env = ["//java/core"], ) filegroup( @@ -74,3 +75,18 @@ junit_tests( "@maven//:junit_junit", ], ) + +pkg_files( + name = "dist_files", + srcs = glob([ + "src/main/**/*.java", + "src/test/**/*.java", + "src/test/**/*.proto", + ]) + [ + "BUILD", + "pom.xml", + "pom_template.xml", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//java:__pkg__"], +) diff --git a/js/BUILD b/js/BUILD new file mode 100644 index 0000000000..baa93be9cf --- /dev/null +++ b/js/BUILD @@ -0,0 +1,29 @@ +# Protobuf JS runtime +# +# See also code generation logic under /src/google/protobuf/compiler/js. + +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + +pkg_files( + name = "dist_files", + srcs = glob([ + "*.js", + "*.json", + "*.proto", + "binary/*.js", + "commonjs/*.js*", # js, json + "commonjs/**/*.proto", + "compatibility_tests/v3.0.0/**/*.js*", + "compatibility_tests/v3.0.0/**/*.proto", + "compatibility_tests/v3.0.0/**/*.sh", + "compatibility_tests/v3.1.0/**/*.js*", + "compatibility_tests/v3.1.0/**/*.proto", + "experimental/benchmarks/**/*.js", + "experimental/runtime/**/*.js", + ]) + [ + "BUILD", + "README.md", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) diff --git a/objectivec/BUILD b/objectivec/BUILD index 9f702ec95f..7b0ede6865 100644 --- a/objectivec/BUILD +++ b/objectivec/BUILD @@ -1,4 +1,5 @@ load("@rules_cc//cc:defs.bzl", "objc_library") +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") objc_library( name = "objectivec", @@ -63,28 +64,59 @@ objc_library( non_arc_srcs = [ "GPBAny.pbobjc.m", "GPBApi.pbobjc.m", - "GPBDuration.pbobjc.m", - "GPBEmpty.pbobjc.m", - "GPBFieldMask.pbobjc.m", - "GPBSourceContext.pbobjc.m", - "GPBStruct.pbobjc.m", - "GPBTimestamp.pbobjc.m", - "GPBType.pbobjc.m", - "GPBWrappers.pbobjc.m", "GPBArray.m", "GPBCodedInputStream.m", "GPBCodedOutputStream.m", "GPBDescriptor.m", "GPBDictionary.m", + "GPBDuration.pbobjc.m", + "GPBEmpty.pbobjc.m", "GPBExtensionInternals.m", "GPBExtensionRegistry.m", + "GPBFieldMask.pbobjc.m", "GPBMessage.m", "GPBRootObject.m", + "GPBSourceContext.pbobjc.m", + "GPBStruct.pbobjc.m", + "GPBTimestamp.pbobjc.m", + "GPBType.pbobjc.m", "GPBUnknownField.m", "GPBUnknownFieldSet.m", "GPBUtilities.m", "GPBWellKnownTypes.m", "GPBWireFormat.m", + "GPBWrappers.pbobjc.m", ], visibility = ["//visibility:public"], ) + +pkg_files( + name = "dist_files", + srcs = glob([ + "*.h", + "*.m", + "**/*.h", + "**/*.m", + "**/*.mm", + "**/*.swift", + "DevTools/*.sh", + "DevTools/*.py", + "ProtocolBuffers_iOS.xcodeproj/**/*", + "ProtocolBuffers_OSX.xcodeproj/**/*", + "ProtocolBuffers_tvOS.xcodeproj/**/*", + "Tests/CocoaPods/**/*", + "Tests/*.pddm", + "Tests/*.txt", + "Tests/*.plist", + "Tests/*.proto", + ]) + [ + ".clang-format", + "BUILD", + "README.md", + "Tests/golden_message", + "Tests/golden_packed_fields_message", + "generate_well_known_types.sh", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) diff --git a/php/BUILD b/php/BUILD new file mode 100644 index 0000000000..cf94be1cd4 --- /dev/null +++ b/php/BUILD @@ -0,0 +1,30 @@ +# Protobuf PHP runtime +# +# See also code generation logic under /src/google/protobuf/compiler/php. + +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + +pkg_files( + name = "dist_files", + srcs = glob([ + "ext/google/protobuf/**/*", + "src/GPBMetadata/Google/Protobuf/**/*.php", + "src/Google/Protobuf/**/*.php", + "tests/*.php", + "tests/*.sh", + "tests/proto/**/*.proto", + ]) + [ + "BUILD", + "README.md", + "REFCOUNTING.md", + "composer.json", + "generate_descriptor_protos.sh", + "generate_test_protos.sh", + "release.sh", + "src/phpdoc.dist.xml", + "tests/valgrind.supp", + ], + prefix = "php", + strip_prefix = strip_prefix.from_pkg(""), + visibility = ["//pkg:__pkg__"], +) diff --git a/pkg/BUILD b/pkg/BUILD index 3e5f5d1d75..b455cec378 100644 --- a/pkg/BUILD +++ b/pkg/BUILD @@ -1,8 +1,17 @@ -load("@rules_pkg//:pkg.bzl", "pkg_zip") -load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_files") +load("@rules_pkg//:pkg.bzl", "pkg_tar", "pkg_zip") +load( + "@rules_pkg//:mappings.bzl", + "pkg_attributes", + "pkg_filegroup", + "pkg_files", +) load("//:protobuf_release.bzl", "package_naming") load(":cc_dist_library.bzl", "cc_dist_library") +package_naming( + name = "protobuf_pkg_naming", +) + pkg_files( name = "wkt_protos_files", srcs = [ @@ -69,10 +78,6 @@ pkg_files( visibility = ["//visibility:private"], ) -package_naming( - name = "protoc_pkg_naming", -) - pkg_zip( name = "protoc_release", srcs = [ @@ -83,7 +88,249 @@ pkg_zip( ":wkt_protos_files", ], package_file_name = "protoc-{version}-{platform}.zip", - package_variables = ":protoc_pkg_naming", + package_variables = ":protobuf_pkg_naming", +) + +################################################################################ +# Source distribution packaging +# +# TODO: these will eventually replace autotools for release artifact packaging. +################################################################################ + +pkg_filegroup( + name = "dist_common", + srcs = [ + "//:common_dist_files", + "//:conformance_dist_files", + "//:cpp_dist_files", # to build protoc + "//benchmarks:all_dist_files", + "@com_google_protobuf_examples//:dist_files", + ], +) + +pkg_filegroup( + name = "cpp_srcs", + srcs = [ + ":dist_common", + "//:cpp_dist_files", + ], +) + +pkg_tar( + name = "dist_cpp_tar", + srcs = [":cpp_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-cpp-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_cpp_zip", + srcs = [":cpp_srcs"], + package_file_name = "protobuf-cpp-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "csharp_srcs", + srcs = [ + ":dist_common", + "//:csharp_dist_files", + "//csharp:dist_files", + ], +) + +pkg_tar( + name = "dist_csharp_tar", + srcs = [":csharp_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-csharp-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_csharp_zip", + srcs = [":csharp_srcs"], + package_file_name = "protobuf-csharp-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "java_srcs", + srcs = [ + ":dist_common", + "//java:all_dist_files", + ], +) + +pkg_tar( + name = "dist_java_tar", + srcs = [":java_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-java-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_java_zip", + srcs = [":java_srcs"], + package_file_name = "protobuf-java-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "js_srcs", + srcs = [ + ":dist_common", + "//js:dist_files", + ], +) + +pkg_tar( + name = "dist_js_tar", + srcs = [":js_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-js-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_js_zip", + srcs = [":js_srcs"], + package_file_name = "protobuf-js-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "objectivec_srcs", + srcs = [ + ":dist_common", + "//:objectivec_dist_files", + "//objectivec:dist_files", + ], +) + +pkg_tar( + name = "dist_objectivec_tar", + srcs = [":objectivec_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-objectivec-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_objectivec_zip", + srcs = [":objectivec_srcs"], + package_file_name = "protobuf-objectivec-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "php_srcs", + srcs = [ + ":dist_common", + "//:php_dist_files", + "//php:dist_files", + ], +) + +pkg_tar( + name = "dist_php_tar", + srcs = [":php_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-php-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_php_zip", + srcs = [":php_srcs"], + package_file_name = "protobuf-php-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "python_srcs", + srcs = [ + ":dist_common", + "//:python_dist_files", + ], +) + +pkg_tar( + name = "dist_python_tar", + srcs = [":python_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-python-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_python_zip", + srcs = [":python_srcs"], + package_file_name = "protobuf-python-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "ruby_srcs", + srcs = [ + ":dist_common", + "//ruby:dist_files", + ], +) + +pkg_tar( + name = "dist_ruby_tar", + srcs = [":ruby_srcs"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-ruby-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_ruby_zip", + srcs = [":ruby_srcs"], + package_file_name = "protobuf-ruby-{version}.zip", + package_variables = ":protobuf_pkg_naming", +) + +pkg_filegroup( + name = "dist_all", + srcs = [ + ":cpp_srcs", + ":csharp_srcs", + ":java_srcs", + ":js_srcs", + ":objectivec_srcs", + ":php_srcs", + ":python_srcs", + ":ruby_srcs", + ], +) + +pkg_tar( + name = "dist_all_tar", + srcs = [":dist_all"], + extension = "tar.gz", + package_dir = "protobuf-{version}", + package_file_name = "protobuf-all-{version}.tar.gz", + package_variables = ":protobuf_pkg_naming", +) + +pkg_zip( + name = "dist_all_zip", + srcs = [":dist_all"], + package_file_name = "protobuf-all-{version}.zip", + package_variables = ":protobuf_pkg_naming", ) ################################################################################ diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 0000000000..82a49e9bfd --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,31 @@ +# Protobuf packaging + +This directory contains Bazel rules for building packaging and distribution +artifacts. + +*Everything in this directory should be considered internal and subject to +change.* + +## Protocol compiler binary packaging + +The protocol compiler is used in binary form in various places. There are rules +which package it, along with commonly used `.proto` files, for distribution. + +## Source distribution packaging + +Protobuf releases include source distributions, sliced by target language (C++, +Java, etc.). There are rules in this package to define those source archives. +These depend upon `pkg_files` rules elsewhere in the repo to get the contents. + +The source distribution files should include the outputs from `autogen.sh`, but +this isn't something we can reliably do from Bazel. To produce fully functioning +source distributions, run `autogen.sh` before building the archives (this +populates the necessary files directly into the source tree). + +## C++ runtime binary distribution + +The `cc_dist_library` rule creates composite libraries from several other +`cc_library` targets. Bazel uses a "fine-grained" library model, where each +`cc_library` produces its own library artifacts, without transitive +dependencies. The `cc_dist_library` rule combines several other libraries +together, creating a single library that may be suitable for distribution. diff --git a/ruby/BUILD b/ruby/BUILD new file mode 100644 index 0000000000..1884c39834 --- /dev/null +++ b/ruby/BUILD @@ -0,0 +1,34 @@ +# Protobuf Ruby runtime +# +# See also code generation logic under /src/google/protobuf/compiler/ruby. + +load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + +pkg_files( + name = "dist_files", + srcs = glob([ + "compatibility_tests/v3.0.0/**/*", + "ext/google/protobuf_c/*", + "src/main/java/com/google/protobuf/jruby/*.java", + "tests/*.proto", + "tests/*.rb", + ]) + [ + ".gitignore", + "BUILD", + "Gemfile", + "README.md", + "Rakefile", + "google-protobuf.gemspec", + "lib/google/protobuf.rb", + "lib/google/protobuf/descriptor_dsl.rb", + "lib/google/protobuf/message_exts.rb", + "lib/google/protobuf/repeated_field.rb", + "lib/google/protobuf/well_known_types.rb", + "pom.xml", + "src/main/java/google/ProtobufJavaService.java", + "src/main/sentinel.proto", + "travis-test.sh", + ], + strip_prefix = strip_prefix.from_root(""), + visibility = ["//pkg:__pkg__"], +) diff --git a/third_party/zlib.BUILD b/third_party/zlib.BUILD index 093dee18dc..098f7bdd89 100644 --- a/third_party/zlib.BUILD +++ b/third_party/zlib.BUILD @@ -2,6 +2,8 @@ load("@rules_cc//cc:defs.bzl", "cc_library") licenses(["notice"]) # BSD/MIT-like license (for zlib) +exports_files(["zlib.BUILD"]) + _ZLIB_HEADERS = [ "crc32.h", "deflate.h", diff --git a/util/python/BUILD b/util/python/BUILD index 9ee56c87e7..85ede91c5b 100644 --- a/util/python/BUILD +++ b/util/python/BUILD @@ -1,5 +1,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library") +exports_files(["BUILD"]) + # This is a placeholder for python headers. Projects needing to use # fast cpp protos in protobuf's python interface should build with # --define=use_fast_cpp_protos=true, and in addition, provide