1+ # notice that this is used in the `@codeql_koblin_embeddable` external repo, which means we need to
2+ # reference explicitly @codeql
13load (
2- "//java/kotlin-extractor:versions.bzl" ,
4+ "@codeql //java/kotlin-extractor:versions.bzl" ,
35 "VERSIONS" ,
46 "get_compatilibity_sources" ,
57 "version_less" ,
68)
79load ("@rules_kotlin//kotlin:jvm.bzl" , "kt_jvm_library" )
810load ("@rules_kotlin//kotlin:core.bzl" , "kt_kotlinc_options" )
911
12+ _for_embeddable = repo_name ().endswith ("codeql_kotlin_embeddable" )
13+
14+ _common_extractor_name_prefix = "codeql-extractor-kotlin"
15+
16+ _extractor_name_prefix = "%s-%s" % (
17+ _common_extractor_name_prefix ,
18+ "embeddable" if _for_embeddable else "standalone" ,
19+ )
20+
1021py_binary (
1122 name = "generate_dbscheme" ,
1223 srcs = ["generate_dbscheme.py" ],
1324)
1425
1526genrule (
1627 name = "generated-dbscheme" ,
17- srcs = ["//java:dbscheme" ],
28+ srcs = ["@codeql //java:dbscheme" ],
1829 outs = ["KotlinExtractorDbScheme.kt" ],
1930 cmd = "$(execpath :generate_dbscheme) $< $@" ,
2031 tools = [":generate_dbscheme" ],
@@ -56,14 +67,14 @@ _resources = [
5667 for _ , tgt in _resources
5768 ],
5869 cmd = "\n " .join ([
59- "echo codeql-extractor-kotlin-standalone- %s > $(RULEDIR)/%s/com/github/codeql/extractor.name" % (v , v ),
70+ "echo %s- %s > $(RULEDIR)/%s/com/github/codeql/extractor.name" % (_extractor_name_prefix , v , v ),
6071 ] + [
6172 "cp $(execpath %s) $(RULEDIR)/%s/%s" % (src , v , tgt )
6273 for src , tgt in _resources
6374 ]),
6475 ),
6576 kt_jvm_library (
66- name = "codeql-extractor-kotlin-standalone- %s" % v ,
77+ name = "%s- %s" % ( _extractor_name_prefix , v ) ,
6778 srcs =
6879 [":generated-dbscheme" ] +
6980 glob (
@@ -75,18 +86,31 @@ _resources = [
7586 ) + get_compatilibity_sources (v , "src/main/kotlin/utils/versions" ),
7687 kotlinc_opts = ":kotlinc-options-%s" % v ,
7788 module_name = "codeql-kotlin-extractor" ,
78- resource_strip_prefix = "%s/%s" % (
89+ resource_strip_prefix = "../%s/%s" % (
90+ repo_name (),
91+ v ,
92+ ) if _for_embeddable else "%s/%s" % (
7993 package_name (),
8094 v ,
8195 ),
8296 resources = [
8397 ":resources-%s" % v ,
8498 ],
99+ visibility = ["//visibility:public" ],
85100 deps = [
86- "@kotlin-compiler-%s" % v ,
101+ "@kotlin-compiler%s-%s" % (
102+ "-embeddable" if _for_embeddable else "" ,
103+ v ,
104+ ),
87105 "@kotlin-stdlib-%s" % v ,
88106 ],
89107 ),
108+ # if in main repository, alias the embeddable versions from the modified @codeql_kotlin_embeddable repo
109+ alias (
110+ name = "%s-embeddable-%s" % (_common_extractor_name_prefix , v ),
111+ actual = "@codeql_kotlin_embeddable//:%s-embeddable-%s" % (_common_extractor_name_prefix , v ),
112+ visibility = ["//visibility:public" ],
113+ ) if not _for_embeddable else None ,
90114 )
91115 for v in VERSIONS
92116]
0 commit comments