Make external usage easier by providing a sapi_deps() workspace rule

If using Sandboxed API from an external Bazel WORKSPACE, dependencies can be
imported by declaring the repository and calling `sapi_deps()`:

```python
git_repository(
    name = "com_google_sandboxed_api",
    commit = "master",
    remote = "https://github.com/google/sandboxed-api.git",
)

load(
    "@com_google_sandboxed_api//sandboxed_api/bazel:sapi_deps.bzl",
    "sapi_deps",
)

sapi_deps()
```

PiperOrigin-RevId: 255373664
Change-Id: I4c41ffc75e1ca95eb126702cb2d5cedb255191d5
pull/30/head
Christian Blichmann 2019-06-27 04:27:37 -07:00 committed by Copybara-Service
parent 301a265c95
commit 0d16c136ae
2 changed files with 125 additions and 105 deletions

111
WORKSPACE
View File

@ -15,54 +15,16 @@
workspace(name = "com_google_sandboxed_api")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//sandboxed_api/bazel:repositories.bzl", "autotools_repository")
load("//sandboxed_api/bazel:sapi_deps.bzl", "sapi_deps")
# Bazel Skylib, needed by newer Protobuf builds
http_archive(
name = "bazel_skylib",
sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/0.8.0/bazel-skylib.0.8.0.tar.gz", # 2019-03-20
)
# Load common dependencies, then Protobuf's
sapi_deps()
# Abseil
http_archive(
name = "com_google_absl",
sha256 = "57cadb5f4e35e479de395490994db5cd91a23b3a4d6fba85ffbe86590d70f606", # 2019-05-07
strip_prefix = "abseil-cpp-aa468ad75539619b47979911297efbb629c52e44",
urls = ["https://github.com/abseil/abseil-cpp/archive/aa468ad75539619b47979911297efbb629c52e44.zip"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
# Abseil-py
http_archive(
name = "com_google_absl_py",
strip_prefix = "abseil-py-master",
urls = ["https://github.com/abseil/abseil-py/archive/master.zip"],
)
protobuf_deps()
# Abseil-py deps
http_archive(
name = "six_archive",
build_file = "//sandboxed_api:bazel/external/six.BUILD",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
strip_prefix = "six-1.10.0",
urls = [
"http://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",
],
)
http_archive(
# NOTE: The name here is used in _enum_module.py to find the sys.path entry.
name = "enum34_archive",
build_file = "//sandboxed_api:bazel/external/enum34.BUILD",
sha256 = "8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1",
urls = [
"https://mirror.bazel.build/pypi.python.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz",
"https://pypi.python.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz",
],
)
# zlib
# zlib, only needed for examples
http_archive(
name = "net_zlib",
build_file = "//sandboxed_api:bazel/external/zlib.BUILD",
@ -79,14 +41,6 @@ http_archive(
urls = ["https://www.zlib.net/zlib-1.2.11.tar.gz"],
)
# gflags
http_archive(
name = "com_github_gflags_gflags",
sha256 = "53b16091efa386ab11e33f018eef0ed489e0ab63554455293cbb0cc2a5f50e98",
strip_prefix = "gflags-28f50e0fed19872e0fd50dd23ce2ee8cd759338e",
urls = ["https://github.com/gflags/gflags/archive/28f50e0fed19872e0fd50dd23ce2ee8cd759338e.zip"], # 2019-01-25
)
# GoogleTest/GoogleMock
http_archive(
name = "com_google_googletest",
@ -101,56 +55,3 @@ http_archive(
strip_prefix = "benchmark-master",
urls = ["https://github.com/google/benchmark/archive/master.zip"],
)
# Google logging
http_archive(
name = "com_google_glog",
sha256 = "74010e549e3555a11d3eb22b80f0040fa4f013a4b254b2d5ede12afcc92e690b",
strip_prefix = "glog-41f4bf9cbc3e8995d628b459f6a239df43c2b84a",
urls = ["https://github.com/google/glog/archive/41f4bf9cbc3e8995d628b459f6a239df43c2b84a.zip"], # 2019-02-02
)
# Protobuf
http_archive(
name = "com_google_protobuf",
sha256 = "1e622ce4b84b88b6d2cdf1db38d1a634fe2392d74f0b7b74ff98f3a51838ee53",
strip_prefix = "protobuf-3.8.0",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.8.0.zip"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
# libcap
http_archive(
name = "org_kernel_libcap",
build_file = "//sandboxed_api:bazel/external/libcap.BUILD",
sha256 = "ef83108f77314e50bae926ae473f9b130b15240d17cbae05089e19c36a8676d6",
strip_prefix = "libcap-2.13",
urls = ["https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.13.tar.gz"],
)
# libffi
autotools_repository(
name = "org_sourceware_libffi",
build_file = "//sandboxed_api:bazel/external/libffi.BUILD",
sha256 = "403d67aabf1c05157855ea2b1d9950263fb6316536c8c333f5b9ab1eb2f20ecf",
strip_prefix = "libffi-3.3-rc0",
urls = ["https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz"],
)
# libunwind
autotools_repository(
name = "org_gnu_libunwind",
build_file = "//sandboxed_api:bazel/external/libunwind.BUILD",
configure_args = [
"--disable-documentation",
"--disable-minidebuginfo",
"--disable-shared",
"--enable-ptrace",
],
sha256 = "3f3ecb90e28cbe53fba7a4a27ccce7aad188d3210bb1964a923a731a27a75acb",
strip_prefix = "libunwind-1.2.1",
urls = ["https://github.com/libunwind/libunwind/releases/download/v1.2.1/libunwind-1.2.1.tar.gz"], # v1.2.1
)

View File

@ -0,0 +1,119 @@
# Copyright 2019 Google LLC. 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.
"""Loads dependencies needed to compile Sandboxed API for 3rd-party consumers."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//sandboxed_api/bazel:repositories.bzl", "autotools_repository")
def sapi_deps():
"""Loads common dependencies needed to compile Sandboxed API."""
# Bazel Skylib, needed by newer Protobuf builds
if "bazel_skylib" not in native.existing_rules():
http_archive(
name = "bazel_skylib",
sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/0.8.0/bazel-skylib.0.8.0.tar.gz", # 2019-03-20
)
# Abseil
if "com_google_absl" not in native.existing_rules():
http_archive(
name = "com_google_absl",
sha256 = "57cadb5f4e35e479de395490994db5cd91a23b3a4d6fba85ffbe86590d70f606", # 2019-05-07
strip_prefix = "abseil-cpp-aa468ad75539619b47979911297efbb629c52e44",
urls = ["https://github.com/abseil/abseil-cpp/archive/aa468ad75539619b47979911297efbb629c52e44.zip"],
)
# Abseil-py
if "com_google_absl_py" not in native.existing_rules():
http_archive(
name = "com_google_absl_py",
strip_prefix = "abseil-py-master",
urls = ["https://github.com/abseil/abseil-py/archive/master.zip"],
)
# Abseil-py dependency for Python 2/3 compatiblity
if "six_archive" not in native.existing_rules():
http_archive(
name = "six_archive",
build_file = "//sandboxed_api:bazel/external/six.BUILD",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
strip_prefix = "six-1.10.0",
urls = [
"http://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",
],
)
# gflags
# TODO(cblichmann): Use Abseil flags once compatible with logging
if "com_github_gflags_gflags" not in native.existing_rules():
http_archive(
name = "com_github_gflags_gflags",
sha256 = "53b16091efa386ab11e33f018eef0ed489e0ab63554455293cbb0cc2a5f50e98",
strip_prefix = "gflags-28f50e0fed19872e0fd50dd23ce2ee8cd759338e",
urls = ["https://github.com/gflags/gflags/archive/28f50e0fed19872e0fd50dd23ce2ee8cd759338e.zip"], # 2019-01-25
)
# Google logging
http_archive(
name = "com_google_glog",
sha256 = "74010e549e3555a11d3eb22b80f0040fa4f013a4b254b2d5ede12afcc92e690b",
strip_prefix = "glog-41f4bf9cbc3e8995d628b459f6a239df43c2b84a",
urls = ["https://github.com/google/glog/archive/41f4bf9cbc3e8995d628b459f6a239df43c2b84a.zip"], # 2019-02-02
)
# Protobuf
if "com_google_protobuf" not in native.existing_rules():
http_archive(
name = "com_google_protobuf",
sha256 = "1e622ce4b84b88b6d2cdf1db38d1a634fe2392d74f0b7b74ff98f3a51838ee53",
strip_prefix = "protobuf-3.8.0",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.8.0.zip"],
)
# libcap
http_archive(
name = "org_kernel_libcap",
build_file = "//sandboxed_api:bazel/external/libcap.BUILD",
sha256 = "ef83108f77314e50bae926ae473f9b130b15240d17cbae05089e19c36a8676d6",
strip_prefix = "libcap-2.13",
urls = ["https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.13.tar.gz"],
)
# libffi
autotools_repository(
name = "org_sourceware_libffi",
build_file = "//sandboxed_api:bazel/external/libffi.BUILD",
sha256 = "403d67aabf1c05157855ea2b1d9950263fb6316536c8c333f5b9ab1eb2f20ecf",
strip_prefix = "libffi-3.3-rc0",
urls = ["https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz"],
)
# libunwind
autotools_repository(
name = "org_gnu_libunwind",
build_file = "//sandboxed_api:bazel/external/libunwind.BUILD",
configure_args = [
"--disable-documentation",
"--disable-minidebuginfo",
"--disable-shared",
"--enable-ptrace",
],
sha256 = "3f3ecb90e28cbe53fba7a4a27ccce7aad188d3210bb1964a923a731a27a75acb",
strip_prefix = "libunwind-1.2.1",
urls = ["https://github.com/libunwind/libunwind/releases/download/v1.2.1/libunwind-1.2.1.tar.gz"], # v1.2.1
)