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

Skip to content

Commit e5e6225

Browse files
committed
Kotlin: Add a build.py script that uses kotlinc to build
1 parent 1d1b9fe commit e5e6225

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

java/kotlin-extractor/build.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/python
2+
3+
import glob
4+
import re
5+
import subprocess
6+
7+
kotlinc = 'kotlinc'
8+
srcs = glob.glob('src/**/*.kt', recursive=True)
9+
jars = ['kotlin-compiler']
10+
11+
x = subprocess.run([kotlinc, '-version', '-verbose'], check=True, capture_output=True)
12+
output = x.stderr.decode(encoding = 'UTF-8',errors = 'strict')
13+
m = re.match(r'.*\nlogging: using Kotlin home directory ([^\n]+)\n.*', output)
14+
if m is None:
15+
raise Exception('Cannot determine kotlinc home directory')
16+
kotlin_home = m.group(1)
17+
kotlin_lib = kotlin_home + '/lib'
18+
classpath = ':'.join(map(lambda j: kotlin_lib + '/' + j + '.jar', jars))
19+
20+
subprocess.run([kotlinc,
21+
'-d', 'codeql-extractor-kotlin.jar',
22+
'-module-name', 'codeql-kotlin-extractor',
23+
'-no-reflect',
24+
'-jvm-target', '1.8',
25+
'-classpath', classpath] + srcs , check=True)
26+
subprocess.run(['jar', '-u', '-f', 'codeql-extractor-kotlin.jar', '-C', 'src/main/resources', 'META-INF'], check=True)
27+

0 commit comments

Comments
 (0)