-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce
select_since
for backwards incompatible dependencies in c…
…lion
- Loading branch information
Showing
2 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
load("//intellij_platform_sdk:build_defs.bzl", "INDIRECT_IJ_PRODUCTS") | ||
|
||
SUPPORTED_VERSIONS = { | ||
"clion-oss-oldest-stable": INDIRECT_IJ_PRODUCTS["clion-oss-oldest-stable"], | ||
"clion-oss-latest-stable": INDIRECT_IJ_PRODUCTS["clion-oss-latest-stable"], | ||
"clion-oss-under-dev": INDIRECT_IJ_PRODUCTS["clion-oss-under-dev"], | ||
} | ||
|
||
def _version_to_number(version): | ||
""" | ||
Turns a clion version `clion-20xx.x` to an integer. Used for comparing clion versions. | ||
""" | ||
|
||
# take the last six characters of the version `20xx.x ` | ||
version = version[-6:] | ||
|
||
# replace the dot with a 0 | ||
version = version.replace(".", "0") | ||
|
||
return int(version) | ||
|
||
def select_since(since, value, default = None): | ||
""" | ||
Returns a select that on targeted clion version. The select returns the `value` if the target version is bigger or | ||
equal to the specified `version`. If a default value is defined this value is returned otherwise. | ||
Might be good replacement for sdkcompat if only future versions are targeted. | ||
Args: | ||
since: the minimum supported version | ||
value: the value to select if the current target version is bigger or equal than `since | ||
default: a optional default value | ||
""" | ||
|
||
select_params = dict() | ||
|
||
for name, version in SUPPORTED_VERSIONS.items(): | ||
if _version_to_number(version) >= _version_to_number(since): | ||
select_params["//intellij_platform_sdk:" + version] = value | ||
select_params["//intellij_platform_sdk:" + name] = value | ||
|
||
if default != None: | ||
select_params["//conditions:default"] = default | ||
|
||
return select( | ||
select_params, | ||
no_match_error = "unsupported clion version, min version: clion-" + since, | ||
) |