Skip to content

Commit d42bc14

Browse files
authored
Upgrade rules_scala and rules_meta (#2293)
Summary: Upgrade rules scala and rules_meta Relevant Issues: #2282 Type of change: /kind cleanup Test Plan: Build succeeds --------- Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 76d03e7 commit d42bc14

File tree

8 files changed

+115
-74
lines changed

8 files changed

+115
-74
lines changed

.bazelrc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ run --remote_download_outputs=all
2222
coverage --build_runfile_links
2323
coverage --nocache_test_results
2424

25-
# Needed by rules_meta.
26-
# Follow https://github.com/fmeum/rules_meta/issues/1#issuecomment-1255828109
27-
# for updates.
28-
common --incompatible_remove_rule_name_parameter=false
29-
3025
# Get version information into the build.
3126
build --workspace_status_command=bazel/get_workspace_status.sh
3227

WORKSPACE

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ pl_register_cc_toolchains()
1919
# Install Pixie Labs Dependencies.
2020
pl_deps()
2121

22+
load("@bazel_features//:deps.bzl", "bazel_features_deps")
23+
24+
bazel_features_deps()
25+
26+
load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo")
27+
28+
compatibility_proxy_repo()
29+
2230
# Order is important. Try to go from most basic/primitive to higher level packages.
2331
# - go_rules_dependencies
2432
# - protobuf_deps
@@ -45,6 +53,10 @@ go_register_toolchains()
4553
# gazelle:repository_macro go_deps.bzl%pl_go_dependencies
4654
pl_go_dependencies()
4755

56+
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
57+
58+
rules_java_dependencies()
59+
4860
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
4961

5062
protobuf_deps()
@@ -53,17 +65,34 @@ load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
5365

5466
grpc_deps()
5567

56-
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
68+
load("@io_bazel_rules_scala//scala:deps.bzl", "rules_scala_dependencies")
5769

58-
scala_version = "2.13.6"
70+
rules_scala_dependencies()
5971

60-
scala_config(scala_version = scala_version)
72+
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
6173

62-
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
74+
scala_version = "2.13.16"
6375

64-
scala_repositories()
76+
scala_config(scala_version = scala_version)
6577

66-
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
78+
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains", "scala_toolchains")
79+
80+
scala_toolchains(
81+
fetch_sources = True,
82+
twitter_scrooge = {
83+
"libthrift": "@thrift_deps//:org_apache_thrift_libthrift",
84+
# Use scrooge_core_with_finagle to include finagle on the compile classpath
85+
# for generated thrift service code. Must use @px// prefix to reference
86+
# the main workspace from within the generated @rules_scala_toolchains repo.
87+
"scrooge_core": "@px//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:scrooge_core_with_finagle",
88+
"scrooge_generator": "@thrift_deps//:com_twitter_scrooge_generator_2_13",
89+
"util_core": "@thrift_deps//:com_twitter_util_core_2_13",
90+
"util_logging": "@thrift_deps//:com_twitter_util_logging_2_13",
91+
"javax_annotation_api": "@thrift_deps//:javax_annotation_javax_annotation_api",
92+
"mustache": "@thrift_deps//:com_github_spullara_mustache_java_compiler",
93+
"scopt": "@thrift_deps//:com_github_scopt_scopt_2_13",
94+
},
95+
)
6796

6897
scala_register_toolchains()
6998

@@ -183,26 +212,6 @@ load("@thrift_deps//:defs.bzl", thrift_pinned_maven_install = "pinned_maven_inst
183212

184213
thrift_pinned_maven_install()
185214

186-
# twitter_scrooge will use incompatible versions of @scrooge_jars and @thrift_jars.
187-
# These bind statements ensure that the correct versions of finagle libthrift, scrooge core
188-
# and scrooge generator are used to ensure successful compilation.
189-
# See https://github.com/bazelbuild/rules_scala/issues/592 and
190-
# https://github.com/bazelbuild/rules_scala/pull/847 for more details.
191-
bind(
192-
name = "io_bazel_rules_scala/dependency/thrift/scrooge_core",
193-
actual = "//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:scrooge_jars",
194-
)
195-
196-
bind(
197-
name = "io_bazel_rules_scala/dependency/thrift/scrooge_generator",
198-
actual = "//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:scrooge_jars",
199-
)
200-
201-
bind(
202-
name = "io_bazel_rules_scala/dependency/thrift/libthrift",
203-
actual = "//src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux:thrift_jars",
204-
)
205-
206215
# gazelle:repo bazel_gazelle
207216
# Gazelle depes need to be loaded last to make sure they don't override our dependencies.
208217
# The first one wins when it comes to package declaration.

bazel/cc_toolchains/sysroots/images.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def _sysroot_variant_image_factory(variant):
6565
return _image_from_sysroot_info(ctx, sysroot_toolchain.sysroot)
6666

6767
return rule(
68-
name = "sysroot_{variant}_image".format(variant = variant),
6968
implementation = _impl,
7069
attrs = dicts.add(_container.image.attrs, {
7170
"default_image": attr.label(mandatory = True, doc = "Default container_image to use if no sysroot toolchain is found"),

bazel/repositories.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,11 @@ def _pl_deps():
257257
_bazel_repo("rules_python")
258258
_bazel_repo("rules_pkg")
259259
_bazel_repo("com_github_bazelbuild_buildtools")
260-
_bazel_repo("com_github_fmeum_rules_meta")
261260
_bazel_repo("com_google_protobuf_javascript", patches = ["//bazel/external:protobuf_javascript.patch"], patch_args = ["-p1"])
262261
# TODO(ddelnano): Remove patch once grpc-web upgrades to protobuf v30+.
263262
_bazel_repo("com_github_grpc_grpcweb", patches = ["//bazel/external:grpc-web_protobuf_v30_support.patch"], patch_args = ["-p1"])
263+
_bazel_repo("bazel_features")
264+
_bazel_repo("with_cfg.bzl")
264265

265266
_com_llvm_lib()
266267
_cc_deps()

bazel/repository_locations.bzl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
# SPDX-License-Identifier: Apache-2.0
1616

1717
REPOSITORY_LOCATIONS = dict(
18+
bazel_features = dict(
19+
sha256 = "07271d0f6b12633777b69020c4cb1eb67b1939c0cf84bb3944dc85cc250c0c01",
20+
strip_prefix = "bazel_features-1.38.0",
21+
urls = ["https://github.com/bazel-contrib/bazel_features/releases/download/v1.38.0/bazel_features-v1.38.0.tar.gz"],
22+
),
1823
bazel_gazelle = dict(
1924
sha256 = "d76bf7a60fd8b050444090dfa2837a4eaf9829e1165618ee35dceca5cbdf58d5",
2025
urls = [
@@ -81,13 +86,6 @@ REPOSITORY_LOCATIONS = dict(
8186
strip_prefix = "tdigest-85e0f70092460e60236821db4c25143768d3da12",
8287
urls = ["https://github.com/pixie-io/tdigest/archive/85e0f70092460e60236821db4c25143768d3da12.tar.gz"],
8388
),
84-
com_github_fmeum_rules_meta = dict(
85-
sha256 = "ed3ed909e6e3f34a11d7c2adcc461535975a875fe434719540a4e6f63434a866",
86-
strip_prefix = "rules_meta-0.0.4",
87-
urls = [
88-
"https://github.com/fmeum/rules_meta/archive/refs/tags/v0.0.4.tar.gz",
89-
],
90-
),
9189
com_github_gflags_gflags = dict(
9290
sha256 = "9e1a38e2dcbb20bb10891b5a171de2e5da70e0a50fff34dd4b0c2c6d75043909",
9391
strip_prefix = "gflags-524b83d0264cb9f1b2d134c564ef1aa23f207a41",
@@ -439,11 +437,11 @@ REPOSITORY_LOCATIONS = dict(
439437
],
440438
),
441439
io_bazel_rules_scala = dict(
442-
sha256 = "6e9191363357d30b144e7306fec74deea2c7f1de63f3ed32028838116c239e8a",
440+
sha256 = "6a900a39bf643c5c9308c8200f9a61e27588dc54a67aa08fcfc798f25add4f7b",
443441
urls = [
444-
"https://github.com/bazelbuild/rules_scala/archive/4ba3780fcba8d26980daff4639abc6f18517308b.tar.gz",
442+
"https://github.com/bazelbuild/rules_scala/releases/download/v7.1.0/rules_scala-v7.1.0.tar.gz",
445443
],
446-
strip_prefix = "rules_scala-4ba3780fcba8d26980daff4639abc6f18517308b",
444+
strip_prefix = "rules_scala-7.1.0",
447445
),
448446
org_tensorflow = dict(
449447
sha256 = "a640d1f97be316a09301dfc9347e3d929ad4d9a2336e3ca23c32c93b0ff7e5d0",
@@ -457,9 +455,9 @@ REPOSITORY_LOCATIONS = dict(
457455
manual_license_name = "libc/musl",
458456
),
459457
rules_cc = dict(
460-
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
461-
strip_prefix = "rules_cc-0.0.17",
462-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
458+
sha256 = "a2fdfde2ab9b2176bd6a33afca14458039023edb1dd2e73e6823810809df4027",
459+
strip_prefix = "rules_cc-0.2.14",
460+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.2.14/rules_cc-0.2.14.tar.gz"],
463461
),
464462
rules_foreign_cc = dict(
465463
sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc",
@@ -511,6 +509,12 @@ REPOSITORY_LOCATIONS = dict(
511509
),
512510
)
513511

512+
REPOSITORY_LOCATIONS["with_cfg.bzl"] = dict(
513+
sha256 = "c7af6227d24499438fa0bb96fe4034e163d8c807b06f7c0645f3654448268b84",
514+
strip_prefix = "with_cfg.bzl-0.11.0",
515+
urls = ["https://github.com/fmeum/with_cfg.bzl/releases/download/v0.11.0/with_cfg.bzl-v0.11.0.tar.gz"],
516+
)
517+
514518
# To modify one of the forked repos below:
515519
# 1. Make the changes to the repo and push the changes to the `pixie` on github.
516520
# 2. Update the commit below to point to the commit hash of the new `pixie` branch.

bazel/thrift.bzl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,29 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616

17-
load("@io_bazel_rules_scala//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge")
1817
load("@rules_jvm_external//:defs.bzl", "maven_install")
1918

2019
def thrift_deps(scala_version):
21-
twitter_scrooge()
20+
# twitter_scrooge is now set up via scala_toolchains(twitter_scrooge = {...}) in WORKSPACE
2221

23-
finagle_version = "22.7.0"
22+
finagle_version = "24.2.0"
2423
scala_minor_version = ".".join(scala_version.split(".")[:2])
2524

2625
maven_install(
2726
name = "thrift_deps",
2827
artifacts = [
28+
# Finagle dependencies (needed for generated service code)
2929
"com.twitter:finagle-thriftmux_%s:%s" % (scala_minor_version, finagle_version),
30+
"com.twitter:finagle-thrift_%s:%s" % (scala_minor_version, finagle_version),
3031
"com.twitter:finagle-mux_%s:%s" % (scala_minor_version, finagle_version),
3132
"com.twitter:finagle-core_%s:%s" % (scala_minor_version, finagle_version),
33+
"com.twitter:finagle-http_%s:%s" % (scala_minor_version, finagle_version),
34+
# Scrooge dependencies (needed for code generation toolchain)
3235
"com.twitter:scrooge-core_%s:%s" % (scala_minor_version, finagle_version),
3336
"com.twitter:scrooge-generator_%s:%s" % (scala_minor_version, finagle_version),
34-
"com.twitter:finagle-http_%s:%s" % (scala_minor_version, finagle_version),
35-
"org.apache.thrift:libthrift:0.10.0",
37+
"com.twitter:util-core_%s:%s" % (scala_minor_version, finagle_version),
38+
"com.twitter:util-logging_%s:%s" % (scala_minor_version, finagle_version),
39+
# Logging
3640
"org.slf4j:slf4j-api:1.7.36",
3741
"ch.qos.logback:logback-core:1.2.10",
3842
"ch.qos.logback:logback-classic:1.2.10",

bazel/toolchain_transitions.bzl

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,15 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616

17-
load("@com_github_fmeum_rules_meta//meta:defs.bzl", "meta")
17+
load("@with_cfg.bzl", "with_cfg")
1818
load("//bazel/test_runners/qemu_with_kernel:runner.bzl", "qemu_with_kernel_interactive_runner")
1919

20-
java_graal_binary = meta.wrap_with_transition(
21-
native.java_binary,
22-
{
23-
"java_runtime_version": meta.replace_with("remotejdk_openjdk_graal_17"),
24-
},
25-
executable = True,
26-
)
20+
java_graal_binary, _java_graal_binary_internal = with_cfg(native.java_binary).set(
21+
"java_runtime_version", "remotejdk_openjdk_graal_17").build()
2722

28-
cc_clang_binary = meta.wrap_with_transition(
29-
native.cc_binary,
30-
{
31-
"@//bazel/cc_toolchains:compiler": meta.replace_with("clang"),
32-
"@//bazel/cc_toolchains:libc_version": meta.replace_with("glibc2_36"),
33-
},
34-
executable = True,
35-
)
23+
cc_clang_binary, _cc_clang_binary_internal = with_cfg(native.cc_binary).set(
24+
Label("@//bazel/cc_toolchains:compiler"), "clang").set(
25+
Label("@//bazel/cc_toolchains:libc_version"), "glibc2_36").build()
3626

37-
qemu_interactive_runner = meta.wrap_with_transition(
38-
qemu_with_kernel_interactive_runner,
39-
{
40-
"@//bazel/cc_toolchains:libc_version": meta.replace_with("glibc2_36"),
41-
},
42-
executable = True,
43-
)
27+
qemu_interactive_runner, _qemu_interactive_runner_internal = with_cfg(qemu_with_kernel_interactive_runner).set(
28+
Label("@//bazel/cc_toolchains:libc_version"), "glibc2_36").build()

src/stirling/source_connectors/socket_tracer/testing/containers/thriftmux/BUILD.bazel

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ thrift_library(
6767
srcs = glob(["**/*.thrift"]),
6868
)
6969

70+
# Scrooge core with finagle dependencies bundled.
71+
# This is used as the scrooge_core for the toolchain, so that the generated
72+
# service code has access to finagle classes at compile time.
73+
scala_library(
74+
name = "scrooge_core_with_finagle",
75+
visibility = ["//visibility:public"],
76+
exports = [
77+
"@thrift_deps//:com_twitter_finagle_core_2_13",
78+
"@thrift_deps//:com_twitter_finagle_thrift_2_13",
79+
"@thrift_deps//:com_twitter_scrooge_core_2_13",
80+
],
81+
)
82+
7083
scala_library(
7184
name = "scrooge_jars",
7285
visibility = ["//visibility:public"],
@@ -81,6 +94,31 @@ scala_library(
8194
],
8295
)
8396

97+
# Runtime dependencies for generated scrooge code (for downstream consumers)
98+
scala_library(
99+
name = "scrooge_runtime_deps",
100+
visibility = ["//visibility:public"],
101+
exports = [
102+
"@thrift_deps//:com_twitter_finagle_core_2_13",
103+
"@thrift_deps//:com_twitter_finagle_thrift_2_13",
104+
"@thrift_deps//:com_twitter_scrooge_core_2_13",
105+
"@thrift_deps//:org_apache_thrift_libthrift",
106+
],
107+
)
108+
109+
# Full finagle dependencies for Server/Client scala files
110+
scala_library(
111+
name = "finagle_deps",
112+
visibility = ["//visibility:public"],
113+
exports = [
114+
"@thrift_deps//:com_twitter_finagle_core_2_13",
115+
"@thrift_deps//:com_twitter_finagle_http_2_13",
116+
"@thrift_deps//:com_twitter_finagle_mux_2_13",
117+
"@thrift_deps//:com_twitter_finagle_thrift_2_13",
118+
"@thrift_deps//:com_twitter_finagle_thriftmux_2_13",
119+
],
120+
)
121+
84122
scala_library(
85123
name = "thrift_jars",
86124
visibility = ["//visibility:public"],
@@ -91,6 +129,9 @@ scala_library(
91129

92130
scrooge_scala_library(
93131
name = "thriftmux_scrooge",
132+
exports = [
133+
":scrooge_runtime_deps",
134+
],
94135
deps = [
95136
":thrift_library",
96137
],
@@ -110,6 +151,7 @@ scala_binary(
110151
srcs = glob(["**/*.scala"]),
111152
main_class = "Server",
112153
deps = [
154+
":finagle_deps",
113155
":thriftmux_scrooge",
114156
],
115157
)
@@ -119,6 +161,7 @@ scala_binary(
119161
srcs = glob(["**/*.scala"]),
120162
main_class = "Client",
121163
deps = [
164+
":finagle_deps",
122165
":thriftmux_scrooge",
123166
],
124167
)
@@ -144,6 +187,7 @@ scala_image(
144187
],
145188
main_class = "Server",
146189
deps = [
190+
":finagle_deps",
147191
":logging",
148192
":thriftmux_scrooge",
149193
],

0 commit comments

Comments
 (0)