Skip to content

Commit

Permalink
fiddling with toolchains
Browse files Browse the repository at this point in the history
  • Loading branch information
5h4d0w4rt committed Dec 19, 2020
1 parent 85e2825 commit 24ced20
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 27 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# bazel_prometheus
Bazel prometheus rules
# Prometheus bazel rules
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ load(":deps.bzl", "prometheus_repositories")

prometheus_repositories()

register_toolchains(
"//prometheus/toolchain:all",
)
load("@io_bazel_rules_prometheus//prometheus:prometheus.bzl", "prometheus_register_toolchains")

prometheus_register_toolchains()
2 changes: 1 addition & 1 deletion deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ def prometheus_repositories():
sha256 = "d589a45495cea1aa74bff82335d2145f2d93b8b357c3398739b9139c74dc0cfe",
urls = [PROMETHEUS_DARWIN_URL],
strip_prefix = "prometheus-%s.%s" % (PROMETHEUS_VERSION, PROMETHEUS_DARWIN_ARCH),
build_file = "@//:prometheus.BUILD",
build_file = "@io_bazel_rules_prometheus//:prometheus.BUILD",
)
5 changes: 5 additions & 0 deletions prometheus/prometheus.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ load(
_promtool_config_test = "promtool_config_test",
_promtool_unit_test = "promtool_unit_test",
)
load(
"@io_bazel_rules_prometheus//prometheus/toolchain:toolchain.bzl",
_prometheus_register_toolchains = "prometheus_register_toolchains",
)

promtool_unit_test = _promtool_unit_test
promtool_config_test = _promtool_config_test
prometheus_register_toolchains = _prometheus_register_toolchains
23 changes: 2 additions & 21 deletions prometheus/toolchain/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,10 @@ package(
default_visibility = ["//visibility:public"],
)

load(":toolchain.bzl", "prometheus_toolchain")
load(":toolchain.bzl", "declare_toolchains")

exports_files(["toolchain.bzl"])

toolchain_type(name = "toolchain_type")

prometheus_toolchain(
name = "prometheus_darwin",
prometheus = "@prometheus_darwin//:prometheus",
promtool = "@prometheus_darwin//:promtool",
promtool_executor_template = "//prometheus/internal:promtool.sh.tpl",
)

toolchain(
name = "prometheus_toolchain_darwin",
exec_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
toolchain = ":prometheus_darwin",
toolchain_type = ":toolchain_type",
)
declare_toolchains()
24 changes: 24 additions & 0 deletions prometheus/toolchain/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,27 @@ prometheus_toolchain = rule(
},
provides = [platform_common.ToolchainInfo],
)

def declare_toolchains():
prometheus_toolchain(
name = "prometheus_darwin",
prometheus = "@prometheus_darwin//:prometheus",
promtool = "@prometheus_darwin//:promtool",
promtool_executor_template = "@io_bazel_rules_prometheus//prometheus/internal:promtool.sh.tpl",
)
native.toolchain(
name = "prometheus_toolchain_darwin",
exec_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
target_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
toolchain = "@io_bazel_rules_prometheus//prometheus/toolchain:prometheus_darwin",
toolchain_type = "@io_bazel_rules_prometheus//prometheus/toolchain:toolchain_type",
)

def prometheus_register_toolchains():
native.register_toolchains("@io_bazel_rules_prometheus//prometheus/toolchain:all")

0 comments on commit 24ced20

Please sign in to comment.