From c0f4c1a155b14d118fc845ef4bdd2a2f9eb2c970 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 10:37:59 +0000 Subject: [PATCH 01/19] Adding .bcr rules --- .bcr/metadata.template.json | 6 ++++++ .bcr/presubmit.yml | 9 +++++++++ .bcr/source.template.json | 5 +++++ 3 files changed, 20 insertions(+) create mode 100644 .bcr/metadata.template.json create mode 100644 .bcr/presubmit.yml create mode 100644 .bcr/source.template.json diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000..c29a377 --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,6 @@ +{ + "homepage": "https://github.com/bazelbuild/rules_proto" + "maintainers": [], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000..db4b09f --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,9 @@ +bcr_test_module: + matrix: + platform: ["centos7", "debian10", "macos", "ubuntu2004", "windows"] + tasks: + run_tests: + name: "Run test module" + platform: ${{ platform }} + test_targets: + - "//..." diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000..4f14819 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "{REPO}-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz" +} From 0d5030697e106c97861b3117ce462cd211d71e09 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 10:38:49 +0000 Subject: [PATCH 02/19] Initial version of MODULE.bazel --- MODULE.bazel | 11 +++++++++++ WORKSPACE.bzlmod | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bzlmod diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..d0eb4af --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,11 @@ +module( + name = "rules_proto", + compatibility_level = 1, + version = "5.3.0-21.5", +) + +bazel_dep(name = "bazel_skylib", version = "1.1.1") +bazel_dep(name = "rules_cc", version = "0.0.1") +bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "3.19.0") +bazel_dep(name = "googletest", repo_name = "com_google_googletest", version = "1.11.0") +bazel_dep(name = "rules_java", version = "5.1.0") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 0000000..38bffce --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1,7 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "remote_coverage_tools", + sha256 = "cd14f1cb4559e4723e63b7e7b06d09fcc3bd7ba58d03f354cdff1439bd936a7d", + urls = ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"], +) From b422768f7ebadaf903ba0a3051f49b06f64c179e Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 10:48:07 +0000 Subject: [PATCH 03/19] Configure CI --- .bazelci/presubmit.yml | 90 +++++++++++++++++++++++++++++++----------- .bazelrc | 3 ++ 2 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 .bazelrc diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index c8f7270..42aec63 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,31 +1,77 @@ --- +build_targets: &build_targets + - "//..." +test_targets: &test_targets + - "//..." + +build_targets_bzlmod: &build_targets_bzlmod + - "//..." +test_targets_bzlmod: &test_targets_bzlmod + buildifier: version: latest # skylark-comment fails because links to Bazel's docs for # `ProtoInfo` and `proto_common` contain `/skylark/`. warnings: "-skylark-comment" -platforms: +tasks: + ubuntu2004: + build_targets: *build_targets + test_targets: *test_targets macos: - build_targets: - - "//..." - test_targets: - - "//..." - - rbe_ubuntu1604: - build_targets: - - "//..." - test_targets: - - "//..." - - ubuntu1804: - build_targets: - - "//..." - test_targets: - - "//..." - + build_targets: *build_targets + test_targets: *test_targets windows: - build_targets: - - "//..." - test_targets: - - "//..." + build_targets: *build_targets + test_targets: *test_targets + rbe_ubuntu2004: + build_targets: *build_targets + test_targets: *test_targets + ubuntu2004_head: + bazel: last_green + platform: ubuntu2004 + build_targets: *build_targets + test_targets: *test_targets + macos_head: + bazel: last_green + platform: macos + build_targets: *build_targets + test_targets: *test_targets + windows_head: + bazel: last_green + platform: windows + build_targets: *build_targets + test_targets: *test_targets + rbe_ubuntu2004_head: + bazel: last_green + platform: rbe_ubuntu2004 + build_targets: *build_targets + test_targets: *test_targets + ubuntu2004_bzlmod: + bazel: last_green + platform: rbe_ubuntu2004 + build_flags: + - "--config=bzlmod" + build_targets: *build_targets_bzlmod + test_targets: *test_targets_bzlmod + macos_bzlmod: + bazel: last_green + platform: macos + build_flags: + - "--config=bzlmod" + build_targets: *build_targets_bzlmod + test_targets: *test_targets_bzlmod + windows_bzlmod: + bazel: last_green + platform: windows + build_flags: + - "--config=bzlmod" + build_targets: *build_targets_bzlmod + test_targets: *test_targets_bzlmod + rbe_ubuntu2004_bzlmod: + bazel: last_green + platform: rbe_ubuntu2004 + build_flags: + - "--config=bzlmod" + build_targets: *build_targets_bzlmod + test_targets: *test_targets_bzlmod diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..44860da --- /dev/null +++ b/.bazelrc @@ -0,0 +1,3 @@ +build:bzlmod --experimental_enable_bzlmod +build:bzlmod --crosstool_top=@rules_cc.0.0.1.cc_configure.local_config_cc//:toolchain +build:bzlmod --host_crosstool_top=@rules_cc.0.0.1.cc_configure.local_config_cc//:toolchain From 7e3745605cc012c573af47efcf931fb8aa3f0a33 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 10:55:21 +0000 Subject: [PATCH 04/19] Fix presubmit script --- .bazelci/presubmit.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 42aec63..4046c81 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -7,6 +7,7 @@ test_targets: &test_targets build_targets_bzlmod: &build_targets_bzlmod - "//..." test_targets_bzlmod: &test_targets_bzlmod + - "//..." buildifier: version: latest @@ -42,11 +43,6 @@ tasks: platform: windows build_targets: *build_targets test_targets: *test_targets - rbe_ubuntu2004_head: - bazel: last_green - platform: rbe_ubuntu2004 - build_targets: *build_targets - test_targets: *test_targets ubuntu2004_bzlmod: bazel: last_green platform: rbe_ubuntu2004 @@ -68,10 +64,3 @@ tasks: - "--config=bzlmod" build_targets: *build_targets_bzlmod test_targets: *test_targets_bzlmod - rbe_ubuntu2004_bzlmod: - bazel: last_green - platform: rbe_ubuntu2004 - build_flags: - - "--config=bzlmod" - build_targets: *build_targets_bzlmod - test_targets: *test_targets_bzlmod From e52c7af311edecea03c30f22a4058829a04fd3d7 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 10:56:19 +0000 Subject: [PATCH 05/19] Fix presubmit script --- .bazelci/presubmit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 4046c81..dc03a0b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -45,7 +45,7 @@ tasks: test_targets: *test_targets ubuntu2004_bzlmod: bazel: last_green - platform: rbe_ubuntu2004 + platform: ubuntu2004 build_flags: - "--config=bzlmod" build_targets: *build_targets_bzlmod From 19051e55e0aff0d0d68880d52948c67a966a3b18 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 10:56:59 +0000 Subject: [PATCH 06/19] Fix presubmit script --- .bazelci/presubmit.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index dc03a0b..00a0c6c 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -25,9 +25,6 @@ tasks: windows: build_targets: *build_targets test_targets: *test_targets - rbe_ubuntu2004: - build_targets: *build_targets - test_targets: *test_targets ubuntu2004_head: bazel: last_green platform: ubuntu2004 From 5612db8e0abdf5194f9bca199e2faa71947a1d3b Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 13:57:56 +0000 Subject: [PATCH 07/19] Fixing coverage import and cc toolchains --- .bazelrc | 2 -- MODULE.bazel | 4 ++++ WORKSPACE.bzlmod | 7 ------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.bazelrc b/.bazelrc index 44860da..4fadfce 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1 @@ build:bzlmod --experimental_enable_bzlmod -build:bzlmod --crosstool_top=@rules_cc.0.0.1.cc_configure.local_config_cc//:toolchain -build:bzlmod --host_crosstool_top=@rules_cc.0.0.1.cc_configure.local_config_cc//:toolchain diff --git a/MODULE.bazel b/MODULE.bazel index d0eb4af..c49b766 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -9,3 +9,7 @@ bazel_dep(name = "rules_cc", version = "0.0.1") bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "3.19.0") bazel_dep(name = "googletest", repo_name = "com_google_googletest", version = "1.11.0") bazel_dep(name = "rules_java", version = "5.1.0") + +# Importing non bzl-mod remote_coverage_tools +coverage_deps_ext = use_extension("//proto/private:bzlmod_deps.bzl", "coverage_deps_ext") +use_repo(coverage_deps_ext, "remote_coverage_tools") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index 38bffce..e69de29 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -1,7 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "remote_coverage_tools", - sha256 = "cd14f1cb4559e4723e63b7e7b06d09fcc3bd7ba58d03f354cdff1439bd936a7d", - urls = ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"], -) From 6741cd906b019510a838e403913219c9990574d6 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 14:31:04 +0000 Subject: [PATCH 08/19] missing file --- proto/private/bzlmod_deps.bzl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 proto/private/bzlmod_deps.bzl diff --git a/proto/private/bzlmod_deps.bzl b/proto/private/bzlmod_deps.bzl new file mode 100644 index 0000000..839dd48 --- /dev/null +++ b/proto/private/bzlmod_deps.bzl @@ -0,0 +1,16 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def remote_coverage_tools(): + http_archive( + name = "remote_coverage_tools", + sha256 = "cd14f1cb4559e4723e63b7e7b06d09fcc3bd7ba58d03f354cdff1439bd936a7d", + urls = ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"], + ) + +def _coverage_deps_extension_impl(ctx): + remote_coverage_tools() + +coverage_deps_ext = module_extension( + implementation = _coverage_deps_extension_impl, +) + From 5cb9fe68b027a5dfe14d37ba1b38020f411469bf Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 14:33:47 +0000 Subject: [PATCH 09/19] Fix presubmit configs. --- .bazelci/presubmit.yml | 6 ++++++ .bcr/presubmit.yml | 17 ++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 00a0c6c..ea48388 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -46,6 +46,8 @@ tasks: build_flags: - "--config=bzlmod" build_targets: *build_targets_bzlmod + test_flags: + - "--config=bzlmod" test_targets: *test_targets_bzlmod macos_bzlmod: bazel: last_green @@ -53,6 +55,8 @@ tasks: build_flags: - "--config=bzlmod" build_targets: *build_targets_bzlmod + test_flags: + - "--config=bzlmod" test_targets: *test_targets_bzlmod windows_bzlmod: bazel: last_green @@ -60,4 +64,6 @@ tasks: build_flags: - "--config=bzlmod" build_targets: *build_targets_bzlmod + test_flags: + - "--config=bzlmod" test_targets: *test_targets_bzlmod diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index db4b09f..0cdbbf6 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -1,9 +1,8 @@ -bcr_test_module: - matrix: - platform: ["centos7", "debian10", "macos", "ubuntu2004", "windows"] - tasks: - run_tests: - name: "Run test module" - platform: ${{ platform }} - test_targets: - - "//..." +matrix: + platform: ["centos7", "debian10", "macos", "ubuntu2004", "windows"] +tasks: + run_tests: + name: "Verify build targets" + platform: ${{ platform }} + build_targets: + - "@rules_proto//..." From 0462c19bbad3cd5e0a40bb5a3b06e8a87f6130ce Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 14:35:41 +0000 Subject: [PATCH 10/19] Buildifier. --- MODULE.bazel | 1 + proto/private/bzlmod_deps.bzl | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index c49b766..e209d32 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,4 +12,5 @@ bazel_dep(name = "rules_java", version = "5.1.0") # Importing non bzl-mod remote_coverage_tools coverage_deps_ext = use_extension("//proto/private:bzlmod_deps.bzl", "coverage_deps_ext") + use_repo(coverage_deps_ext, "remote_coverage_tools") diff --git a/proto/private/bzlmod_deps.bzl b/proto/private/bzlmod_deps.bzl index 839dd48..a10bc9c 100644 --- a/proto/private/bzlmod_deps.bzl +++ b/proto/private/bzlmod_deps.bzl @@ -1,16 +1,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def remote_coverage_tools(): - http_archive( - name = "remote_coverage_tools", - sha256 = "cd14f1cb4559e4723e63b7e7b06d09fcc3bd7ba58d03f354cdff1439bd936a7d", - urls = ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"], - ) + http_archive( + name = "remote_coverage_tools", + sha256 = "cd14f1cb4559e4723e63b7e7b06d09fcc3bd7ba58d03f354cdff1439bd936a7d", + urls = ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"], + ) def _coverage_deps_extension_impl(ctx): - remote_coverage_tools() + remote_coverage_tools() coverage_deps_ext = module_extension( implementation = _coverage_deps_extension_impl, ) - From 27232d27028976238f99e581f8c4e11f87fb8e6d Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 14:38:41 +0000 Subject: [PATCH 11/19] add copyright and module docstring --- proto/private/bzlmod_deps.bzl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/proto/private/bzlmod_deps.bzl b/proto/private/bzlmod_deps.bzl index a10bc9c..64869a6 100644 --- a/proto/private/bzlmod_deps.bzl +++ b/proto/private/bzlmod_deps.bzl @@ -1,3 +1,27 @@ +# Copyright 2022 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. + +# Redefine native symbols with a new name as a workaround for +# exporting them in `//proto:defs.bzl` with their original name. +# +# While we cannot force users to load these symbol due to the lack of a +# allowlisting mechanism, we can still export them and tell users to +# load it to make a future migration to pure Starlark easier. + + +"""Adding missing bzlmod dependencies.""" + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def remote_coverage_tools(): @@ -7,7 +31,7 @@ def remote_coverage_tools(): urls = ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"], ) -def _coverage_deps_extension_impl(ctx): +def _coverage_deps_extension_impl(_ctx): remote_coverage_tools() coverage_deps_ext = module_extension( From 940e468b9401b3b2c17e4d7e3d8d43ff04784249 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 20 Sep 2022 15:19:08 +0000 Subject: [PATCH 12/19] Address different handling of runfiles in bzlmod. --- .../proto_descriptor_set/proto_descriptor_set_test.cc | 9 +++++++-- tests/utils/workspace_constants.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc b/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc index f1d407c..c48b8c4 100644 --- a/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc +++ b/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc @@ -33,7 +33,12 @@ namespace { std::string GetRlocation(const std::string& file) { static std::unique_ptr runfiles(Runfiles::CreateForTest()); - return runfiles->Rlocation(file); + std::string path = runfiles->Rlocation(rulesproto::kWorkspaceRlocation + file); + std::ifstream input(path, std::ifstream::binary); + if (!input) { + path = runfiles->Rlocation(rulesproto::kWorkspaceRlocationBzlmod + file); + } + return path; } template @@ -66,7 +71,7 @@ void AssertFileDescriptorSetContains( const std::vector& expected_proto_files) { std::vector actual_proto_files = ReadFileDescriptorSet( - GetRlocation(rulesproto::kWorkspaceRlocation + path)); + GetRlocation(path)); EXPECT_EQ(expected_proto_files, actual_proto_files); } diff --git a/tests/utils/workspace_constants.h b/tests/utils/workspace_constants.h index d1eae5e..2658003 100644 --- a/tests/utils/workspace_constants.h +++ b/tests/utils/workspace_constants.h @@ -22,5 +22,6 @@ namespace rulesproto { constexpr char kWorkspaceRlocation[] = "rules_proto/"; +constexpr char kWorkspaceRlocationBzlmod[] = "__main__/"; } // namespace rulesproto From 8fa4805757a913f035315be8e26cd81df5abc4c3 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Wed, 21 Sep 2022 07:09:17 +0000 Subject: [PATCH 13/19] Revert "Address different handling of runfiles in bzlmod." This reverts commit 940e468b9401b3b2c17e4d7e3d8d43ff04784249. --- .../proto_descriptor_set/proto_descriptor_set_test.cc | 9 ++------- tests/utils/workspace_constants.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc b/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc index c48b8c4..f1d407c 100644 --- a/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc +++ b/tests/rules/proto_descriptor_set/proto_descriptor_set_test.cc @@ -33,12 +33,7 @@ namespace { std::string GetRlocation(const std::string& file) { static std::unique_ptr runfiles(Runfiles::CreateForTest()); - std::string path = runfiles->Rlocation(rulesproto::kWorkspaceRlocation + file); - std::ifstream input(path, std::ifstream::binary); - if (!input) { - path = runfiles->Rlocation(rulesproto::kWorkspaceRlocationBzlmod + file); - } - return path; + return runfiles->Rlocation(file); } template @@ -71,7 +66,7 @@ void AssertFileDescriptorSetContains( const std::vector& expected_proto_files) { std::vector actual_proto_files = ReadFileDescriptorSet( - GetRlocation(path)); + GetRlocation(rulesproto::kWorkspaceRlocation + path)); EXPECT_EQ(expected_proto_files, actual_proto_files); } diff --git a/tests/utils/workspace_constants.h b/tests/utils/workspace_constants.h index 2658003..d1eae5e 100644 --- a/tests/utils/workspace_constants.h +++ b/tests/utils/workspace_constants.h @@ -22,6 +22,5 @@ namespace rulesproto { constexpr char kWorkspaceRlocation[] = "rules_proto/"; -constexpr char kWorkspaceRlocationBzlmod[] = "__main__/"; } // namespace rulesproto From bd6e254cc3c40e72c5fd405a1a3a155962e6a309 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Wed, 21 Sep 2022 07:15:22 +0000 Subject: [PATCH 14/19] Add repo_name --- MODULE.bazel | 1 + WORKSPACE.bzlmod | 2 ++ 2 files changed, 3 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index e209d32..e468e82 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,5 +1,6 @@ module( name = "rules_proto", + repo_name = "rules_proto", compatibility_level = 1, version = "5.3.0-21.5", ) diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index e69de29..e2857dc 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -0,0 +1,2 @@ +# TODO(bazel-team): Without following line runfiles use __main__ as a repo name. +workspace(name = "rules_proto") From fbf31962db93adde85fa13f9b1aa5b359123fe1a Mon Sep 17 00:00:00 2001 From: Ivo List Date: Wed, 21 Sep 2022 07:15:49 +0000 Subject: [PATCH 15/19] Buildifier --- proto/private/bzlmod_deps.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/proto/private/bzlmod_deps.bzl b/proto/private/bzlmod_deps.bzl index 64869a6..271472c 100644 --- a/proto/private/bzlmod_deps.bzl +++ b/proto/private/bzlmod_deps.bzl @@ -19,7 +19,6 @@ # allowlisting mechanism, we can still export them and tell users to # load it to make a future migration to pure Starlark easier. - """Adding missing bzlmod dependencies.""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") From 405cdd8b23d57c663853f0c9bd10e3df104bcda5 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Wed, 21 Sep 2022 07:19:12 +0000 Subject: [PATCH 16/19] Buildifier --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index e468e82..1326242 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,7 +1,7 @@ module( name = "rules_proto", - repo_name = "rules_proto", compatibility_level = 1, + repo_name = "rules_proto", version = "5.3.0-21.5", ) From 76ab0fe633b0406ab1d3292b629916d6e34cbb37 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Wed, 21 Sep 2022 07:30:45 +0000 Subject: [PATCH 17/19] Remove remote_coverage_tools - it builds without them --- MODULE.bazel | 5 ----- proto/private/bzlmod_deps.bzl | 38 ----------------------------------- 2 files changed, 43 deletions(-) delete mode 100644 proto/private/bzlmod_deps.bzl diff --git a/MODULE.bazel b/MODULE.bazel index 1326242..70e0c48 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -10,8 +10,3 @@ bazel_dep(name = "rules_cc", version = "0.0.1") bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "3.19.0") bazel_dep(name = "googletest", repo_name = "com_google_googletest", version = "1.11.0") bazel_dep(name = "rules_java", version = "5.1.0") - -# Importing non bzl-mod remote_coverage_tools -coverage_deps_ext = use_extension("//proto/private:bzlmod_deps.bzl", "coverage_deps_ext") - -use_repo(coverage_deps_ext, "remote_coverage_tools") diff --git a/proto/private/bzlmod_deps.bzl b/proto/private/bzlmod_deps.bzl deleted file mode 100644 index 271472c..0000000 --- a/proto/private/bzlmod_deps.bzl +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2022 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. - -# Redefine native symbols with a new name as a workaround for -# exporting them in `//proto:defs.bzl` with their original name. -# -# While we cannot force users to load these symbol due to the lack of a -# allowlisting mechanism, we can still export them and tell users to -# load it to make a future migration to pure Starlark easier. - -"""Adding missing bzlmod dependencies.""" - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -def remote_coverage_tools(): - http_archive( - name = "remote_coverage_tools", - sha256 = "cd14f1cb4559e4723e63b7e7b06d09fcc3bd7ba58d03f354cdff1439bd936a7d", - urls = ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"], - ) - -def _coverage_deps_extension_impl(_ctx): - remote_coverage_tools() - -coverage_deps_ext = module_extension( - implementation = _coverage_deps_extension_impl, -) From a2c430f40a6f9975a141e6420f1a483631b059ef Mon Sep 17 00:00:00 2001 From: Ivo List Date: Wed, 21 Sep 2022 07:44:53 +0000 Subject: [PATCH 18/19] Optimise dependencies. --- MODULE.bazel | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 70e0c48..c1085ff 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,7 +6,10 @@ module( ) bazel_dep(name = "bazel_skylib", version = "1.1.1") -bazel_dep(name = "rules_cc", version = "0.0.1") bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "3.19.0") -bazel_dep(name = "googletest", repo_name = "com_google_googletest", version = "1.11.0") -bazel_dep(name = "rules_java", version = "5.1.0") + +# TODO(bazel-team): add support for protobuf_workspace + +# Dependencies needed in tests +bazel_dep(name = "rules_cc", dev_dependency = True, version = "0.0.1") +bazel_dep(name = "googletest", dev_dependency = True, repo_name = "com_google_googletest", version = "1.11.0") From ad04b537f2570b9517f6c0fc1e0a4730232e3232 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Wed, 21 Sep 2022 08:43:06 +0000 Subject: [PATCH 19/19] Fixes --- .bazelrc | 2 +- .bcr/presubmit.yml | 2 +- MODULE.bazel | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 4fadfce..f1a8f3d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +1 @@ -build:bzlmod --experimental_enable_bzlmod +build:bzlmod --enable_bzlmod diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 0cdbbf6..59c12a0 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -1,7 +1,7 @@ matrix: platform: ["centos7", "debian10", "macos", "ubuntu2004", "windows"] tasks: - run_tests: + verify_build_targets: name: "Verify build targets" platform: ${{ platform }} build_targets: diff --git a/MODULE.bazel b/MODULE.bazel index c1085ff..41a695b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,7 +1,6 @@ module( name = "rules_proto", compatibility_level = 1, - repo_name = "rules_proto", version = "5.3.0-21.5", )