Skip to content

Commit b9aea94

Browse files
committed
WIP: Bzlmod part the forty-ninth
Made the config extension aware of the `SCALA_VERSION` and `ENABLE_COMPILER_DEPENDENCY_TRACKING` env vars to fix part of `test_classpath_contains_2_12` from test/shell/test_scala_config.sh. Now it's dying with: ```txt Analyzing: target //src/java/io/bazel/rulesscala/scalac:scalac (1 packages loaded, 0 targets configured) ERROR: Traceback (most recent call last): File ".../scala/extensions/deps.bzl", line 210, column 30, in _scala_deps_impl scalafmt_repositories( File ".../scala/scalafmt/scalafmt_repositories.bzl", line 67, column 21, in scalafmt_repositories repositories( File ".../third_party/repositories/repositories.bzl", line 103, column 33, in repositories artifact = artifacts[id]["artifact"], Error: key "com_geirsson_metaconfig_pprint" not found in dictionary ERROR: Analysis of target '//src/java/io/bazel/rulesscala/scalac:scalac' failed; build aborted: error evaluating module extension scala_deps in //scala/extensions:deps.bzl ``` Still, getting closer and closer to getting all the tests to pass under Bzlmod!
1 parent 83f383c commit b9aea94

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

MODULE.bazel.lock

+7-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scala/extensions/config.bzl

+17-7
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@ _settings = tag_class(
1212
)
1313

1414
def _get_root_settings(module_ctx):
15+
scala_version = DEFAULT_SCALA_VERSION
16+
compiler_dep_tracking = False
1517
root_settings = module_ctx.modules[0].tags.settings
1618

17-
if len(root_settings) == 0:
18-
return DEFAULT_SCALA_VERSION, False
19-
root = root_settings[0]
20-
return root.scala_version, root.enable_compiler_dependency_tracking
19+
if len(root_settings) != 0:
20+
root = root_settings[0]
21+
scala_version = root.scala_version
22+
compiler_dep_tracking = root.enable_compiler_dependency_tracking
2123

22-
def _collect_versions(module_ctx):
23-
versions = {}
24+
return (
25+
module_ctx.os.environ.get("SCALA_VERSION", scala_version),
26+
module_ctx.os.environ.get(
27+
"ENABLE_COMPILER_DEPENDENCY_TRACKING", compiler_dep_tracking
28+
),
29+
)
30+
31+
def _collect_versions(module_ctx, scala_version):
32+
versions = {scala_version: None}
2433

2534
for mod in module_ctx.modules:
2635
for settings in mod.tags.settings:
@@ -33,7 +42,7 @@ def _scala_config_impl(module_ctx):
3342

3443
_scala_config(
3544
scala_version = version,
36-
scala_versions = _collect_versions(module_ctx),
45+
scala_versions = _collect_versions(module_ctx, version),
3746
enable_compiler_dependency_tracking = compiler_dep_tracking,
3847
)
3948
return module_ctx.extension_metadata(
@@ -44,4 +53,5 @@ def _scala_config_impl(module_ctx):
4453
scala_config = module_extension(
4554
implementation = _scala_config_impl,
4655
tag_classes = {"settings": _settings},
56+
environ = ["SCALA_VERSION", "ENABLE_COMPILER_DEPENDENCY_TRACKING"],
4757
)

0 commit comments

Comments
 (0)