mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Merge pull request #11217 from igfoo/igfoo/kotlin_version_rec
Java/Kotlin: Write Kotlin version information to the database
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
description: Remove compilation_info
|
||||
compatibility: full
|
||||
compilation_info.rel: delete
|
||||
@@ -103,7 +103,7 @@ def compile_to_dir(srcs, classpath, java_classpath, output):
|
||||
'-classpath', os.path.pathsep.join([output, classpath, java_classpath])] + [s for s in srcs if s.endswith(".java")])
|
||||
|
||||
|
||||
def compile_to_jar(build_dir, srcs, classpath, java_classpath, output):
|
||||
def compile_to_jar(build_dir, tmp_src_dir, srcs, classpath, java_classpath, output):
|
||||
class_dir = build_dir + '/classes'
|
||||
|
||||
if os.path.exists(class_dir):
|
||||
@@ -114,7 +114,8 @@ def compile_to_jar(build_dir, srcs, classpath, java_classpath, output):
|
||||
|
||||
run_process(['jar', 'cf', output,
|
||||
'-C', class_dir, '.',
|
||||
'-C', 'src/main/resources', 'META-INF'])
|
||||
'-C', tmp_src_dir + '/main/resources', 'META-INF',
|
||||
'-C', tmp_src_dir + '/main/resources', 'com/github/codeql/extractor.name'])
|
||||
shutil.rmtree(class_dir)
|
||||
|
||||
|
||||
@@ -185,6 +186,11 @@ def compile(jars, java_jars, dependency_folder, transform_to_embeddable, output,
|
||||
include_version_folder = tmp_src_dir + '/main/kotlin/utils/versions/to_include'
|
||||
os.makedirs(include_version_folder)
|
||||
|
||||
resource_dir = tmp_src_dir + '/main/resources/com/github/codeql'
|
||||
os.makedirs(resource_dir)
|
||||
with open(resource_dir + '/extractor.name', 'w') as f:
|
||||
f.write(output)
|
||||
|
||||
parsed_current_version = kotlin_plugin_versions.version_string_to_tuple(
|
||||
current_version)
|
||||
|
||||
@@ -211,7 +217,7 @@ def compile(jars, java_jars, dependency_folder, transform_to_embeddable, output,
|
||||
|
||||
transform_to_embeddable(srcs)
|
||||
|
||||
compile_to_jar(build_dir, srcs, classpath, java_classpath, output)
|
||||
compile_to_jar(build_dir, tmp_src_dir, srcs, classpath, java_classpath, output)
|
||||
|
||||
shutil.rmtree(tmp_src_dir)
|
||||
|
||||
|
||||
@@ -131,6 +131,9 @@ class KotlinExtractorExtension(
|
||||
// The interceptor has already defined #compilation = *
|
||||
val compilation: Label<DbCompilation> = StringLabel("compilation")
|
||||
tw.writeCompilation_started(compilation)
|
||||
tw.writeCompilation_info(compilation, "Kotlin Compiler Version", KotlinCompilerVersion.getVersion() ?: "<unknown>")
|
||||
val extractor_name = this::class.java.getResource("extractor.name")?.readText() ?: "<unknown>"
|
||||
tw.writeCompilation_info(compilation, "Kotlin Extractor Name", extractor_name)
|
||||
if (compilationStartTime != null) {
|
||||
tw.writeCompilation_compiler_times(compilation, -1.0, (System.currentTimeMillis()-compilationStartTime)/1000.0)
|
||||
}
|
||||
|
||||
4
java/ql/lib/change-notes/2022-11-10-getInfo.md
Normal file
4
java/ql/lib/change-notes/2022-11-10-getInfo.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: feature
|
||||
---
|
||||
* The new `string Compilation.getInfo(string)` provides access to some information about compilations.
|
||||
@@ -31,6 +31,12 @@ compilation_started(
|
||||
int id : @compilation ref
|
||||
)
|
||||
|
||||
compilation_info(
|
||||
int id : @compilation ref,
|
||||
string info_key: string ref,
|
||||
string info_value: string ref
|
||||
)
|
||||
|
||||
/**
|
||||
* The arguments that were passed to the extractor for a compiler
|
||||
* invocation. If `id` is for the compiler invocation
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -143,4 +143,9 @@ class Compilation extends @compilation {
|
||||
* Holds if the extractor encountered non-recoverable errors.
|
||||
*/
|
||||
predicate nonRecoverableErrors() { compilation_finished(this, _, _, 2) }
|
||||
|
||||
/**
|
||||
* Gets the piece of compilation information with the given key, if any.
|
||||
*/
|
||||
string getInfo(string key) { compilation_info(this, key, result) }
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Add compilation_info
|
||||
compatibility: backwards
|
||||
Reference in New Issue
Block a user