@@ -2,6 +2,7 @@ import * as cp from 'child_process';
2
2
import { ChildProcess , spawn } from 'child_process' ;
3
3
import * as fs from 'fs' ;
4
4
import * as path from 'path' ;
5
+ import * as paths from './paths' ;
5
6
import * as vscode from 'vscode' ;
6
7
import { CFG_TLC_STATISTICS_TYPE , ShareOption } from './commands/tlcStatisticsCfg' ;
7
8
import { pathToUri } from './common' ;
@@ -24,12 +25,15 @@ const NO_ERROR = 0;
24
25
const MIN_TLA_ERROR = 10 ; // Exit codes not related to tooling start from this number
25
26
const LOWEST_JAVA_VERSION = 8 ;
26
27
const DEFAULT_GC_OPTION = '-XX:+UseParallelGC' ;
28
+ const TLA_CMODS_LIB_NAME = 'CommunityModules-deps.jar' ;
27
29
const TLA_TOOLS_LIB_NAME = 'tla2tools.jar' ;
28
30
const TLA_TOOLS_LIB_NAME_END_UNIX = '/' + TLA_TOOLS_LIB_NAME ;
29
31
const TLA_TOOLS_LIB_NAME_END_WIN = '\\' + TLA_TOOLS_LIB_NAME ;
30
32
const toolsJarPath = path . resolve ( __dirname , '../tools/' + TLA_TOOLS_LIB_NAME ) ;
33
+ const cmodsJarPath = path . resolve ( __dirname , '../tools/' + TLA_CMODS_LIB_NAME ) ;
31
34
const javaCmd = 'java' + ( process . platform === 'win32' ? '.exe' : '' ) ;
32
35
const javaVersionChannel = new ToolOutputChannel ( 'TLA+ Java version' ) ;
36
+ const TLA_TOOLS_STANDARD_MODULES = '/tla2sany/StandardModules' ;
33
37
34
38
let lastUsedJavaHome : string | undefined ;
35
39
let cachedJavaPath : string | undefined ;
@@ -69,6 +73,14 @@ export class JavaVersion {
69
73
) { }
70
74
}
71
75
76
+ function makeTlaLibraryJavaOpt ( ) : string {
77
+ const libPaths = paths . moduleSearchPaths .
78
+ getOtherPaths ( paths . TLC ) .
79
+ filter ( p => ! p . startsWith ( 'jar:' ) ) . // TODO: Support archive paths as well.
80
+ join ( path . delimiter ) ;
81
+ return '-DTLA-Library=' + libPaths ;
82
+ }
83
+
72
84
export async function runPlusCal ( tlaFilePath : string ) : Promise < ToolProcessInfo > {
73
85
const customOptions = getConfigOptions ( CFG_PLUSCAL_OPTIONS ) ;
74
86
return runTool (
@@ -84,7 +96,7 @@ export async function runSany(tlaFilePath: string): Promise<ToolProcessInfo> {
84
96
TlaTool . SANY ,
85
97
tlaFilePath ,
86
98
[ path . basename ( tlaFilePath ) ] ,
87
- [ ]
99
+ [ makeTlaLibraryJavaOpt ( ) ]
88
100
) ;
89
101
}
90
102
@@ -116,7 +128,7 @@ export async function runTlc(
116
128
return undefined ;
117
129
}
118
130
const customOptions = extraOpts . concat ( promptedOptions ) ;
119
- const javaOptions = [ ] ;
131
+ const javaOptions = [ makeTlaLibraryJavaOpt ( ) ] ;
120
132
const shareStats = vscode . workspace . getConfiguration ( ) . get < ShareOption > ( CFG_TLC_STATISTICS_TYPE ) ;
121
133
if ( shareStats !== ShareOption . DoNotShare ) {
122
134
javaOptions . push ( '-Dtlc2.TLC.ide=vscode' ) ;
@@ -136,6 +148,7 @@ async function runTool(
136
148
javaOptions : string [ ]
137
149
) : Promise < ToolProcessInfo > {
138
150
const javaPath = await obtainJavaPath ( ) ;
151
+ // TODO: Merge cfgOptions with javaOptions to avoid complete overrides.
139
152
const cfgOptions = getConfigOptions ( CFG_JAVA_OPTIONS ) ;
140
153
const args = buildJavaOptions ( cfgOptions , toolsJarPath ) . concat ( javaOptions ) ;
141
154
args . push ( toolName ) ;
@@ -145,6 +158,13 @@ async function runTool(
145
158
return new ToolProcessInfo ( buildCommandLine ( javaPath , args ) , proc ) ;
146
159
}
147
160
161
+ export function moduleSearchPaths ( ) : string [ ] {
162
+ return [
163
+ 'jar:file:' + toolsJarPath + '!' + TLA_TOOLS_STANDARD_MODULES ,
164
+ 'jar:file:' + cmodsJarPath + '!' + '/'
165
+ ] ;
166
+ }
167
+
148
168
/**
149
169
* Kills the given process.
150
170
*/
0 commit comments