Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7aefd22

Browse files
committed
Kotlin: tweak BUILD.bazel file, add documentation
1 parent 44f3c02 commit 7aefd22

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

java/kotlin-extractor/BUILD.bazel

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1-
# notice that this is used in the `@codeql_koblin_embeddable` external repo, which means we need to
1+
"""
2+
# Usage overview
3+
Building the extractor can be done via
4+
```
5+
bazel build //java/kotlin-extractor:codeql-extractor-kotlin-<variant>-<version>
6+
```
7+
where `<variant>` is either `standalone` or `embeddable`, and `<version>` is one of the supported versions.
8+
9+
For the moment both variants where tested by replacing them into `target/intree/codeql-java` and running one relevant integration test.
10+
11+
```
12+
bazel build //java/kotlin-extractor
13+
```
14+
will build a default variant:
15+
* standalone, unless `CODEQL_KOTLIN_SINGLE_VERSION_EMBEDDABLE` is set to true, in which case it will go for embeddable
16+
* the version will be taken as the last supported version less than the version of the currently installed `kotlinc`
17+
* if `CODEQL_KOTLIN_SINGLE_VERSION` is set, that will be used instead
18+
* if `kotlinc` is not installed, `1.9.20-Beta` will be used
19+
20+
If `kotlinc` is updated, bazel won't be aware of it and will therefore keep the same default version. Possible workarounds for that:
21+
* `bazel clean`
22+
* `bazel fetch --force @codeql_kotlin_defaults\\:all`
23+
* `CODEQL_KOTLIN_SINGLE_VERSION= bazel build //java/kotlin-extractor`
24+
"""
25+
26+
# notice that this file is used in the `@codeql_koblin_embeddable` external repo, which means we need to
227
# reference explicitly @codeql
328
load(
429
"@codeql//java/kotlin-extractor:versions.bzl",
530
"VERSIONS",
631
"get_compatilibity_sources",
32+
"get_language_version",
733
"version_less",
834
)
935
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
@@ -46,7 +72,7 @@ _resources = [
4672
name = "kotlinc-options-%s" % v,
4773
include_stdlibs = "none",
4874
jvm_target = "1.8",
49-
language_version = v[:3],
75+
language_version = get_language_version(v),
5076
warn = "error",
5177
x_optin = [
5278
"kotlin.RequiresOptIn",

java/kotlin-extractor/versions.bzl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ def _version_to_tuple(v):
2222
v = tuple([int(x) for x in v.split(".")])
2323
return v + (tail,)
2424

25-
def _tuple_to_version(t):
26-
ret = ".".join([str(x) for x in t[:3]])
27-
if t[3]:
28-
ret += "-" + t[3]
29-
return ret
30-
3125
def version_less(lhs, rhs):
3226
return _version_to_tuple(lhs) < _version_to_tuple(rhs)
3327

28+
def get_language_version(version):
29+
major, minor, _, _ = _version_to_tuple(version)
30+
return "%s.%s" % (major, minor)
31+
3432
def _basename(path):
3533
if "/" not in path:
3634
return path

0 commit comments

Comments
 (0)