Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
5h4d0w4rt committed Oct 31, 2021
1 parent 5248848 commit 85883cd
Show file tree
Hide file tree
Showing 11 changed files with 464 additions and 484 deletions.
25 changes: 18 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
workspace(name = "io_bazel_rules_prometheus")

# all dependencies are called from there
load("@//:deps.bzl", "rules_prometheus_dependencies", "rules_prometheus_repositories")
load("@//:deps.bzl", "rules_prometheus_repositories", "rules_prometheus_toolchains")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# this downloads dependencies required for prometheus to work
rules_prometheus_dependencies()
http_archive(
name = "io_bazel_stardoc",
sha256 = "c9794dcc8026a30ff67cf7cf91ebe245ca294b20b071845d12c192afe243ad72",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz",
"https://github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz",
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
# this downloads dependencies required for prometheus to work
rules_prometheus_repositories()

bazel_skylib_workspace()
# this downloads prometheus blobs and registers toolchain
rules_prometheus_toolchains()

load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()

# this downloads prometheus blobs and registers toolchain
rules_prometheus_repositories()
# https://docs.bazel.build/versions/main/workspace-log.html skylib import fails somewhere, should debug
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()
4 changes: 2 additions & 2 deletions deps.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load(
"@//prometheus:defs.bzl",
_prometheus_dependencies = "prometheus_dependencies",
_prometheus_repositories = "prometheus_repositories",
_prometheus_toolchains = "prometheus_toolchains",
)

rules_prometheus_repositories = _prometheus_repositories
rules_prometheus_dependencies = _prometheus_dependencies
rules_prometheus_toolchains = _prometheus_toolchains
2 changes: 1 addition & 1 deletion examples/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//prometheus:defs.bzl", "promtool_config_test", "promtool_rules_test", "promtool_unit_test")
load("@//prometheus:defs.bzl", "promtool_config_test", "promtool_rules_test", "promtool_unit_test")

promtool_unit_test(
name = "unit_test_rules_yml",
Expand Down
12 changes: 7 additions & 5 deletions prometheus/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ exports_files([
bzl_library(
name = "api",
srcs = [
"//prometheus/internal:prom",
"//prometheus/internal:promtool",
"//prometheus/internal:providers",
"//prometheus/internal:repositories",
"//prometheus/internal:toolchain",
"@//prometheus/internal:defaults",
"@//prometheus/internal:platforms",
"@//prometheus/internal:prom",
"@//prometheus/internal:promtool",
"@//prometheus/internal:providers",
"@//prometheus/internal:repositories",
"@//prometheus/internal:toolchain",
],
)

Expand Down
11 changes: 7 additions & 4 deletions prometheus/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
load(
"@//prometheus/internal:repositories.bzl",
_prometheus_repositories = "prometheus_repositories",
)
load(
"@//prometheus/internal:promtool.bzl",
_promtool = "promtool",
Expand All @@ -10,12 +14,11 @@ load(
_prometheus = "prometheus",
)
load(
"@//prometheus/internal:repositories.bzl",
_prometheus_dependencies = "prometheus_dependencies",
_prometheus_repositories = "prometheus_repositories",
"@//prometheus/internal:toolchain.bzl",
_prometheus_toolchains = "prometheus_toolchains",
)

prometheus_dependencies = _prometheus_dependencies
prometheus_toolchains = _prometheus_toolchains
prometheus_repositories = _prometheus_repositories
promtool_unit_test = _promtool_unit_test
promtool_config_test = _promtool_config_test
Expand Down
28 changes: 20 additions & 8 deletions prometheus/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ package(
)

exports_files(
[
"repositories.bzl",
] + glob([
glob([
"*.bat",
"*.sh",
"*.sh.tpl",
Expand All @@ -23,6 +21,9 @@ exports_files([
"promtool.bzl",
"prom.bzl",
"providers.bzl",
"platforms.bzl",
"toolchain.bzl",
"repositories.bzl",
"toolchain.bzl",
])

Expand All @@ -43,16 +44,27 @@ bzl_library(
srcs = ["providers.bzl"],
)

bzl_library(
name = "defaults",
srcs = ["defaults.bzl"],
deps = [
":providers",
],
)

bzl_library(
name = "platforms",
srcs = ["platforms.bzl"],
deps = [
":defaults",
],
)

bzl_library(
name = "toolchain",
srcs = ["toolchain.bzl"],
deps = [
":platforms",
":defaults",
":providers",
],
)
Expand All @@ -61,11 +73,11 @@ bzl_library(
name = "repositories",
srcs = ["repositories.bzl"],
deps = [
":platforms",
":toolchain",
":defaults",
":providers",
],
)

declare_platforms(name = "constraints")
declare_platforms()

declare_toolchains(name = "toolchains")
declare_toolchains()
Loading

0 comments on commit 85883cd

Please sign in to comment.