mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-19 01:05:29 +00:00
Fixed downloading of glslangValidator
This commit is contained in:
parent
41995c3f38
commit
ffa0007c51
1 changed files with 16 additions and 16 deletions
|
@ -1,14 +1,12 @@
|
||||||
import { ConfigProvider } from './config'
|
import * as unzip from 'adm-zip';
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process';
|
||||||
import { extensionMap, ShaderFileExtension } from './fileTypes'
|
import { writeFileSync } from 'fs';
|
||||||
import * as path from 'path'
|
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { platform } from 'os';
|
import { platform } from 'os';
|
||||||
import * as unzip from 'adm-zip'
|
import { ConfigProvider } from './config';
|
||||||
import { createWriteStream } from 'fs'
|
import { extensionMap, ShaderFileExtension } from './fileTypes';
|
||||||
import { writeFileSync, fstat } from 'fs';
|
|
||||||
import { connection } from './server';
|
|
||||||
import { glslProviderLog as log } from './logging';
|
import { glslProviderLog as log } from './logging';
|
||||||
|
import { connection } from './server';
|
||||||
|
|
||||||
|
|
||||||
const url = {
|
const url = {
|
||||||
|
@ -50,12 +48,12 @@ export class GLSLangProvider {
|
||||||
const glslangPath = this._config.config.shaderpacksPath + glslangBin
|
const glslangPath = this._config.config.shaderpacksPath + glslangBin
|
||||||
|
|
||||||
const response = await fetch(url[platform()])
|
const response = await fetch(url[platform()])
|
||||||
|
log.warn(() => 'glslangValidator download response status: ' + response.status )
|
||||||
const zip = new unzip(await response.buffer())
|
const zip = new unzip(await response.buffer())
|
||||||
|
|
||||||
const bin = zip.readFile('bin' + glslangBin)
|
const bin = zip.readFile('bin' + glslangBin)
|
||||||
|
log.warn(() => 'buffer length ' + bin.length)
|
||||||
writeFileSync(glslangPath, bin)
|
writeFileSync(glslangPath, bin, {encoding: null, mode: 0o755})
|
||||||
|
|
||||||
if (!this.testExecutable()) {
|
if (!this.testExecutable()) {
|
||||||
connection.window.showErrorMessage(
|
connection.window.showErrorMessage(
|
||||||
|
@ -79,20 +77,22 @@ export class GLSLangProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public testExecutable(glslangPath?: string): boolean {
|
public testExecutable(glslangPath?: string): boolean {
|
||||||
let success = false
|
let stdout = ''
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(glslangPath || this._config.config.glslangValidatorPath, {
|
stdout = execSync(glslangPath || this._config.config.glslangValidatorPath, {
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
}).toString()
|
}).toString()
|
||||||
success = stdout.startsWith('Usage')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
success = (e.stdout.toString() as string).startsWith('Usage')
|
stdout = (e.stdout.toString() as string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.warn(() => 'glslangValidator first line stdout: ' + stdout.split('\n')[0])
|
||||||
|
const success = stdout.startsWith('Usage')
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
log.info(() => `glslangValidator found at ${this._config.config.glslangValidatorPath}`)
|
log.info(() => `glslangValidator found at ${this._config.config.glslangValidatorPath}`)
|
||||||
} else {
|
} else {
|
||||||
log.error(() => `glslangValidator not found at ${this._config.config.glslangValidatorPath}`, null)
|
log.warn(() => `glslangValidator not found at ${this._config.config.glslangValidatorPath}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return success
|
return success
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue