FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/java/kotlin-extractor/deps.bzl at codeql-cli/v2.19.1 · github/codeql · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10k
Code
Issues
997
Pull requests
467
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
java
/
kotlin-extractor
/
deps.bzl
Copy path
More file actions
More file actions
Latest commit
History
History
History
124 lines (107 loc) · 4.33 KB
Breadcrumbs
codeql
/
java
/
kotlin-extractor
/
deps.bzl
Copy path
File metadata and controls
124 lines (107 loc) · 4.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
load
(
"//java/kotlin-extractor:versions.bzl"
,
"VERSIONS"
)
load
(
"//misc/bazel:lfs.bzl"
,
"lfs_smudge"
)
_kotlin_dep_build
=
"""
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_import")
kt_jvm_import(
name = "{name}",
jar = "{name}.jar",
visibility = ["//visibility:public"],
)
"""
_empty_zip
=
"PK
\005
\006
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
\000
"
def
_get_dep
(
repository_ctx
,
name
):
return
repository_ctx
.
path
(
Label
(
"//java/kotlin-extractor/deps:%s"
%
name
))
def
_kotlin_dep_impl
(
repository_ctx
):
_
,
_
,
name
=
repository_ctx
.
name
.
rpartition
(
"~"
)
lfs_smudge
(
repository_ctx
, [
_get_dep
(
repository_ctx
,
name
+
".jar"
)])
# for some reason rules_kotlin warns about these jars missing, this is to silence those warnings
repository_ctx
.
file
(
"empty.zip"
,
_empty_zip
)
for
jar
in
(
"annotations-13.0.jar"
,
"kotlin-stdlib.jar"
,
"kotlin-reflect.jar"
,
"kotlin-script-runtime.jar"
,
"trove4j.jar"
,
):
repository_ctx
.
symlink
(
"empty.zip"
,
jar
)
repository_ctx
.
file
(
"BUILD.bazel"
,
_kotlin_dep_build
.
format
(
name
=
name
))
_kotlin_dep
=
repository_rule
(
implementation
=
_kotlin_dep_impl
,
)
def
_walk
(
dir
):
res
=
[]
next_dirs
=
[
dir
]
# loops must be bounded in starlark
for
i
in
range
(
100
):
current_dirs
=
next_dirs
next_dirs
=
[]
for
d
in
current_dirs
:
children
=
d
.
readdir
()
next_dirs
.
extend
([
c
for
c
in
children
if
c
.
is_dir
])
res
.
extend
([
c
for
c
in
children
if
not
c
.
is_dir
])
if
not
next_dirs
:
return
res
fail
(
"%s directory too deep"
%
dir
)
def
_embeddable_source_impl
(
repository_ctx
):
src_dir
=
repository_ctx
.
path
(
Label
(
"//java/kotlin-extractor:src"
))
repository_ctx
.
watch_tree
(
src_dir
)
for
src
in
_walk
(
src_dir
):
contents
=
repository_ctx
.
read
(
src
)
contents
=
contents
.
replace
(
"import com.intellij"
,
"import org.jetbrains.kotlin.com.intellij"
,
)
repository_ctx
.
file
(
str
(
src
).
replace
(
str
(
src_dir
),
"src"
),
contents
)
repository_ctx
.
symlink
(
Label
(
"//java/kotlin-extractor:BUILD.bazel"
),
"BUILD.bazel"
,
)
_embeddable_source
=
repository_rule
(
implementation
=
_embeddable_source_impl
)
def
_get_version
(
repository_ctx
,
available
=
[]):
default_version
=
repository_ctx
.
getenv
(
"CODEQL_KOTLIN_SINGLE_VERSION"
)
if
default_version
:
return
default_version
repository_ctx
.
watch
(
Label
(
"//java/kotlin-extractor:dev/.kotlinc_version"
))
version_picker
=
repository_ctx
.
path
(
Label
(
"//java/kotlin-extractor:pick-kotlin-version.py"
))
python
=
repository_ctx
.
which
(
"python3"
)
or
repository_ctx
.
which
(
"python"
)
# use the kotlinc wrapper as fallback
path
=
repository_ctx
.
getenv
(
"PATH"
)
path_to_add
=
repository_ctx
.
path
(
Label
(
"//java/kotlin-extractor:dev"
))
if
not
path
:
path
=
str
(
path_to_add
)
elif
repository_ctx
.
os
.
name
==
"windows"
:
path
=
"%s;%s"
%
(
path
,
path_to_add
)
else
:
path
=
"%s:%s"
%
(
path
,
path_to_add
)
res
=
repository_ctx
.
execute
([
python
,
version_picker
]
+
available
,
environment
=
{
"PATH"
:
path
})
if
res
.
return_code
!=
0
:
fail
(
res
.
stderr
)
return
res
.
stdout
.
strip
()
def
_defaults_impl
(
repository_ctx
):
default_version
=
_get_version
(
repository_ctx
)
default_variant
=
"standalone"
if
repository_ctx
.
getenv
(
"CODEQL_KOTLIN_SINGLE_VERSION_EMBEDDABLE"
)
in
(
"true"
,
"1"
):
default_variant
=
"embeddable"
available_version
=
_get_version
(
repository_ctx
,
VERSIONS
)
info
=
struct
(
version
=
default_version
,
variant
=
default_variant
,
extractor_version
=
available_version
,
)
repository_ctx
.
file
(
"defaults.bzl"
,
"kotlin_extractor_defaults = %s
\n
"
%
repr
(
info
),
)
repository_ctx
.
file
(
"BUILD.bazel"
)
_defaults
=
repository_rule
(
implementation
=
_defaults_impl
)
def
_kotlin_deps_impl
(
module_ctx
):
for
v
in
VERSIONS
:
for
lib
in
(
"compiler"
,
"compiler-embeddable"
,
"stdlib"
):
_kotlin_dep
(
name
=
"kotlin-%s-%s"
%
(
lib
,
v
))
_embeddable_source
(
name
=
"codeql_kotlin_embeddable"
)
_defaults
(
name
=
"codeql_kotlin_defaults"
)
return
module_ctx
.
extension_metadata
(
root_module_direct_deps
=
"all"
,
root_module_direct_dev_deps
=
[],
)
kotlin_extractor_deps
=
module_extension
(
implementation
=
_kotlin_deps_impl
)
Back
|
FazBrowse Home
|
New Git URL