|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 |
|
3 | 3 | import glob
|
| 4 | +import os |
4 | 5 | import re
|
5 | 6 | from create_database_utils import *
|
6 | 7 |
|
| 8 | +def say(s): |
| 9 | + print(s) |
| 10 | + sys.stdout.flush() |
| 11 | + |
| 12 | +say('Doing normal compilation') |
7 | 13 | # This is a normal intercepted compilation
|
8 | 14 | runSuccessfully([get_cmd('kotlinc'), 'normal.kt'])
|
9 | 15 |
|
| 16 | +say('Identifying extractor jar') |
10 | 17 | # Find the extractor jar that is being used
|
11 | 18 | trapDir = os.environ['CODEQL_EXTRACTOR_JAVA_TRAP_DIR']
|
12 |
| -invocationTrapDir = trapDir + '/invocations' |
| 19 | +invocationTrapDir = os.path.join(trapDir, 'invocations') |
13 | 20 | invocationTraps = os.listdir(invocationTrapDir)
|
14 | 21 | if len(invocationTraps) != 1:
|
15 | 22 | raise Exception('Expected to find 1 invocation TRAP, but found ' + str(invocationTraps))
|
16 |
| -invocationTrap = invocationTrapDir + '/' + invocationTraps[0] |
| 23 | +invocationTrap = os.path.join(invocationTrapDir, invocationTraps[0]) |
17 | 24 | with open(invocationTrap, 'r') as f:
|
18 | 25 | content = f.read()
|
19 | 26 | m = re.search('^// Using extractor: (.*)$', content, flags = re.MULTILINE)
|
20 | 27 | extractorJar = m.group(1)
|
21 | 28 |
|
22 | 29 | def getManualFlags(invocationTrapName):
|
23 |
| - return ['-Xplugin=' + extractorJar, '-P', 'plugin:kotlin-extractor:invocationTrapFile=' + trapDir + '/invocations/' + invocationTrapName + '.trap'] |
| 30 | + return ['-Xplugin=' + extractorJar, '-P', 'plugin:kotlin-extractor:invocationTrapFile=' + os.path.join(trapDir, 'invocations', invocationTrapName + '.trap')] |
24 | 31 |
|
25 | 32 | # This is both normally intercepted, and it has the extractor flags manually added
|
| 33 | +say('Doing double-interception compilation') |
26 | 34 | runSuccessfully([get_cmd('kotlinc'), 'doubleIntercepted.kt'] + getManualFlags('doubleIntercepted'))
|
27 | 35 | os.environ['CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN'] = 'true'
|
28 | 36 | # We don't see this compilation at all
|
| 37 | +say('Doing unseen compilation') |
29 | 38 | runSuccessfully([get_cmd('kotlinc'), 'notSeen.kt'])
|
30 | 39 | # This is extracted as it has the extractor flags manually added
|
| 40 | +say('Doing manual compilation') |
31 | 41 | runSuccessfully([get_cmd('kotlinc'), 'manual.kt'] + getManualFlags('manual'))
|
0 commit comments