@@ -15,34 +15,34 @@ import { CppSettings } from './settings';
15
15
nls . config ( { messageFormat : nls . MessageFormat . bundle , bundleFormat : nls . BundleFormat . standalone } ) ( ) ;
16
16
const localize : nls . LocalizeFunc = nls . loadMessageBundle ( ) ;
17
17
18
- const ERROR_NO_CONTEXT = localize ( 'no.context.provided' , 'No context provided' ) ;
19
- const ERROR_NOT_WINDOWS = localize ( 'not.windows' , 'This command is only available on Windows' ) ;
20
- const ERROR_NO_VS_FOUND = localize ( 'error.no.vs' , 'A Visual Studio installation with the C++ compiler was not found' ) ;
21
- const ERROR_OPERATION_CANCELLED = localize ( 'operation.cancelled' , 'The operation was cancelled' ) ;
22
- const ERROR_NO_HOSTS_FOUND = localize ( 'no.hosts' , 'No hosts found' ) ;
23
- const CONFIGURING_DEV_ENV = localize ( 'config.dev.env' , 'Configuring Developer Environment...' ) ;
24
- const SELECT_VS_INSTALLATION = localize ( 'select.vs.install' , 'Select a Visual Studio installation' ) ;
25
- const ADVANCED_OPTIONS = localize ( 'advanced.options' , 'Advanced options...' ) ;
26
- const ADVANCED_OPTIONS_DESCRIPTION = localize ( 'advanced.options.desc' , 'Select a specific host/target architecture, toolset version, etc.' ) ;
27
- const SELECT_TOOLSET_VERSION = localize ( 'select.toolset' , 'Select a toolset version' ) ;
28
- const SELECT_HOST_TARGET_ARCH = localize ( 'select.host.target' , 'Select a host and target architecture' ) ;
18
+ const errorNoContext = localize ( 'no.context.provided' , 'No context provided' ) ;
19
+ const errorNotWindows = localize ( 'not.windows' , 'This command is only available on Windows' ) ;
20
+ const errorNoVSFound = localize ( 'error.no.vs' , 'A Visual Studio installation with the C++ compiler was not found' ) ;
21
+ const errorOperationCancelled = localize ( 'operation.cancelled' , 'The operation was cancelled' ) ;
22
+ const errorNoHostsFound = localize ( 'no.hosts' , 'No hosts found' ) ;
23
+ const configuringDevEnv = localize ( 'config.dev.env' , 'Configuring Developer Environment...' ) ;
24
+ const selectVSInstallation = localize ( 'select.vs.install' , 'Select a Visual Studio installation' ) ;
25
+ const advancedOptions = localize ( 'advanced.options' , 'Advanced options...' ) ;
26
+ const advancedOptionsDescription = localize ( 'advanced.options.desc' , 'Select a specific host/target architecture, toolset version, etc.' ) ;
27
+ const selectToolsetVersion = localize ( 'select.toolset' , 'Select a toolset version' ) ;
28
+ const selectHostTargetArch = localize ( 'select.host.target' , 'Select a host and target architecture' ) ;
29
29
30
30
export function isEnvironmentOverrideApplied ( context ?: vscode . ExtensionContext ) {
31
31
return context ?. environmentVariableCollection . get ( 'VCToolsInstallDir' ) !== undefined ;
32
32
}
33
33
34
34
export async function setEnvironment ( context ?: vscode . ExtensionContext ) {
35
35
if ( ! isWindows ) {
36
- throw new Error ( ERROR_NOT_WINDOWS ) ;
36
+ throw new Error ( errorNotWindows ) ;
37
37
}
38
38
39
39
if ( ! context ) {
40
- throw new Error ( ERROR_NO_CONTEXT ) ;
40
+ throw new Error ( errorNoContext ) ;
41
41
}
42
42
43
43
const vses = await getVSInstallations ( ) ;
44
44
if ( ! vses ) {
45
- throw new Error ( ERROR_NO_VS_FOUND ) ;
45
+ throw new Error ( errorNoVSFound ) ;
46
46
}
47
47
48
48
let vs = await chooseVSInstallation ( vses ) ;
@@ -55,7 +55,7 @@ export async function setEnvironment(context?: vscode.ExtensionContext) {
55
55
const vars = await vscode . window . withProgress ( {
56
56
cancellable : false ,
57
57
location : vscode . ProgressLocation . Notification ,
58
- title : CONFIGURING_DEV_ENV
58
+ title : configuringDevEnv
59
59
} , ( ) => vcvars . getVCVars ( vs , options ) ) ;
60
60
61
61
if ( ! vars || ! vars [ 'INCLUDE' ] ) {
@@ -89,7 +89,7 @@ async function getVSInstallations() {
89
89
} ) ;
90
90
91
91
if ( installations . length === 0 ) {
92
- throw new Error ( ERROR_NO_VS_FOUND ) ;
92
+ throw new Error ( errorNoVSFound ) ;
93
93
}
94
94
return installations ;
95
95
}
@@ -100,34 +100,34 @@ async function chooseVSInstallation(installations: vswhere.Installation[]): Prom
100
100
description : localize ( 'default.settings' , 'Default settings for {0}' , installation . displayName )
101
101
} ) ;
102
102
items . push ( {
103
- label : ADVANCED_OPTIONS ,
104
- description : ADVANCED_OPTIONS_DESCRIPTION
103
+ label : advancedOptions ,
104
+ description : advancedOptionsDescription
105
105
} ) ;
106
106
const selection = await vscode . window . showQuickPick ( items , {
107
- placeHolder : SELECT_VS_INSTALLATION
107
+ placeHolder : selectVSInstallation
108
108
} ) ;
109
109
if ( ! selection ) {
110
- throw new Error ( ERROR_OPERATION_CANCELLED ) ;
110
+ throw new Error ( errorOperationCancelled ) ;
111
111
}
112
112
113
113
return installations . find ( installation => installation . displayName === selection . label ) ;
114
114
}
115
115
116
+ interface Compiler {
117
+ version : string ;
118
+ vs : vswhere . Installation ;
119
+ options : vcvars . Options ;
120
+ }
121
+
116
122
async function getAdvancedConfiguration ( vses : vswhere . Installation [ ] ) : Promise < Compiler > {
117
123
const compiler = await chooseCompiler ( vses ) ;
118
124
if ( ! compiler ) {
119
- throw new Error ( ERROR_OPERATION_CANCELLED ) ;
125
+ throw new Error ( errorOperationCancelled ) ;
120
126
}
121
127
await setOptions ( compiler ) ;
122
128
return compiler ;
123
129
}
124
130
125
- interface Compiler {
126
- version : string ;
127
- vs : vswhere . Installation ;
128
- options : vcvars . Options ;
129
- }
130
-
131
131
async function chooseCompiler ( vses : vswhere . Installation [ ] ) : Promise < Compiler | undefined > {
132
132
const compilers : Compiler [ ] = [ ] ;
133
133
for ( const vs of vses ) {
@@ -146,10 +146,10 @@ async function chooseCompiler(vses: vswhere.Installation[]): Promise<Compiler |
146
146
description : compiler . vs . displayName
147
147
} ) ;
148
148
const selection = await vscode . window . showQuickPick ( items , {
149
- placeHolder : SELECT_TOOLSET_VERSION
149
+ placeHolder : selectToolsetVersion
150
150
} ) ;
151
151
if ( ! selection ) {
152
- throw new Error ( ERROR_OPERATION_CANCELLED ) ;
152
+ throw new Error ( errorOperationCancelled ) ;
153
153
}
154
154
return compilers . find ( compiler => compiler . version === selection . label && compiler . vs . displayName === selection . description ) ;
155
155
}
@@ -163,10 +163,10 @@ async function setOptions(compiler: Compiler): Promise<void> {
163
163
description : localize ( 'host.target' , 'host = {0}, target = {1}' , ht . host , ht . target )
164
164
} ) ;
165
165
const selection = await vscode . window . showQuickPick ( items , {
166
- placeHolder : SELECT_HOST_TARGET_ARCH
166
+ placeHolder : selectHostTargetArch
167
167
} ) ;
168
168
if ( ! selection ) {
169
- throw new Error ( ERROR_OPERATION_CANCELLED ) ;
169
+ throw new Error ( errorOperationCancelled ) ;
170
170
}
171
171
compiler . options . arch = < vcvars . Architecture > selection . label ;
172
172
}
@@ -175,7 +175,7 @@ async function setOptions(compiler: Compiler): Promise<void> {
175
175
async function getHostsAndTargets ( vcPath : string ) : Promise < vcvars . HostTarget [ ] > {
176
176
const hosts = await fs . readdir ( vcPath ) ;
177
177
if ( hosts . length === 0 ) {
178
- throw new Error ( ERROR_NO_HOSTS_FOUND ) ;
178
+ throw new Error ( errorNoHostsFound ) ;
179
179
}
180
180
const hostTargets : vcvars . HostTarget [ ] = [ ] ;
181
181
for ( const host of hosts ) {
@@ -195,9 +195,6 @@ async function getHostsAndTargets(vcPath: string): Promise<vcvars.HostTarget[]>
195
195
return hostTargets ;
196
196
}
197
197
198
- export function deactivate ( ) {
199
- }
200
-
201
198
function match < T > ( item : string , cases : { [ key : string ] : T } ) : T | undefined {
202
199
return cases [ item ] ;
203
200
}
0 commit comments