2024-04-04 11:23:26 +03:00
|
|
|
# when updating this list, `bazel mod tidy` should be run from `codeql` to update `MODULE.bazel`
|
2024-05-06 18:31:50 +03:00
|
|
|
VERSIONS = [
|
|
|
|
"1.5.0",
|
|
|
|
"1.5.10",
|
|
|
|
"1.5.20",
|
|
|
|
"1.5.30",
|
|
|
|
"1.6.0",
|
|
|
|
"1.6.20",
|
|
|
|
"1.7.0",
|
|
|
|
"1.7.20",
|
|
|
|
"1.8.0",
|
|
|
|
"1.9.0-Beta",
|
|
|
|
"1.9.20-Beta",
|
|
|
|
"2.0.0-RC1",
|
2024-07-11 17:34:37 +03:00
|
|
|
"2.0.20-Beta2",
|
2024-05-06 18:31:50 +03:00
|
|
|
]
|
2024-04-03 17:29:16 +03:00
|
|
|
|
|
|
|
def _version_to_tuple(v):
|
2024-04-10 12:29:58 +03:00
|
|
|
# we ignore the tag when comparing versions, for example 1.9.0-Beta <= 1.9.0
|
|
|
|
v, _, ignored_tag = v.partition("-")
|
|
|
|
return tuple([int(x) for x in v.split(".")])
|
2024-04-03 17:29:16 +03:00
|
|
|
|
|
|
|
def version_less(lhs, rhs):
|
|
|
|
return _version_to_tuple(lhs) < _version_to_tuple(rhs)
|
|
|
|
|
2024-04-04 18:32:23 +03:00
|
|
|
def get_language_version(version):
|
2024-04-10 12:29:58 +03:00
|
|
|
major, minor, _ = _version_to_tuple(version)
|
2024-04-04 18:32:23 +03:00
|
|
|
return "%s.%s" % (major, minor)
|
|
|
|
|
2024-04-03 17:29:16 +03:00
|
|
|
def _basename(path):
|
|
|
|
if "/" not in path:
|
|
|
|
return path
|
|
|
|
return path[path.rindex("/") + 1:]
|
|
|
|
|
|
|
|
def get_compatilibity_sources(version, dir):
|
|
|
|
prefix = "%s/v_" % dir
|
|
|
|
available = native.glob(["%s*" % prefix], exclude_directories = 0)
|
|
|
|
|
|
|
|
# we want files with the same base name to replace ones for previous versions, hence the map
|
|
|
|
srcs = {}
|
|
|
|
for d in available:
|
|
|
|
compat_version = d[len(prefix):].replace("_", ".")
|
|
|
|
if version_less(version, compat_version):
|
|
|
|
break
|
|
|
|
files = native.glob(["%s/*.kt" % d])
|
|
|
|
srcs |= {_basename(f): f for f in files}
|
|
|
|
return srcs.values()
|