daml/sdk/bazel_tools/scala_version.bzl
Gary Verhaegen e40aad897f
move to subdir 3.0 (#18520)
* move most files

* update CI configuration
2024-03-22 02:27:46 +01:00

65 lines
2.2 KiB
Python

# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Keep the Scala versions in sync with /nix/nixpkgs.nix and /release/src/Options.hs.
# When upgrading download the libraries from maven and then use the sha256sum to generate the checksum.
default_scala_version = "2.13.11"
scala_artifacts = {
"2.13.11": {
"io_bazel_rules_scala_scala_compiler": {
"artifact": "org.scala-lang:scala-compiler:2.13.11",
"sha256": "c5a14770370e73a69367b131da1533890200b1e2aa70643b73f9ff31ef2e69ec",
},
"io_bazel_rules_scala_scala_library": {
"artifact": "org.scala-lang:scala-library:2.13.11",
"sha256": "71853291f61bda32786a866533361cae474344f5b2772a379179b02112444ed3",
},
"io_bazel_rules_scala_scala_reflect": {
"artifact": "org.scala-lang:scala-reflect:2.13.11",
"sha256": "6a46ed9b333857e8b5ea668bb254ed8e47dacd1116bf53ade9467aa4ae8f1818",
},
},
}
def _impl(ctx):
# Generates an empty BUILD file, because we do not need to build anything.
ctx.file(
"BUILD",
content = """exports_files(["index.bzl"])""",
executable = False,
)
version = ctx.os.environ.get("DAML_SCALA_VERSION", default = default_scala_version)
if version == "":
version = default_scala_version
suffix = version.replace(".", "_")
major = version[:version.rfind(".")]
major_suffix = major.replace(".", "_")
artifacts = scala_artifacts.get(version) or fail("Unknown Scala version: %s" % version)
ctx.file(
"index.bzl",
content = """
scala_version = "{version}"
scala_major_version = "{major}"
scala_version_suffix = "{suffix}"
scala_major_version_suffix = "{major_suffix}"
scala_artifacts = {artifacts}
""".format(
version = version,
major = major,
suffix = suffix,
major_suffix = major_suffix,
artifacts = artifacts,
),
executable = False,
)
scala_version_configure = repository_rule(
environ = ["DAML_SCALA_VERSION"],
implementation = _impl,
attrs = {},
)