@@ -36,9 +36,10 @@ export function isRunningOnWeb() : boolean {
3636 // Web environment is detected with no fallback on child process which is not supported there.
3737 return typeof cp . spawn !== 'function' || typeof process === 'undefined' ;
3838}
39- function getServerVersion ( serverPath : string ) : string | null {
40- if ( isRunningOnWeb ( ) ) {
39+ function getServerVersion ( serverPath : string , platform : ServerPlatform ) : string | null {
40+ if ( isRunningOnWeb ( ) || platform === ServerPlatform . wasi ) {
4141 // Bundled version always used on the web as we cant access external folders.
42+ // For wasi, we need some runner to test version & we cant do this here. So ignore check.
4243 return "shader-language-server v" + vscode . extensions . getExtension ( 'antaalt.shader-validator' ) ! . packageJSON . server_version ;
4344 } else {
4445 if ( fs . existsSync ( serverPath ) ) {
@@ -55,14 +56,14 @@ function isValidVersion(serverVersion: string) {
5556 const versionExpected = "shader-language-server v" + requestedServerVersion ;
5657 return serverVersion === versionExpected ;
5758}
58- function getUserServerPath ( ) : string | null {
59+ function getUserServerPath ( platform : ServerPlatform ) : string | null {
5960 if ( isRunningOnWeb ( ) ) {
6061 return null ;
6162 } else {
6263 // Check configuration.
6364 let serverPath = vscode . workspace . getConfiguration ( "shader-validator" ) . get < string > ( "serverPath" ) ;
6465 if ( serverPath && serverPath . length > 0 ) {
65- let serverVersion = getServerVersion ( serverPath ) ;
66+ let serverVersion = getServerVersion ( serverPath , platform ) ;
6667 if ( serverVersion ) {
6768 console . info ( `shader-validator.serverPath found: ${ serverPath } ` ) ;
6869 return serverPath ;
@@ -73,7 +74,7 @@ function getUserServerPath() : string | null {
7374 // Check environment variables
7475 if ( process . env . SHADER_LANGUAGE_SERVER_EXECUTABLE_PATH !== undefined ) {
7576 let envPath = process . env . SHADER_LANGUAGE_SERVER_EXECUTABLE_PATH ;
76- let serverVersion = getServerVersion ( envPath ) ;
77+ let serverVersion = getServerVersion ( envPath , platform ) ;
7778 if ( serverVersion ) {
7879 console . info ( `SHADER_LANGUAGE_SERVER_EXECUTABLE_PATH found: ${ envPath } ` ) ;
7980 return envPath ;
@@ -87,7 +88,7 @@ function getUserServerPath() : string | null {
8788 }
8889}
8990function getPlatformBinaryDirectoryPath ( extensionUri : vscode . Uri , platform : ServerPlatform ) : vscode . Uri {
90- let serverPath = getUserServerPath ( ) ;
91+ let serverPath = getUserServerPath ( platform ) ;
9192 if ( serverPath ) {
9293 return vscode . Uri . file ( path . dirname ( serverPath ) ) ;
9394 } else {
@@ -103,7 +104,7 @@ function getPlatformBinaryDirectoryPath(extensionUri: vscode.Uri, platform: Serv
103104 }
104105}
105106function getPlatformBinaryName ( platform : ServerPlatform ) : string {
106- let serverPath = getUserServerPath ( ) ;
107+ let serverPath = getUserServerPath ( platform ) ;
107108 if ( serverPath ) {
108109 return path . basename ( serverPath ) ;
109110 } else {
@@ -205,7 +206,7 @@ async function createLanguageClientStandard(context: vscode.ExtensionContext, pl
205206 context . subscriptions . push ( channel ) ;
206207
207208 const executable = getPlatformBinaryUri ( context . extensionUri , platform ) ;
208- const version = getServerVersion ( executable . fsPath ) ;
209+ const version = getServerVersion ( executable . fsPath , platform ) ;
209210 if ( ! version ) {
210211 vscode . window . showErrorMessage ( `Server executable not found.` ) ;
211212 return null ;
@@ -273,9 +274,9 @@ async function createLanguageClientWASI(context: vscode.ExtensionContext) : Prom
273274 // So we can use VS Code's file system API to load it. Makes it
274275 // independent of whether the code runs in the desktop or the web.
275276 const executable = getPlatformBinaryUri ( context . extensionUri , ServerPlatform . wasi ) ;
276- const version = getServerVersion ( executable . fsPath ) ;
277+ const version = getServerVersion ( executable . fsPath , ServerPlatform . wasi ) ;
277278 if ( ! version ) {
278- vscode . window . showErrorMessage ( `Server executable not found.` ) ;
279+ vscode . window . showErrorMessage ( `WASI server not found.` ) ;
279280 return null ;
280281 }
281282 if ( ! isValidVersion ( version ) ) {
0 commit comments