Skip to content

Commit

Permalink
Merge pull request #41 from hsimpson/feature/38-stop-extension-from-w…
Browse files Browse the repository at this point in the history
…riting-spir-v-fi

38 Stop extension from writing spir-v files on save
  • Loading branch information
hsimpson authored Jan 6, 2022
2 parents 03c60dd + d547c05 commit 9bbb91b
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 110 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist
node_modules
test/test_shaders/restricted/
*.vsix

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to the "vscode-glsllint" extension will be documented in thi

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [1.7.x]

### Added

- Save SPIR-V files to $TEMP [#38](https://github.com/hsimpson/vscode-glsllint/issues/38)

## [1.6.x]

### Added
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-glsllint",
"version": "1.6.0",
"version": "1.7.0",
"publisher": "dtoplak",
"repository": {
"type": "git",
Expand Down Expand Up @@ -154,25 +154,25 @@
"test": "webpack --config ./webpack.config.ts --mode production && node ./node_modules/vscode/bin/test"
},
"devDependencies": {
"@types/node": "^16.11.7",
"@types/node": "^17.0.8",
"@types/vscode": "1.38.0",
"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@typescript-eslint/typescript-estree": "^5.4.0",
"eslint": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"@typescript-eslint/typescript-estree": "^5.9.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"prettier": "^2.5.1",
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"vsce": "^2.3.0",
"vsce": "^2.6.3",
"vscode-test": "^1.6.1",
"webpack": "^5.64.1",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
},
"dependencies": {
"glslify": "^7.1.1",
"typescript": "^4.5.2"
"typescript": "^4.5.4"
}
}
16 changes: 13 additions & 3 deletions src/features/glsllintProvider.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as child_process from 'child_process';
import * as vscode from 'vscode';
import * as path from 'path';
import * as fs from 'fs';
import * as glslify from 'glslify';
import * as os from 'os';
import * as path from 'path';
import * as ts from 'typescript';
import * as vscode from 'vscode';
import { GLSLifyProvider } from './glslifyProvider';
import { GLSLifyUriMapper } from './glslifyUriMapper';
import * as ts from 'typescript';
import { stageExpressions } from './glslStageExpression';

enum glslValidatorFailCodes {
Expand Down Expand Up @@ -433,13 +435,16 @@ export class GLSLLintingProvider {

// Split the arguments string from the settings
const args = this.config.glslangValidatorArgs.split(/\s+/).filter((arg) => arg);
const tempFile = path.join(os.tmpdir(), `vscode-glsllint-${stage}.tmp`);

if (this.config.linkShader) {
args.push('-l');
}
args.push('--stdin');
args.push('-S');
args.push(stage);
args.push('-o');
args.push(tempFile);

if (this.config.useIncludeDirOfFile && includePath && includePath !== '') {
args.push(`-I${includePath}`);
Expand All @@ -448,6 +453,8 @@ export class GLSLLintingProvider {
// FIXME: use workspaceFolders instead of rootPath
const options = vscode.workspace.rootPath ? { cwd: vscode.workspace.rootPath } : undefined;

console.log(`${glslangValidatorPath} ${args.join(' ')}`);

const childProcess = child_process.spawn(glslangValidatorPath, args, options);
childProcess.on('error', (error: Error) => {
if (error) {
Expand Down Expand Up @@ -500,6 +507,9 @@ export class GLSLLintingProvider {
}
}
}
if (fs.existsSync(tempFile)) {
fs.unlinkSync(tempFile);
}
resolve(diagnostics);
});

Expand Down
4 changes: 3 additions & 1 deletion test/test_shaders/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
"glsllint.glslifyOptions": {
// "basedir": "G:\\src\\vscodeextensions\\vscode-glsllint\\test\\test_shaders\\GLSLIFY\\chunks"
},
"glsllint.glslifyUseCurrentFileAsBasedir": true
"glsllint.glslangValidatorArgs": "--target-env vulkan1.1",
"glsllint.glslifyUseCurrentFileAsBasedir": true,
"glsllint.linkShader": false
}
Loading

0 comments on commit 9bbb91b

Please sign in to comment.