Skip to content

Commit

Permalink
bazel: Cleanup workspace/dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax committed Aug 15, 2024
1 parent eb15e67 commit 1f4d1d3
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 69 deletions.
49 changes: 7 additions & 42 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
workspace(name = "aptly")

load("//:deps.bzl", "dependencies")
load(":archive.bzl", "load_archives")
load_archives()

load("//:deps.bzl", "dependencies")
dependencies()

load("//:deps-go.bzl", "aptly_dependencies", "go_dependencies")

go_dependencies()


load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
name = "python_3_11",
# Available versions are listed in @rules_python//python:versions.bzl.
# We recommend using the same version your team is already standardized on.
python_version = "3.11",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")

rules_proto_dependencies()

load("@rules_proto//proto:setup.bzl", "rules_proto_setup")

rules_proto_setup()

load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")

rules_proto_toolchains()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.22.4")
load("//:setup.bzl", "setup")
setup()

gazelle_dependencies(go_repository_default_config = "//:WORKSPACE")
load("//:toolchains.bzl", "toolchains")
toolchains()

# gazelle:repo bazel_gazelle
# gazelle:repository_macro deps-go.bzl%go_dependencies
aptly_dependencies()
go_dependencies()
26 changes: 26 additions & 0 deletions archive.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("//:versions.bzl", "VERSIONS")

def load_github_archives():
for k, v in VERSIONS.items():
if type(v) == type("") or v.get("type") != "github_archive":
continue
kwargs = dict(name = k, **v)
http_archive(
**{
k: (
(v.format(**kwargs) if not k.startswith("patch") else v)
if type(v) == "string"
else [
_v.format(**kwargs) if not k.startswith("patch") else _v
for _v in v
]
)
for k, v in kwargs.items()
if k not in ["repo", "type", "version"]
}
)

def load_archives():
load_github_archives()
38 changes: 11 additions & 27 deletions deps.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
load("//:deps-go.bzl", "aptly_dependencies", "go_dependencies")

def dependencies():
def archives():
http_archive(
name = "io_bazel_rules_go",
integrity = "sha256-M6zErg9wUC20uJPJ/B3Xqb+ZjCPn/yxFF3QdQEmpdvg=",
Expand All @@ -9,41 +12,22 @@ def dependencies():
"https://github.com/bazelbuild/rules_go/releases/download/v0.48.0/rules_go-v0.48.0.zip",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "d76bf7a60fd8b050444090dfa2837a4eaf9829e1165618ee35dceca5cbdf58d5",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.37.0/bazel-gazelle-v0.37.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.37.0/bazel-gazelle-v0.37.0.tar.gz",
],
)
http_archive(
name = "rules_proto",
sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
urls = ["https://github.com/bazelbuild/rules_proto/archive/refs/tags/6.0.2.tar.gz"],
strip_prefix = "rules_proto-6.0.2",
)
http_archive(
name = "rules_pkg",
sha256 = "23005750a27aabfd5975a3d5aeac9542371cbfa24d3ad74e47f80b84547754da",
urls = ["https://github.com/bazelbuild/rules_pkg/archive/refs/tags/1.0.1.tar.gz"],
strip_prefix = "rules_pkg-1.0.1",
)
http_archive(
name = "rules_python",
sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618",
urls = ["https://github.com/bazelbuild/rules_python/archive/refs/tags/0.34.0.tar.gz"],
strip_prefix = "rules_python-0.34.0",
)
http_archive(
name = "com_google_absl",
sha256 = "987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed",
strip_prefix = "abseil-cpp-20230802.1",
urls = ["https://github.com/abseil/abseil-cpp/archive/20230802.1.tar.gz"],
)
http_archive(
name = "com_google_protobuf",
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-26.1",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-26.1.tar.gz"],
)

def dependencies():
archives()
protobuf_deps()
rules_proto_dependencies()
aptly_dependencies()
go_dependencies()
4 changes: 4 additions & 0 deletions setup.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load("@rules_proto//proto:setup.bzl", "rules_proto_setup")

def setup():
rules_proto_setup()
17 changes: 17 additions & 0 deletions toolchains.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

def toolchains():
py_repositories()
python_register_toolchains(
name = "python3_12",
# Available versions are listed in @rules_python//python:versions.bzl.
# We recommend using the same version your team is already standardized on.
python_version = "3.12",
)
rules_proto_toolchains()
go_rules_dependencies()
go_register_toolchains(version = "1.22.4")
gazelle_dependencies(go_repository_default_config = "//:WORKSPACE")
61 changes: 61 additions & 0 deletions versions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

VERSIONS = {
"python": "3.12",
"aspect_bazel_lib": {
"type": "github_archive",
"repo": "aspect-build/bazel-lib",
"version": "2.7.9",
"sha256": "ccb66940aff9dfded4b03b929c83803f386807ef5ea4960404dfa8a7715cb74f",
"urls": ["https://github.com/{repo}/archive/v{version}.tar.gz"],
"strip_prefix": "bazel-lib-{version}",
},
"bazel_gazelle": {
"type": "github_archive",
"repo": "bazelbuild/bazel-gazelle",
"version": "0.37.0",
"sha256": "d76bf7a60fd8b050444090dfa2837a4eaf9829e1165618ee35dceca5cbdf58d5",
"urls": ["https://github.com/{repo}/releases/download/bazel-gazelle-v{version}.tar.gz"],
},
"com_google_protobuf": {
"type": "github_archive",
"repo": "protocolbuffers/protobuf",
"version": "26.1",
"sha256": "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
"urls": ["https://github.com/{repo}/releases/download/v{version}/protobuf-{version}.tar.gz"],
"strip_prefix": "protobuf-{version}",
},
"envoy": {
"type": "github_archive",
"repo": "envoyproxy/envoy",
"version": "fea66c359069991e88bdfa4e0f2883c90cc39aef",
"sha256": "96294f4b491c676b650ddeb07c7986ec7e48b5ae5a75c4adebbb9a58741a2fb1",
"urls": ["https://github.com/{repo}/archive/{version}.tar.gz"],
"strip_prefix": "envoy-{version}",
},
"envoy_toolshed": {
"type": "github_archive",
"repo": "envoyproxy/toolshed",
"version": "0.1.4",
"sha256": "7ddfd251a89518b97c4eb8064a7d37454bbd998bf29e4cd3ad8f44227b5ca7b3",
"urls": ["https://github.com/{repo}/archive/bazel-v{version}.tar.gz"],
"strip_prefix": "toolshed-bazel-v{version}/bazel",
},
"rules_proto": {
"type": "github_archive",
"repo": "bazelbuild/rules_proto",
"version": "6.0.2",
"sha256": "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295",
"urls": ["https://github.com/{repo}/archive/refs/tags/{version}.tar.gz"],
"strip_prefix": "rules_proto-{version}",
},
"rules_python": {
"type": "github_archive",
"repo": "bazelbuild/rules_python",
"version": "0.32.2",
"sha256": "4912ced70dc1a2a8e4b86cec233b192ca053e82bc72d877b98e126156e8f228d",
"urls": ["https://github.com/{repo}/archive/{version}.tar.gz"],
"strip_prefix": "rules_python-{version}",
},


}

0 comments on commit 1f4d1d3

Please sign in to comment.