Merge pull request #31 from fweikert:merge PiperOrigin-RevId: 262965730 Change-Id: Ibf68e12666dd01930f40adf04c4be18cb52d040f
diff --git a/WORKSPACE b/WORKSPACE index 79a8575..d37b398 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -3,85 +3,24 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "six_archive", - urls = [ - "https://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz", - "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz", - ], - sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", - strip_prefix = "six-1.10.0", - build_file = "@//third_party:six.BUILD", + name = "bazel_federation", + url = "https://github.com/bazelbuild/bazel-federation/archive/a3e140a91ea9ea25b01ad0cc6fbfcaf74f65498f.zip", + sha256 = "026149d1273a87c634d2270004865fd7474420f88d5bd6ea8d8cd71f4b0f0542", + strip_prefix = "bazel-federation-a3e140a91ea9ea25b01ad0cc6fbfcaf74f65498f", + type = "zip", ) -bind( - name = "six", - actual = "@six_archive//:six", -) +load("@bazel_federation//:repositories.bzl", "rules_cc_deps") +rules_cc_deps() -http_archive( - name = "com_google_protobuf", - sha256 = "3e933375ecc58d01e52705479b82f155aea2d02cc55d833f8773213e74f88363", - strip_prefix = "protobuf-3.7.0", - urls = [ - "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/protobuf-all-3.7.0.tar.gz", - "https://github.com/protocolbuffers/protobuf/releases/download/v3.7.0/protobuf-all-3.7.0.tar.gz", - ], -) +load("@bazel_federation//setup:rules_cc.bzl", "rules_cc_setup") +rules_cc_setup() -http_archive( - name = "io_abseil_py", - sha256 = "74a2203a9b4681851f4f1dfc17f2832e0a16bae0369b288b18b431cea63f0ee9", - strip_prefix = "abseil-py-pypi-v0.6.1", - urls = [ - "https://mirror.bazel.build/github.com/abseil/abseil-py/archive/pypi-v0.6.1.zip", - "https://github.com/abseil/abseil-py/archive/pypi-v0.6.1.zip", - ], -) +# +# Dependencies for development of rules_cc itself. +# +load("//:internal_deps.bzl", "rules_cc_internal_deps") +rules_cc_internal_deps() -http_archive( - name = "py_mock", - sha256 = "b839dd2d9c117c701430c149956918a423a9863b48b09c90e30a6013e7d2f44f", - urls = [ - "https://mirror.bazel.build/pypi.python.org/packages/source/m/mock/mock-1.0.1.tar.gz", - "https://pypi.python.org/packages/source/m/mock/mock-1.0.1.tar.gz", - ], - strip_prefix = "mock-1.0.1", - patch_cmds = [ - "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""", - ], -) - -# TODO(https://github.com/protocolbuffers/protobuf/issues/5918: Remove when protobuf releases protobuf_deps.bzl) -http_archive( - name = "net_zlib", - build_file = "@com_google_protobuf//examples:third_party/zlib.BUILD", - sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", - strip_prefix = "zlib-1.2.11", - urls = ["https://zlib.net/zlib-1.2.11.tar.gz"], -) - -bind( - name = "zlib", - actual = "@net_zlib//:zlib" -) - -# Go rules and proto support -http_archive( - name = "io_bazel_rules_go", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz", - "https://github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz", - ], - sha256 = "f04d2373bcaf8aa09bccb08a98a57e721306c8f6043a2a0ee610fd6853dcde3d", -) - -load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") -go_rules_dependencies() -go_register_toolchains() - -load("//cc:repositories.bzl", "rules_cc_dependencies") -rules_cc_dependencies() +load("//:internal_setup.bzl", "rules_cc_internal_setup") +rules_cc_internal_setup()
diff --git a/cc/repositories.bzl b/cc/repositories.bzl index c3e1f95..bb41c86 100644 --- a/cc/repositories.bzl +++ b/cc/repositories.bzl
@@ -1,5 +1,13 @@ """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") def rules_cc_dependencies():
diff --git a/internal_deps.bzl b/internal_deps.bzl new file mode 100644 index 0000000..ea51aeb --- /dev/null +++ b/internal_deps.bzl
@@ -0,0 +1,29 @@ +# 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") +load("@bazel_federation//:third_party_repositories.bzl", "abseil_py", "py_mock", "six", "zlib") + +def rules_cc_internal_deps(): + """Fetches all required dependencies for rules_cc tests and tools.""" + bazel_skylib() + protobuf() + rules_go() + + abseil_py() + py_mock() + six() + zlib()
diff --git a/internal_setup.bzl b/internal_setup.bzl new file mode 100644 index 0000000..99e7d55 --- /dev/null +++ b/internal_setup.bzl
@@ -0,0 +1,26 @@ +# 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.""" + +# 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(): + bazel_skylib_workspace() + go_rules_dependencies() + go_register_toolchains()