Skip to content

Commit

Permalink
Replace rules_meta with with_cfg (#2006)
Browse files Browse the repository at this point in the history
Summary: rules_meta relies on the name parameter for rules which
is removed in bazel7. So this switches us over to it's replacement
which is with_cfg.bzl
For more info see fmeum/rules_meta#1

Relevant Issues: N/A

Type of change: /kind infra

Test Plan: Multiarch images still build.

Signed-off-by: Vihang Mehta <vihang@gimletlabs.ai>
GitOrigin-RevId: 742d9f8479883ec9ca224f4565dd3571d993e530
  • Loading branch information
vihangm authored and zasgar committed Jan 4, 2024
1 parent d9b4421 commit bd84fce
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bazel_dep(name = "rules_foreign_cc", version = "0.10.1")
bazel_dep(name = "rules_python", version = "0.27.1")
bazel_dep(name = "rules_oci", version = "1.4.3")
bazel_dep(name = "rules_python_gazelle_plugin", version = "0.27.1")
bazel_dep(name = "with_cfg.bzl", version = "0.2.1")
bazel_dep(name = "glog", version = "0.6.0", repo_name = "com_github_google_glog")
bazel_dep(name = "abseil-cpp", version = "20230802.0", repo_name = "com_google_absl")
bazel_dep(name = "googletest", version = "1.14.0", repo_name = "com_google_googletest")
Expand Down
4 changes: 4 additions & 0 deletions bazel/cc_toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ load("//bazel/cc_toolchains:gcc.bzl", "gcc_x86_64_gnu")
load("//bazel/cc_toolchains:llvm_libs.bzl", "llvm_variant_settings")
load("//bazel/cc_toolchains:settings.bzl", "settings")

package(
default_visibility = ["//visibility:public"],
)

filegroup(
name = "empty",
)
Expand Down
2 changes: 0 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ def _gml_cc_toolchain_deps():

def _gml_deps():
_bazel_repo("bazel_skylib")
_bazel_repo("com_github_fmeum_rules_meta")

_bazel_repo(
"com_github_benchsci_rules_nodejs_gazelle",
patches = [
Expand Down
7 changes: 0 additions & 7 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ REPOSITORY_LOCATIONS = dict(
"https://github.com/benchsci/rules_nodejs_gazelle/archive/refs/tags/v0.4.1.tar.gz",
],
),
com_github_fmeum_rules_meta = dict(
sha256 = "ed3ed909e6e3f34a11d7c2adcc461535975a875fe434719540a4e6f63434a866",
strip_prefix = "rules_meta-0.0.4",
urls = [
"https://github.com/fmeum/rules_meta/archive/refs/tags/v0.0.4.tar.gz",
],
),
com_github_gflags_gflags = dict(
sha256 = "9e1a38e2dcbb20bb10891b5a171de2e5da70e0a50fff34dd4b0c2c6d75043909",
strip_prefix = "gflags-524b83d0264cb9f1b2d134c564ef1aa23f207a41",
Expand Down
30 changes: 15 additions & 15 deletions bazel/toolchain_transitions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
#
# SPDX-License-Identifier: Proprietary

load("@com_github_fmeum_rules_meta//meta:defs.bzl", "meta")
load("@rules_oci//oci:defs.bzl", "oci_image")
load("@with_cfg.bzl", "with_cfg")

oci_image_x86_64 = meta.wrap_with_transition(
oci_image,
{
"//command_line_option:platforms": meta.replace_with("@//bazel/cc_toolchains:linux-x86_64"),
"@//bazel/cc_toolchains:libc_version": meta.replace_with("glibc2_36"),
},
)
oci_image_x86_64, _oci_image_x86_64_internal = with_cfg(oci_image).set(
"platforms",
[Label("@//bazel/cc_toolchains:linux-x86_64")],
).set(
Label("@//bazel/cc_toolchains:libc_version"),
"glibc2_36",
).build()

oci_image_arm64 = meta.wrap_with_transition(
oci_image,
{
"//command_line_option:platforms": meta.replace_with("@//bazel/cc_toolchains:linux-aarch64"),
"@//bazel/cc_toolchains:libc_version": meta.replace_with("glibc2_36"),
},
)
oci_image_arm64, _oci_image_arm64_internal = with_cfg(oci_image).set(
"platforms",
[Label("@//bazel/cc_toolchains:linux-aarch64")],
).set(
Label("@//bazel/cc_toolchains:libc_version"),
"glibc2_36",
).build()

0 comments on commit bd84fce

Please sign in to comment.