| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 796790d commit ea75176
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,10 @@ _compiler_plugin_registrar_service_source = "src/main/resources/META-INF/service | |||
| 57 | 57 | ||
| 58 | 58 | _compiler_plugin_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar" | |
| 59 | 59 | ||
| 60 | + _component_registrar_service_source = "src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar" | ||
| 61 | + | ||
| 62 | + _component_registrar_service_target = "META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar" | ||
| 63 | + | ||
| 60 | 64 | py_binary( | |
| 61 | 65 | name = "generate_dbscheme", | |
| 62 | 66 | srcs = ["generate_dbscheme.py"], | |
@@ -68,14 +72,22 @@ _resources = [ | |||
| 68 | 72 | r[len("src/main/resources/"):], | |
| 69 | 73 | ) | |
| 70 | 74 | for r in glob(["src/main/resources/**"]) | |
| 71 | - if r != _compiler_plugin_registrar_service_source | ||
| 75 | + if r not in ( | ||
| 76 | + _compiler_plugin_registrar_service_source, | ||
| 77 | + _component_registrar_service_source, | ||
| 78 | + ) | ||
| 72 | 79 | ] | |
| 73 | 80 | ||
| 74 | 81 | _compiler_plugin_registrar_service = ( | |
| 75 | 82 | _compiler_plugin_registrar_service_source, | |
| 76 | 83 | _compiler_plugin_registrar_service_target, | |
| 77 | 84 | ) | |
| 78 | 85 | ||
| 86 | + _component_registrar_service = ( | ||
| 87 | + _component_registrar_service_source, | ||
| 88 | + _component_registrar_service_target, | ||
| 89 | + ) | ||
| 90 | + | ||
| 79 | 91 | kt_javac_options( | |
| 80 | 92 | name = "javac-options", | |
| 81 | 93 | release = "8", | |
@@ -93,7 +105,9 @@ kt_javac_options( | |||
| 93 | 105 | "kotlin.RequiresOptIn", | |
| 94 | 106 | "org.jetbrains.kotlin.ir.symbols.%s" % | |
| 95 | 107 | ("IrSymbolInternals" if version_less(v, "2.0.0") else "UnsafeDuringIrConstructionAPI"), | |
| 96 | - ] + ([] if version_less(v, "2.2.20") else ["org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi"]), | ||
| 108 | + ] + ( | ||
| 109 | + [] if version_less(v, "2.2.20") else ["org.jetbrains.kotlin.DeprecatedForRemovalCompilerApi"] | ||
| 110 | + ), | ||
| 97 | 111 | x_suppress_version_warnings = True, | |
| 98 | 112 | ), | |
| 99 | 113 | # * extractor.name is different for each version, so we need to put it in different output dirs | |
@@ -103,6 +117,8 @@ kt_javac_options( | |||
| 103 | 117 | name = "resources-%s" % v, | |
| 104 | 118 | srcs = [src for src, _ in _resources] + ( | |
| 105 | 119 | [_compiler_plugin_registrar_service[0]] if not version_less(v, "2.4.0") else [] | |
| 120 | + ) + ( | ||
| 121 | + [_component_registrar_service[0]] if version_less(v, "2.4.20") else [] | ||
| 106 | 122 | ), | |
| 107 | 123 | outs = [ | |
| 108 | 124 | "%s/com/github/codeql/extractor.name" % v, | |
@@ -114,6 +130,11 @@ kt_javac_options( | |||
| 114 | 130 | v, | |
| 115 | 131 | _compiler_plugin_registrar_service[1], | |
| 116 | 132 | )] if not version_less(v, "2.4.0") else [] | |
| 133 | + ) + ( | ||
| 134 | + ["%s/%s" % ( | ||
| 135 | + v, | ||
| 136 | + _component_registrar_service[1], | ||
| 137 | + )] if version_less(v, "2.4.20") else [] | ||
| 117 | 138 | ), | |
| 118 | 139 | cmd = "\n".join([ | |
| 119 | 140 | "echo %s-%s > $(RULEDIR)/%s/com/github/codeql/extractor.name" % (_extractor_name_prefix, v, v), | |
@@ -126,6 +147,12 @@ kt_javac_options( | |||
| 126 | 147 | v, | |
| 127 | 148 | _compiler_plugin_registrar_service[1], | |
| 128 | 149 | )] if not version_less(v, "2.4.0") else [] | |
| 150 | + ) + ( | ||
| 151 | + ["cp $(execpath %s) $(RULEDIR)/%s/%s" % ( | ||
| 152 | + _component_registrar_service[0], | ||
| 153 | + v, | ||
| 154 | + _component_registrar_service[1], | ||
| 155 | + )] if version_less(v, "2.4.20") else [] | ||
| 129 | 156 | )), | |
| 130 | 157 | ), | |
| 131 | 158 | kt_jvm_library( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 1 | + package com.github.codeql | ||
| 2 | + | ||
| 3 | + import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension | ||
| 4 | + import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar | ||
| 5 | + import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi | ||
| 6 | + import org.jetbrains.kotlin.config.CompilerConfiguration | ||
| 7 | + | ||
| 8 | + @OptIn(ExperimentalCompilerApi::class) | ||
| 9 | + abstract class Kotlin2ComponentRegistrar : CompilerPluginRegistrar() { | ||
| 10 | + override val supportsK2: Boolean | ||
| 11 | + get() = true | ||
| 12 | + | ||
| 13 | + override val pluginId: String | ||
| 14 | + get() = "kotlin-extractor" | ||
| 15 | + | ||
| 16 | + private var extensionStorage: CompilerPluginRegistrar.ExtensionStorage? = null | ||
| 17 | + | ||
| 18 | + override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) { | ||
| 19 | + this@Kotlin2ComponentRegistrar.extensionStorage = this | ||
| 20 | + doRegisterExtensions(configuration) | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + abstract fun doRegisterExtensions(configuration: CompilerConfiguration) | ||
| 24 | + | ||
| 25 | + protected fun registerExtractorExtension(extension: IrGenerationExtension) { | ||
| 26 | + val storage = extensionStorage | ||
| 27 | + ?: throw IllegalStateException("registerExtractorExtension called before registerExtensions") | ||
| 28 | + with(storage) { | ||
| 29 | + IrGenerationExtension.registerExtension(extension) | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments