Skip to content

Commit

Permalink
Cleaning the platform-specific package targets
Browse files Browse the repository at this point in the history
  • Loading branch information
racz16 committed Nov 23, 2023
1 parent ee931ee commit 44496d1
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 53 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/build-and-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,14 @@ jobs:
include:
- os: windows-latest
command: package-win32-x64
- os: windows-latest
command: package-win32-ia32
- os: windows-latest
command: package-win32-arm64
- os: ubuntu-latest
command: package-linux-x64
- os: ubuntu-latest
command: package-linux-arm64
- os: ubuntu-latest
command: package-linux-armhf
- os: ubuntu-latest
command: package-alpine-x64
- os: ubuntu-latest
command: package-alpine-arm64
- os: macos-latest
command: package-darwin-x64
- os: macos-latest
command: package-darwin-arm64
- os: ubuntu-latest
command: package-web
- os: ubuntu-latest
command: package-universal
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -53,5 +41,7 @@ jobs:
run: npm run markdownlint
- name: Prettier lint
run: npm run prettier-lint
- name: Build in production mode
run: npm run build-production
- name: Package
run: npm run ${{ matrix.command }}
18 changes: 4 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,18 @@ jobs:
- name: Generate Antlr parser
run: npx antlr4ts -o "../src/_generated" -no-listener -visitor "AntlrGlslParser.g4"
working-directory: ./syntaxes
- name: Build in production mode
run: npm run build-production
- name: Package universal
run: npm run package-universal
- name: Package to web
run: npm run package-web
- name: Package to win32-x64
run: npm run package-win32-x64
- name: Package to win32-ia32
run: npm run package-win32-ia32
- name: Package to win32-arm64
run: npm run package-win32-arm64
- name: Package to darwin-x64
run: npm run package-darwin-x64
- name: Package to darwin-arm64
run: npm run package-darwin-arm64
- name: Package to linux-x64
run: npm run package-linux-x64
- name: Package to linux-arm64
run: npm run package-linux-arm64
- name: Package to linux-armhf
run: npm run package-linux-armhf
- name: Package to alpine-x64
run: npm run package-alpine-x64
- name: Package to alpine-arm64
run: npm run package-alpine-arm64
- name: Publish
run: npx vsce publish --packagePath $(find . -type f -name "*.vsix" | paste -sd " ")
env:
Expand Down
35 changes: 35 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# folder
.github
.husky
.vscode
.vscode-test
.vscode-test-web
node_modules
private
res/gif
res/png/screenshots
src
syntaxes/.antlr

# file
.editorconfig
.eslintrc.js
.gitattributes
.gitignore
.markdownlint.json
.prettierignore
.prettierrc.json
BUILD.md
package-lock.json
tsconfig.json
webpack.config.js

# file type
**/*.ps1
**/*.sh
**/*.vscodeignore
**/*.g4
**/*.map

# universal ignore
res/bin
16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
{
"command": "webgl-glsl-editor.generatepreprocessed",
"title": "Generate preprocessed GLSL source code",
"enablement": "!isWeb && editorLangId == glsl && resourceExtname != .glsl && !editorReadonly",
"enablement": "!isWeb && editorLangId == glsl && resourceExtname != .glsl && !editorReadonly && webgl-glsl-editor.canRunCompiler",
"icon": "$(open-preview)"
}
],
Expand All @@ -129,7 +129,7 @@
{
"command": "webgl-glsl-editor.generatepreprocessed",
"group": "navigation",
"when": "!isWeb && editorLangId == glsl && resourceExtname != .glsl && !editorReadonly"
"when": "!isWeb && editorLangId == glsl && resourceExtname != .glsl && !editorReadonly && webgl-glsl-editor.canRunCompiler"
}
]
},
Expand Down Expand Up @@ -305,7 +305,7 @@
]
},
"scripts": {
"vscode:prepublish": "webpack --mode production",
"build-production": "webpack --mode production",
"build": "webpack",
"watch": "webpack --watch",
"compile-antlr-windows": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./compile-antlr.ps1",
Expand All @@ -315,18 +315,12 @@
"prettier-format": "prettier --write .",
"eslint": "eslint ./src --ext .ts --ignore-pattern src/_generated",
"run-in-browser": "vscode-test-web --extensionDevelopmentPath=. .",
"package-universal": "vsce package",
"package-web": "vsce package --target web --ignoreFile web.vscodeignore",
"package-win32-x64": "vsce package --target win32-x64 --ignoreFile windows.vscodeignore",
"package-win32-ia32": "vsce package --target win32-ia32 --ignoreFile windows.vscodeignore",
"package-win32-arm64": "vsce package --target win32-arm64 --ignoreFile windows.vscodeignore",
"package-darwin-x64": "vsce package --target darwin-x64 --ignoreFile mac.vscodeignore",
"package-darwin-arm64": "vsce package --target darwin-arm64 --ignoreFile mac.vscodeignore",
"package-linux-x64": "vsce package --target linux-x64 --ignoreFile linux.vscodeignore",
"package-linux-arm64": "vsce package --target linux-arm64 --ignoreFile linux.vscodeignore",
"package-linux-armhf": "vsce package --target linux-armhf --ignoreFile linux.vscodeignore",
"package-alpine-x64": "vsce package --target alpine-x64 --ignoreFile linux.vscodeignore",
"package-alpine-arm64": "vsce package --target alpine-arm64 --ignoreFile linux.vscodeignore",
"package": "start npm run package-web && start npm run package-win32-x64 && start npm run package-win32-ia32 && start npm run package-win32-arm64 && start npm run package-darwin-x64 && start npm run package-darwin-arm64 && start npm run package-linux-x64 && start npm run package-linux-arm64 && start npm run package-linux-armhf && start npm run package-alpine-x64 && start npm run package-alpine-arm64",
"package-all": "start npm run package-universal && start npm run package-web && start npm run package-win32-x64 && start npm run package-darwin-x64 && start npm run package-linux-x64",
"prepare": "husky install"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class Constants {

public static readonly PREPROCESSED_GLSL = 'webgl-glsl-editor-preprocessed';

public static readonly CAN_RUN_COMPILER_CONTEXT = `${Constants.EXTENSION_NAME}.canRunCompiler`;

public static readonly VEC3 = 'vec3';
public static readonly VEC4 = 'vec4';
public static readonly BOOL = 'bool';
Expand Down
15 changes: 13 additions & 2 deletions src/extension-desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import { ExtensionContext, languages, window, workspace } from 'vscode';
import { Documentation } from './builtin/documentation';
import { Constants } from './core/constants';
import { GlslEditor } from './core/glsl-editor';
import { addSharedCommands, addSharedFeatures, selector } from './extension';
import { addSharedCommands, addSharedFeatures, selector, setContext } from './extension';
import { HostDependent } from './host-dependent';
import { GlslDiagnosticProvider } from './providers/glsl-diagnostic-provider';
import { GlslFileDecorationProvider } from './providers/glsl-file-decoration-provider';
import { GlslInjectionErrorProvider } from './providers/glsl-injection-error-provider';
import { GlslTextProvider } from './providers/glsl-text-provider';

export function activate(context: ExtensionContext): void {
import * as os from 'os';

export async function activate(context: ExtensionContext): Promise<void> {
GlslEditor.initialize(context);
await setContext(Constants.CAN_RUN_COMPILER_CONTEXT, canRunCompiler());
addHostDependentCode();
addDiagnostic(context);
addSharedCommands(context);
Expand All @@ -26,6 +29,9 @@ function addHostDependentCode(): void {
}

function addDiagnostic(context: ExtensionContext): void {
if (!canRunCompiler()) {
return;
}
//diagnostic
for (const editor of window.visibleTextEditors) {
if (editor.document.languageId === Constants.GLSL) {
Expand Down Expand Up @@ -67,3 +73,8 @@ function addFeatures(context: ExtensionContext): void {
);
window.registerFileDecorationProvider(new GlslFileDecorationProvider());
}

export function canRunCompiler(): boolean {
const platform = os.platform();
return (platform === 'win32' || platform === 'darwin' || platform === 'linux') && os.arch() === 'x64';
}
6 changes: 4 additions & 2 deletions src/extension-web.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ExtensionContext } from 'vscode';
import { Constants } from './core/constants';
import { GlslEditor } from './core/glsl-editor';
import { addSharedCommands, addSharedFeatures } from './extension';
import { addSharedCommands, addSharedFeatures, setContext } from './extension';
import { HostDependent } from './host-dependent';

export function activate(context: ExtensionContext): void {
export async function activate(context: ExtensionContext): Promise<void> {
GlslEditor.initialize(context);
HostDependent.webExtension = true;
await setContext(Constants.CAN_RUN_COMPILER_CONTEXT, false);
addSharedCommands(context);
addSharedFeatures(context);
}
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ export function addSharedFeatures(context: ExtensionContext): void {
//inlay hints
context.subscriptions.push(languages.registerInlayHintsProvider(selector, new GlslInlayHintsProvider()));
}

export async function setContext<T>(name: string, value: T): Promise<void> {
await commands.executeCommand('setContext', name, value);
}
11 changes: 1 addition & 10 deletions src/providers/glsl-command-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Disposable, Uri, ViewColumn, WebviewPanel, env, window } from 'vscode';
import { Constants } from '../core/constants';
import { GlslEditor } from '../core/glsl-editor';
import { HostDependent } from '../host-dependent';

Expand Down Expand Up @@ -36,15 +35,7 @@ export class GlslCommandProvider {

public static openPreprocessedGlsl(): void {
const doc = window.activeTextEditor.document;
if (doc?.languageId !== Constants.GLSL) {
window.showWarningMessage('The active file has to be a GLSL file.');
} else if (HostDependent.webExtension) {
window.showWarningMessage(
"The web extension can't generate preprocessed GLSL source code. Try it with the desktop version."
);
} else {
HostDependent.displayPreprocessedCode(doc);
}
HostDependent.displayPreprocessedCode(doc);
}

private static openOfflineDoc(name: string): void {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 44496d1

Please sign in to comment.