mirror of https://github.com/bazelbuild/rules_cc
Copybara Merge: https://github.com/bazelbuild/rules_cc/pull/165
BEGIN_PUBLIC Copybara import of the project: -- 56e69b82484f1a9fb55d8173cc112f9f608f3581 by Fabian Meumertzheim <fabian@meumertzhe.im>: Simplify WORKSPACE setup and update ancient deps By removing a single unused `bzl_library` target, rules_cc no longer has any dependencies that would need to be loaded by a dependency macro. The existing macro is made a no-op. The few needed Bazel Federation dependencies are inlined and, in the case of bazel_skylib and abseil-py, updated to modern versions. Also reorders `WORKSPACE` to list direct dependencies first and keeps `MODULE.bazel` in sync with the dependency versions used in WORKSPACE. The `ubuntu1604` CI pipeline is removed as the version of Python used by it is no longer supported and the distribution is EOL. Instead, a new pipeline is added to check the Bzlmod build. END_PUBLIC COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_cc/pull/165 from fmeum:fix-workspace-module 56e69b82484f1a9fb55d8173cc112f9f608f3581 PiperOrigin-RevId: 501245864 Change-Id: Ib71ad910705807a00929a76774387a38d2da0f9f
This commit is contained in:
parent
bc665f9271
commit
66cf3048e9
|
@ -35,11 +35,17 @@ buildifier:
|
||||||
warnings: "all"
|
warnings: "all"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
ubuntu1604:
|
|
||||||
<<: *common
|
|
||||||
ubuntu1804:
|
ubuntu1804:
|
||||||
<<: *common
|
<<: *common
|
||||||
macos:
|
macos:
|
||||||
<<: *common
|
<<: *common
|
||||||
windows:
|
windows:
|
||||||
<<: *common
|
<<: *common
|
||||||
|
ubuntu_bzlmod:
|
||||||
|
name: Bzlmod
|
||||||
|
platform: ubuntu1804
|
||||||
|
build_flags:
|
||||||
|
- "--enable_bzlmod"
|
||||||
|
- "--ignore_dev_dependency"
|
||||||
|
build_targets:
|
||||||
|
- "//cc/..."
|
||||||
|
|
25
BUILD
25
BUILD
|
@ -1,30 +1,5 @@
|
||||||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
|
||||||
|
|
||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
licenses(["notice"])
|
licenses(["notice"])
|
||||||
|
|
||||||
exports_files(["LICENSE"])
|
exports_files(["LICENSE"])
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "distribution",
|
|
||||||
srcs = [
|
|
||||||
"BUILD",
|
|
||||||
"LICENSE",
|
|
||||||
"internal_deps.bzl",
|
|
||||||
"internal_setup.bzl",
|
|
||||||
],
|
|
||||||
visibility = ["@//distro:__pkg__"],
|
|
||||||
)
|
|
||||||
|
|
||||||
bzl_library(
|
|
||||||
name = "internal_deps_bzl",
|
|
||||||
srcs = ["internal_deps.bzl"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
||||||
bzl_library(
|
|
||||||
name = "internal_setup_bzl",
|
|
||||||
srcs = ["internal_setup.bzl"],
|
|
||||||
visibility = ["//visibility:private"],
|
|
||||||
)
|
|
||||||
|
|
|
@ -4,10 +4,11 @@ module(
|
||||||
compatibility_level = 1,
|
compatibility_level = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
bazel_dep(name = "bazel_skylib", version = "1.0.3")
|
bazel_dep(name = "platforms", version = "0.0.6")
|
||||||
bazel_dep(name = "platforms", version = "0.0.4")
|
|
||||||
|
|
||||||
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure")
|
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure")
|
||||||
use_repo(cc_configure, "local_config_cc_toolchains")
|
use_repo(cc_configure, "local_config_cc_toolchains")
|
||||||
|
|
||||||
register_toolchains("@local_config_cc_toolchains//:all")
|
register_toolchains("@local_config_cc_toolchains//:all")
|
||||||
|
|
||||||
|
bazel_dep(name = "bazel_skylib", dev_dependency = True, version = "1.3.0")
|
||||||
|
|
|
@ -20,8 +20,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "rules_cc",
|
name = "rules_cc",
|
||||||
urls = ["https://github.com/bazelbuild/rules_cc/archive/TODO"],
|
urls = ["https://github.com/bazelbuild/rules_cc/archive/refs/tags/<VERSION>.tar.gz"],
|
||||||
sha256 = "TODO",
|
sha256 = "...",
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
99
WORKSPACE
99
WORKSPACE
|
@ -3,11 +3,30 @@ workspace(name = "rules_cc")
|
||||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "platforms",
|
name = "bazel_skylib",
|
||||||
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
|
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
|
||||||
urls = [
|
urls = [
|
||||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
|
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
|
||||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
|
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "com_google_googletest",
|
||||||
|
sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2",
|
||||||
|
strip_prefix = "googletest-release-1.12.1",
|
||||||
|
urls = [
|
||||||
|
"https://mirror.bazel.build/github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz",
|
||||||
|
"https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "io_abseil_py",
|
||||||
|
sha256 = "c0bf3e839b7b1c58ac75e41f72a708597087a6c7dd0582aec4914e0d98ec8b04",
|
||||||
|
strip_prefix = "abseil-py-1.3.0",
|
||||||
|
urls = [
|
||||||
|
"https://github.com/abseil/abseil-py/archive/refs/tags/v1.3.0.tar.gz",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,46 +39,29 @@ http_archive(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
|
||||||
|
|
||||||
go_rules_dependencies()
|
|
||||||
|
|
||||||
go_register_toolchains(version = "1.19.1")
|
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "bazel_federation",
|
name = "platforms",
|
||||||
sha256 = "0d6893f0d18f417a3324ce7f0ed2e6e5b825d6d5ab42f0f3d7877cb313f36453",
|
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
|
||||||
strip_prefix = "bazel-federation-6ad33bc586701e9836a2bf4432c7aff1235b04d2",
|
urls = [
|
||||||
type = "zip",
|
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
|
||||||
url = "https://github.com/bazelbuild/bazel-federation/archive/6ad33bc586701e9836a2bf4432c7aff1235b04d2.zip", # 2019-09-30
|
"https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
load("@bazel_federation//:repositories.bzl", "rules_cc_deps")
|
|
||||||
|
|
||||||
rules_cc_deps()
|
|
||||||
|
|
||||||
load("@bazel_federation//setup:rules_cc.bzl", "rules_cc_setup")
|
|
||||||
|
|
||||||
rules_cc_setup()
|
|
||||||
|
|
||||||
#
|
|
||||||
# Dependencies for development of rules_cc itself.
|
|
||||||
#
|
|
||||||
load("//:internal_deps.bzl", "rules_cc_internal_deps")
|
|
||||||
|
|
||||||
rules_cc_internal_deps()
|
|
||||||
|
|
||||||
load("//:internal_setup.bzl", "rules_cc_internal_setup")
|
|
||||||
|
|
||||||
rules_cc_internal_setup()
|
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "com_google_googletest",
|
name = "py_mock",
|
||||||
sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2",
|
patch_cmds = [
|
||||||
strip_prefix = "googletest-release-1.12.1",
|
"mkdir -p py/mock",
|
||||||
|
"mv mock.py py/mock/__init__.py",
|
||||||
|
"""echo 'licenses(["notice"])' > BUILD""",
|
||||||
|
"touch py/BUILD",
|
||||||
|
"""echo 'py_library(name = "mock", srcs = ["__init__.py"], visibility = ["//visibility:public"],)' > py/mock/BUILD""",
|
||||||
|
],
|
||||||
|
sha256 = "b839dd2d9c117c701430c149956918a423a9863b48b09c90e30a6013e7d2f44f",
|
||||||
|
strip_prefix = "mock-1.0.1",
|
||||||
urls = [
|
urls = [
|
||||||
"https://mirror.bazel.build/github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz",
|
"https://mirror.bazel.build/pypi.python.org/packages/source/m/mock/mock-1.0.1.tar.gz",
|
||||||
"https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz",
|
"https://pypi.python.org/packages/source/m/mock/mock-1.0.1.tar.gz",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,17 +75,18 @@ http_archive(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||||
|
|
||||||
|
bazel_skylib_workspace()
|
||||||
|
|
||||||
|
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||||
|
|
||||||
|
go_rules_dependencies()
|
||||||
|
|
||||||
|
go_register_toolchains(version = "1.19.4")
|
||||||
|
|
||||||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
|
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
|
||||||
|
|
||||||
rules_proto_dependencies()
|
rules_proto_dependencies()
|
||||||
|
|
||||||
rules_proto_toolchains()
|
rules_proto_toolchains()
|
||||||
|
|
||||||
load("//cc:repositories.bzl", "rules_cc_toolchains")
|
|
||||||
|
|
||||||
rules_cc_toolchains()
|
|
||||||
|
|
||||||
local_repository(
|
|
||||||
name = "test_repo",
|
|
||||||
path = "examples/test_cc_shared_library2",
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
|
||||||
|
|
||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
licenses(["notice"]) # Apache 2.0
|
licenses(["notice"]) # Apache 2.0
|
||||||
|
@ -18,9 +16,3 @@ filegroup(
|
||||||
"**/BUILD",
|
"**/BUILD",
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
|
|
||||||
bzl_library(
|
|
||||||
name = "native_bzl",
|
|
||||||
srcs = ["native.bzl"],
|
|
||||||
visibility = ["//cc:__pkg__"],
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,32 +1,10 @@
|
||||||
"""Repository rules entry point module for rules_cc."""
|
"""Repository rules entry point module for rules_cc."""
|
||||||
|
|
||||||
# WARNING: This file only exists for backwards-compatibility.
|
|
||||||
# rules_cc uses the Bazel federation, so please add any new dependencies to
|
|
||||||
# rules_cc_deps() in
|
|
||||||
# https://github.com/bazelbuild/bazel-federation/blob/master/repositories.bzl
|
|
||||||
# Third party dependencies can be added to
|
|
||||||
# https://github.com/bazelbuild/bazel-federation/blob/master/third_party_repositories.bzl
|
|
||||||
# Ideally we'd delete this entire file.
|
|
||||||
|
|
||||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
||||||
load("//cc/private/toolchain:cc_configure.bzl", "cc_configure")
|
load("//cc/private/toolchain:cc_configure.bzl", "cc_configure")
|
||||||
|
|
||||||
def rules_cc_dependencies():
|
def rules_cc_dependencies():
|
||||||
_maybe(
|
pass
|
||||||
http_archive,
|
|
||||||
name = "bazel_skylib",
|
|
||||||
sha256 = "2ea8a5ed2b448baf4a6855d3ce049c4c452a6470b1efd1504fdb7c1c134d220a",
|
|
||||||
strip_prefix = "bazel-skylib-0.8.0",
|
|
||||||
urls = [
|
|
||||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/archive/0.8.0.tar.gz",
|
|
||||||
"https://github.com/bazelbuild/bazel-skylib/archive/0.8.0.tar.gz",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# buildifier: disable=unnamed-macro
|
# buildifier: disable=unnamed-macro
|
||||||
def rules_cc_toolchains(*args):
|
def rules_cc_toolchains(*args):
|
||||||
cc_configure(*args)
|
cc_configure(*args)
|
||||||
|
|
||||||
def _maybe(repo_rule, name, **kwargs):
|
|
||||||
if not native.existing_rule(name):
|
|
||||||
repo_rule(name = name, **kwargs)
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
# Copyright 2019 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.
|
|
||||||
|
|
||||||
"""Dependencies that are needed for rules_cc tests and tools."""
|
|
||||||
|
|
||||||
load("@bazel_federation//:repositories.bzl", "bazel_skylib", "protobuf", "rules_go", "rules_python")
|
|
||||||
load("@bazel_federation//:third_party_repositories.bzl", "abseil_py", "py_mock", "six", "zlib")
|
|
||||||
|
|
||||||
def rules_cc_internal_deps():
|
|
||||||
"""Fetches all dependencies for rules_cc tests and tools."""
|
|
||||||
bazel_skylib()
|
|
||||||
protobuf()
|
|
||||||
rules_go()
|
|
||||||
rules_python()
|
|
||||||
|
|
||||||
abseil_py()
|
|
||||||
py_mock()
|
|
||||||
six()
|
|
||||||
zlib()
|
|
|
@ -1,30 +0,0 @@
|
||||||
# Copyright 2019 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.
|
|
||||||
|
|
||||||
"""Setup for rules_cc tests and tools."""
|
|
||||||
|
|
||||||
load("@bazel_federation//setup:rules_python.bzl", "rules_python_setup")
|
|
||||||
|
|
||||||
# TODO(fweikert): Add setup.bzl file for skylib to the federation and load it instead of workspace.bzl
|
|
||||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
|
||||||
|
|
||||||
# TODO(fweikert): Also load rules_go's setup.bzl file from the federation once it exists
|
|
||||||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
|
||||||
|
|
||||||
def rules_cc_internal_setup():
|
|
||||||
"""Setup of dependencies of tests and development-only tools used in rules_cc repository."""
|
|
||||||
bazel_skylib_workspace()
|
|
||||||
go_rules_dependencies()
|
|
||||||
go_register_toolchains()
|
|
||||||
rules_python_setup()
|
|
Loading…
Reference in New Issue