mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 15:32:05 +00:00
Perfect the codebase for wamr-ide (#1817)
Fix errors and warnings reported by eslint Add CONTRIBUTING document for vscode-extension
This commit is contained in:
parent
676c3c7b04
commit
679a8ab3cb
|
@ -1,13 +1,12 @@
|
||||||
{
|
{
|
||||||
"root": true,
|
"root": true,
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"extends": ["plugin:@typescript-eslint/recommended"],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 6,
|
"ecmaVersion": "latest",
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": ["@typescript-eslint"],
|
||||||
"@typescript-eslint"
|
|
||||||
],
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/naming-convention": "warn",
|
"@typescript-eslint/naming-convention": "warn",
|
||||||
"@typescript-eslint/semi": "warn",
|
"@typescript-eslint/semi": "warn",
|
||||||
|
@ -16,9 +15,5 @@
|
||||||
"no-throw-literal": "warn",
|
"no-throw-literal": "warn",
|
||||||
"semi": "off"
|
"semi": "off"
|
||||||
},
|
},
|
||||||
"ignorePatterns": [
|
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
|
||||||
"out",
|
|
||||||
"dist",
|
|
||||||
"**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
34
test-tools/wamr-ide/VSCode-Extension/CONTRIBUTING.md
Normal file
34
test-tools/wamr-ide/VSCode-Extension/CONTRIBUTING.md
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# CONTRIBUTING
|
||||||
|
|
||||||
|
## Pull requests
|
||||||
|
|
||||||
|
To submit your change:
|
||||||
|
|
||||||
|
- Make sure your code is in line with our
|
||||||
|
[coding conventions](##Coding-conventions).
|
||||||
|
- Create an [issue] describing the bug the PR fixes or the feature you intend
|
||||||
|
to implement.
|
||||||
|
- Submit a [pull request] into the main branch.
|
||||||
|
|
||||||
|
## Coding conventions
|
||||||
|
|
||||||
|
#### Format
|
||||||
|
|
||||||
|
The codebase is formatted by `Prettier` and the `.prettierrc.json` has been
|
||||||
|
configured.
|
||||||
|
|
||||||
|
- VSCode along with `Format on Save` configuration could easily format your
|
||||||
|
code during development.
|
||||||
|
- You can run `prettier-format-check` and `prettier-format-apply` to check and
|
||||||
|
format your codebase with `prettier` in terminal.
|
||||||
|
|
||||||
|
#### Lint
|
||||||
|
|
||||||
|
`ESlint` is used as linter for the codebase and the `.eslintrc.json` has been
|
||||||
|
configured.
|
||||||
|
|
||||||
|
- It's suggested to run `npm run lint` then fix errors and warnings before
|
||||||
|
committing.
|
||||||
|
|
||||||
|
[issue]: https://github.com/bytecodealliance/wasm-micro-runtime/issues
|
||||||
|
[pull request]: https://github.com/bytecodealliance/wasm-micro-runtime/pulls
|
|
@ -229,6 +229,7 @@
|
||||||
"watch": "tsc -watch -p ./",
|
"watch": "tsc -watch -p ./",
|
||||||
"pretest": "npm run compile && npm run lint",
|
"pretest": "npm run compile && npm run lint",
|
||||||
"lint": "eslint src --ext ts",
|
"lint": "eslint src --ext ts",
|
||||||
|
"lint-fix": "eslint --fix src --ext ts",
|
||||||
"test": "node ./out/test/runTest.js",
|
"test": "node ./out/test/runTest.js",
|
||||||
"prettier-format-check": "prettier --config .prettierrc.json 'src/**/*.ts' --check",
|
"prettier-format-check": "prettier --config .prettierrc.json 'src/**/*.ts' --check",
|
||||||
"prettier-format-apply": "prettier --config .prettierrc.json 'src/**/*.ts' --write"
|
"prettier-format-apply": "prettier --config .prettierrc.json 'src/**/*.ts' --write"
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const vscode = acquireVsCodeApi();
|
const vscode = acquireVsCodeApi();
|
||||||
|
|
||||||
document.getElementById('btn_submit').onclick = () => {
|
document.getElementById('btn_submit').onclick = () => {
|
||||||
|
@ -12,16 +11,16 @@ document.getElementById('btn_submit').onclick = () => {
|
||||||
|
|
||||||
function submitFunc() {
|
function submitFunc() {
|
||||||
let outputFileName = document.getElementById('output_file_name').value;
|
let outputFileName = document.getElementById('output_file_name').value;
|
||||||
let initmemSize = document.getElementById('initial_mem_size').value;
|
let initMemSize = document.getElementById('initial_mem_size').value;
|
||||||
let maxmemSize = document.getElementById('max_mem_size').value;
|
let maxMemSize = document.getElementById('max_mem_size').value;
|
||||||
let stackSize = document.getElementById('stack_size').value;
|
let stackSize = document.getElementById('stack_size').value;
|
||||||
let exportedSymbols = document.getElementById('exported_symbols').value;
|
let exportedSymbols = document.getElementById('exported_symbols').value;
|
||||||
|
|
||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
command: 'config_build_target',
|
command: 'config_build_target',
|
||||||
outputFileName: outputFileName,
|
outputFileName: outputFileName,
|
||||||
initmemSize: initmemSize,
|
initMemSize: initMemSize,
|
||||||
maxmemSize: maxmemSize,
|
maxMemSize: maxMemSize,
|
||||||
stackSize: stackSize,
|
stackSize: stackSize,
|
||||||
exportedSymbols: exportedSymbols,
|
exportedSymbols: exportedSymbols,
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,8 +9,6 @@ import * as os from 'os';
|
||||||
export class WasmDebugConfigurationProvider
|
export class WasmDebugConfigurationProvider
|
||||||
implements vscode.DebugConfigurationProvider
|
implements vscode.DebugConfigurationProvider
|
||||||
{
|
{
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
/* default port set as 1234 */
|
/* default port set as 1234 */
|
||||||
private port = 1234;
|
private port = 1234;
|
||||||
private hostPath!: string;
|
private hostPath!: string;
|
||||||
|
@ -29,7 +27,7 @@ export class WasmDebugConfigurationProvider
|
||||||
return this.providerPromise;
|
return this.providerPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setDebugConfig(hostPath: string, port: number) {
|
public setDebugConfig(hostPath: string, port: number): void {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.hostPath = hostPath;
|
this.hostPath = hostPath;
|
||||||
/* linux and windows has different debug configuration */
|
/* linux and windows has different debug configuration */
|
||||||
|
@ -57,7 +55,7 @@ export class WasmDebugConfigurationProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDebugConfig() {
|
public getDebugConfig(): vscode.DebugConfiguration {
|
||||||
return this.wasmDebugConfig;
|
return this.wasmDebugConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,11 @@ export class DecorationProvider implements vscode.FileDecorationProvider {
|
||||||
public onDidChangeFileDecorations: vscode.Event<
|
public onDidChangeFileDecorations: vscode.Event<
|
||||||
vscode.Uri | vscode.Uri[] | undefined
|
vscode.Uri | vscode.Uri[] | undefined
|
||||||
>;
|
>;
|
||||||
private _eventEmiter: vscode.EventEmitter<vscode.Uri | vscode.Uri[]>;
|
private eventEmitter: vscode.EventEmitter<vscode.Uri | vscode.Uri[]>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._eventEmiter = new vscode.EventEmitter();
|
this.eventEmitter = new vscode.EventEmitter();
|
||||||
this.onDidChangeFileDecorations = this._eventEmiter.event;
|
this.onDidChangeFileDecorations = this.eventEmitter.event;
|
||||||
this.disposables.push(
|
this.disposables.push(
|
||||||
vscode.window.registerFileDecorationProvider(this)
|
vscode.window.registerFileDecorationProvider(this)
|
||||||
);
|
);
|
||||||
|
@ -39,34 +39,27 @@ export class DecorationProvider implements vscode.FileDecorationProvider {
|
||||||
public provideFileDecoration(
|
public provideFileDecoration(
|
||||||
uri: vscode.Uri
|
uri: vscode.Uri
|
||||||
): vscode.ProviderResult<vscode.FileDecoration> {
|
): vscode.ProviderResult<vscode.FileDecoration> {
|
||||||
let currentPrjDir,
|
const currentPrjDir =
|
||||||
prjConfigDir,
|
|
||||||
configFilePath,
|
|
||||||
configData,
|
|
||||||
includePathArr = new Array(),
|
|
||||||
excludeFileArr = new Array(),
|
|
||||||
pathRelative;
|
|
||||||
|
|
||||||
/* Read include_paths and exclude_fils from the config file */
|
|
||||||
currentPrjDir =
|
|
||||||
os.platform() === 'win32'
|
os.platform() === 'win32'
|
||||||
? (vscode.workspace.workspaceFolders?.[0].uri.fsPath as string)
|
? (vscode.workspace.workspaceFolders?.[0].uri.fsPath as string)
|
||||||
: os.platform() === 'linux' || os.platform() === 'darwin'
|
: os.platform() === 'linux' || os.platform() === 'darwin'
|
||||||
? (currentPrjDir = vscode.workspace.workspaceFolders?.[0].uri
|
? (vscode.workspace.workspaceFolders?.[0].uri.path as string)
|
||||||
.path as string)
|
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
pathRelative = (uri.fsPath ? uri.fsPath : uri.toString()).replace(
|
const pathRelative = (uri.fsPath ? uri.fsPath : uri.toString()).replace(
|
||||||
currentPrjDir,
|
currentPrjDir,
|
||||||
'..'
|
'..'
|
||||||
);
|
);
|
||||||
|
|
||||||
prjConfigDir = path.join(currentPrjDir, '.wamr');
|
const prjConfigDir = path.join(currentPrjDir, '.wamr');
|
||||||
configFilePath = path.join(prjConfigDir, 'compilation_config.json');
|
const configFilePath = path.join(
|
||||||
|
prjConfigDir,
|
||||||
|
'compilation_config.json'
|
||||||
|
);
|
||||||
if (readFromFile(configFilePath) !== '') {
|
if (readFromFile(configFilePath) !== '') {
|
||||||
configData = JSON.parse(readFromFile(configFilePath));
|
const configData = JSON.parse(readFromFile(configFilePath));
|
||||||
includePathArr = configData['include_paths'];
|
const includePathArr = configData['includePaths'];
|
||||||
excludeFileArr = configData['exclude_files'];
|
const excludeFileArr = configData['excludeFiles'];
|
||||||
|
|
||||||
if (includePathArr.indexOf(pathRelative) > -1) {
|
if (includePathArr.indexOf(pathRelative) > -1) {
|
||||||
return DECORATION_INCLUDE_PATHS;
|
return DECORATION_INCLUDE_PATHS;
|
||||||
|
@ -81,7 +74,7 @@ export class DecorationProvider implements vscode.FileDecorationProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateDecorationsForSource(uri: vscode.Uri): void {
|
public updateDecorationsForSource(uri: vscode.Uri): void {
|
||||||
this._eventEmiter.fire(uri);
|
this.eventEmitter.fire(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,20 @@ import {
|
||||||
|
|
||||||
let wasmTaskProvider: WasmTaskProvider;
|
let wasmTaskProvider: WasmTaskProvider;
|
||||||
let wasmDebugConfigProvider: WasmDebugConfigurationProvider;
|
let wasmDebugConfigProvider: WasmDebugConfigurationProvider;
|
||||||
var currentPrjDir = '';
|
let currentPrjDir = '';
|
||||||
var extensionPath = '';
|
let isWasmProject = false;
|
||||||
var isWasmProject = false;
|
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
export async function activate(context: vscode.ExtensionContext) {
|
export async function activate(context: vscode.ExtensionContext) {
|
||||||
var OS_PLATFORM = '',
|
const extensionPath = context.extensionPath;
|
||||||
buildScript = '',
|
const osPlatform = os.platform();
|
||||||
|
const wamrVersion = getWAMRExtensionVersion(context);
|
||||||
|
const typeMap = new Map<string, string>();
|
||||||
|
const scriptMap = new Map<string, string>();
|
||||||
|
/* set relative path of build.bat|sh script */
|
||||||
|
const scriptPrefix = 'resource/scripts/';
|
||||||
|
|
||||||
|
let buildScript = '',
|
||||||
runScript = '',
|
runScript = '',
|
||||||
debugScript = '',
|
debugScript = '',
|
||||||
destroyScript = '',
|
destroyScript = '',
|
||||||
|
@ -40,40 +47,27 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
runScriptFullPath = '',
|
runScriptFullPath = '',
|
||||||
debugScriptFullPath = '',
|
debugScriptFullPath = '',
|
||||||
destroyScriptFullPath = '',
|
destroyScriptFullPath = '',
|
||||||
typeMap = new Map(),
|
|
||||||
/* include paths array used for written into config file */
|
/* include paths array used for written into config file */
|
||||||
includePathArr = new Array(),
|
includePathArr = new Array<string>(),
|
||||||
/* exclude files array used for written into config file */
|
/* exclude files array used for written into config file */
|
||||||
excludeFileArr = new Array(),
|
excludeFileArr = new Array<string>();
|
||||||
scriptMap = new Map();
|
|
||||||
|
|
||||||
const wamrVersion = getWAMRExtensionVersion(context);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get OS platform information for differ windows and linux execution script
|
|
||||||
*/
|
|
||||||
OS_PLATFORM = os.platform();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide Build & Run Task with Task Provider instead of "tasks.json"
|
* Provide Build & Run Task with Task Provider instead of "tasks.json"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* set relative path of build.bat|sh script */
|
if (osPlatform === 'win32') {
|
||||||
let scriptPrefix = 'resource/scripts/';
|
|
||||||
if (OS_PLATFORM === 'win32') {
|
|
||||||
buildScript = scriptPrefix.concat('build.bat');
|
buildScript = scriptPrefix.concat('build.bat');
|
||||||
runScript = scriptPrefix.concat('run.bat');
|
runScript = scriptPrefix.concat('run.bat');
|
||||||
debugScript = scriptPrefix.concat('boot_debugger_server.bat');
|
debugScript = scriptPrefix.concat('boot_debugger_server.bat');
|
||||||
destroyScript = scriptPrefix.concat('destroy.bat');
|
destroyScript = scriptPrefix.concat('destroy.bat');
|
||||||
} else if (OS_PLATFORM === 'linux' || OS_PLATFORM === 'darwin') {
|
} else if (osPlatform === 'linux' || osPlatform === 'darwin') {
|
||||||
buildScript = scriptPrefix.concat('build.sh');
|
buildScript = scriptPrefix.concat('build.sh');
|
||||||
runScript = scriptPrefix.concat('run.sh');
|
runScript = scriptPrefix.concat('run.sh');
|
||||||
debugScript = scriptPrefix.concat('boot_debugger_server.sh');
|
debugScript = scriptPrefix.concat('boot_debugger_server.sh');
|
||||||
destroyScript = scriptPrefix.concat('destroy.sh');
|
destroyScript = scriptPrefix.concat('destroy.sh');
|
||||||
}
|
}
|
||||||
|
|
||||||
extensionPath = context.extensionPath;
|
|
||||||
|
|
||||||
buildScriptFullPath = path.join(extensionPath, buildScript);
|
buildScriptFullPath = path.join(extensionPath, buildScript);
|
||||||
runScriptFullPath = path.join(extensionPath, runScript);
|
runScriptFullPath = path.join(extensionPath, runScript);
|
||||||
debugScriptFullPath = path.join(extensionPath, debugScript);
|
debugScriptFullPath = path.join(extensionPath, debugScript);
|
||||||
|
@ -94,10 +88,10 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
vscode.tasks.registerTaskProvider('wasm', wasmTaskProvider);
|
vscode.tasks.registerTaskProvider('wasm', wasmTaskProvider);
|
||||||
|
|
||||||
if (vscode.workspace.workspaceFolders?.[0]) {
|
if (vscode.workspace.workspaceFolders?.[0]) {
|
||||||
if (OS_PLATFORM === 'win32') {
|
if (osPlatform === 'win32') {
|
||||||
currentPrjDir = vscode.workspace.workspaceFolders?.[0].uri
|
currentPrjDir = vscode.workspace.workspaceFolders?.[0].uri
|
||||||
.fsPath as string;
|
.fsPath as string;
|
||||||
} else if (OS_PLATFORM === 'linux' || OS_PLATFORM === 'darwin') {
|
} else if (osPlatform === 'linux' || osPlatform === 'darwin') {
|
||||||
currentPrjDir = vscode.workspace.workspaceFolders?.[0].uri
|
currentPrjDir = vscode.workspace.workspaceFolders?.[0].uri
|
||||||
.path as string;
|
.path as string;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +101,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
* it not, `build`, `run` and `debug` will be disabled
|
* it not, `build`, `run` and `debug` will be disabled
|
||||||
*/
|
*/
|
||||||
if (currentPrjDir !== '') {
|
if (currentPrjDir !== '') {
|
||||||
let wamrFolder = fileSystem
|
const wamrFolder = fileSystem
|
||||||
.readdirSync(currentPrjDir, {
|
.readdirSync(currentPrjDir, {
|
||||||
withFileTypes: true,
|
withFileTypes: true,
|
||||||
})
|
})
|
||||||
|
@ -133,7 +127,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
.getConfiguration()
|
.getConfiguration()
|
||||||
.get('C_Cpp.default.systemIncludePath');
|
.get('C_Cpp.default.systemIncludePath');
|
||||||
|
|
||||||
let LibcBuiltinHeaderPath = path.join(
|
const libcBuiltinHeaderPath = path.join(
|
||||||
extensionPath,
|
extensionPath,
|
||||||
'resource/wamr-sdk/libc-builtin-sysroot/include'
|
'resource/wamr-sdk/libc-builtin-sysroot/include'
|
||||||
);
|
);
|
||||||
|
@ -141,17 +135,17 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
if (newIncludeInCppArr !== undefined) {
|
if (newIncludeInCppArr !== undefined) {
|
||||||
/* in case the configuration has not been set up, push directly */
|
/* in case the configuration has not been set up, push directly */
|
||||||
if (newIncludeInCppArr === null) {
|
if (newIncludeInCppArr === null) {
|
||||||
newIncludeInCppArr = new Array();
|
newIncludeInCppArr = [];
|
||||||
newIncludeInCppArr.push(LibcBuiltinHeaderPath);
|
newIncludeInCppArr.push(libcBuiltinHeaderPath);
|
||||||
} else {
|
} else {
|
||||||
/* if the configuration has been set up, check the condition */
|
/* if the configuration has been set up, check the condition */
|
||||||
if (
|
if (
|
||||||
/* include libc-builtin-sysroot */
|
/* include libc-builtin-sysroot */
|
||||||
newIncludeInCppArr.indexOf(
|
newIncludeInCppArr.indexOf(
|
||||||
LibcBuiltinHeaderPath
|
libcBuiltinHeaderPath
|
||||||
) < 0
|
) < 0
|
||||||
) {
|
) {
|
||||||
newIncludeInCppArr.push(LibcBuiltinHeaderPath);
|
newIncludeInCppArr.push(libcBuiltinHeaderPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,21 +179,21 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (readFromConfigFile() !== '') {
|
if (readFromConfigFile() !== '') {
|
||||||
let configData = JSON.parse(readFromConfigFile());
|
const configData = JSON.parse(readFromConfigFile());
|
||||||
includePathArr = configData['include_paths'];
|
includePathArr = configData['includePaths'];
|
||||||
excludeFileArr = configData['exclude_files'];
|
excludeFileArr = configData['excludeFiles'];
|
||||||
|
|
||||||
if (Object.keys(configData['build_args']).length !== 0) {
|
if (Object.keys(configData['buildArgs']).length !== 0) {
|
||||||
TargetConfigPanel.BUILD_ARGS = configData['build_args'];
|
TargetConfigPanel.buildArgs = configData['buildArgs'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let disposableNewProj = vscode.commands.registerCommand(
|
const disposableNewProj = vscode.commands.registerCommand(
|
||||||
'wamride.newProject',
|
'wamride.newProject',
|
||||||
() => {
|
() => {
|
||||||
let _ok = 'Set up now';
|
const okStr = 'Set up now';
|
||||||
let _cancle = 'Maybe later';
|
const cancelStr = 'Maybe later';
|
||||||
let curWorkspace = vscode.workspace
|
const curWorkspace = vscode.workspace
|
||||||
.getConfiguration()
|
.getConfiguration()
|
||||||
.get('WAMR-IDE.configWorkspace');
|
.get('WAMR-IDE.configWorkspace');
|
||||||
|
|
||||||
|
@ -208,11 +202,11 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
vscode.window
|
vscode.window
|
||||||
.showWarningMessage(
|
.showWarningMessage(
|
||||||
'Please setup your workspace firstly.',
|
'Please setup your workspace firstly.',
|
||||||
_ok,
|
okStr,
|
||||||
_cancle
|
cancelStr
|
||||||
)
|
)
|
||||||
.then(item => {
|
.then(item => {
|
||||||
if (item === _ok) {
|
if (item === okStr) {
|
||||||
vscode.commands.executeCommand(
|
vscode.commands.executeCommand(
|
||||||
'wamride.changeWorkspace'
|
'wamride.changeWorkspace'
|
||||||
);
|
);
|
||||||
|
@ -233,10 +227,10 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
.get('WAMR-IDE.configWorkspace') +
|
.get('WAMR-IDE.configWorkspace') +
|
||||||
'',
|
'',
|
||||||
},
|
},
|
||||||
_ok
|
okStr
|
||||||
)
|
)
|
||||||
.then(item => {
|
.then(item => {
|
||||||
if (item === _ok) {
|
if (item === okStr) {
|
||||||
vscode.commands.executeCommand(
|
vscode.commands.executeCommand(
|
||||||
'wamride.changeWorkspace'
|
'wamride.changeWorkspace'
|
||||||
);
|
);
|
||||||
|
@ -250,7 +244,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let disposableTargetConfig = vscode.commands.registerCommand(
|
const disposableTargetConfig = vscode.commands.registerCommand(
|
||||||
'wamride.targetConfig',
|
'wamride.targetConfig',
|
||||||
() => {
|
() => {
|
||||||
if (currentPrjDir !== '') {
|
if (currentPrjDir !== '') {
|
||||||
|
@ -264,16 +258,16 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let disposableChangeWorkspace = vscode.commands.registerCommand(
|
const disposableChangeWorkspace = vscode.commands.registerCommand(
|
||||||
'wamride.changeWorkspace',
|
'wamride.changeWorkspace',
|
||||||
async () => {
|
async () => {
|
||||||
let options: vscode.OpenDialogOptions = {
|
const options: vscode.OpenDialogOptions = {
|
||||||
canSelectFiles: false,
|
canSelectFiles: false,
|
||||||
canSelectFolders: true,
|
canSelectFolders: true,
|
||||||
openLabel: 'Select Workspace',
|
openLabel: 'Select Workspace',
|
||||||
};
|
};
|
||||||
|
|
||||||
let Workspace = await vscode.window
|
const workSpace = await vscode.window
|
||||||
.showOpenDialog(options)
|
.showOpenDialog(options)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -284,21 +278,21 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
});
|
});
|
||||||
|
|
||||||
/* update workspace value to vscode global settings */
|
/* update workspace value to vscode global settings */
|
||||||
if (Workspace !== '' && Workspace !== undefined) {
|
if (workSpace !== '' && workSpace !== undefined) {
|
||||||
await vscode.workspace
|
await vscode.workspace
|
||||||
.getConfiguration()
|
.getConfiguration()
|
||||||
.update(
|
.update(
|
||||||
'WAMR-IDE.configWorkspace',
|
'WAMR-IDE.configWorkspace',
|
||||||
Workspace.trim(),
|
workSpace.trim(),
|
||||||
vscode.ConfigurationTarget.Global
|
vscode.ConfigurationTarget.Global
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
success => {
|
() => {
|
||||||
vscode.window.showInformationMessage(
|
vscode.window.showInformationMessage(
|
||||||
'Workspace has been set up successfully!'
|
'Workspace has been set up successfully!'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
error => {
|
() => {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
'Set up Workspace failed!'
|
'Set up Workspace failed!'
|
||||||
);
|
);
|
||||||
|
@ -308,7 +302,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let disposableBuild = vscode.commands.registerCommand(
|
const disposableBuild = vscode.commands.registerCommand(
|
||||||
'wamride.build',
|
'wamride.build',
|
||||||
() => {
|
() => {
|
||||||
if (!isWasmProject) {
|
if (!isWasmProject) {
|
||||||
|
@ -327,7 +321,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
'Destroy: Wasm-Container-Before-Build'
|
'Destroy: Wasm-Container-Before-Build'
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let disposable = vscode.tasks.onDidEndTaskProcess(t => {
|
const disposable = vscode.tasks.onDidEndTaskProcess(t => {
|
||||||
if (
|
if (
|
||||||
t.execution.task.name ===
|
t.execution.task.name ===
|
||||||
'Wasm-Container-Before-Build'
|
'Wasm-Container-Before-Build'
|
||||||
|
@ -345,7 +339,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
/* destroy the wasm-toolchain-ctr after building */
|
/* destroy the wasm-toolchain-ctr after building */
|
||||||
let disposable_aft =
|
const disposableAft =
|
||||||
vscode.tasks.onDidEndTask(a => {
|
vscode.tasks.onDidEndTask(a => {
|
||||||
if (
|
if (
|
||||||
a.execution.task.name ===
|
a.execution.task.name ===
|
||||||
|
@ -361,7 +355,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
/* dispose the event after this building process
|
/* dispose the event after this building process
|
||||||
*/
|
*/
|
||||||
disposable_aft.dispose();
|
disposableAft.dispose();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -374,7 +368,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let disposableDebug = vscode.commands.registerCommand(
|
const disposableDebug = vscode.commands.registerCommand(
|
||||||
'wamride.debug',
|
'wamride.debug',
|
||||||
async () => {
|
async () => {
|
||||||
if (!isWasmProject) {
|
if (!isWasmProject) {
|
||||||
|
@ -414,7 +408,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
/* execute the debug task when destroy task finish */
|
/* execute the debug task when destroy task finish */
|
||||||
let disposable_bfr = vscode.tasks.onDidEndTask(t => {
|
const disposableBfr = vscode.tasks.onDidEndTask(t => {
|
||||||
if (
|
if (
|
||||||
t.execution.task.name ===
|
t.execution.task.name ===
|
||||||
'Wasm-Container-Before-Debug'
|
'Wasm-Container-Before-Debug'
|
||||||
|
@ -432,7 +426,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
/* register to listen debug session finish event */
|
/* register to listen debug session finish event */
|
||||||
let dispose_aft =
|
const disposableAft =
|
||||||
vscode.debug.onDidTerminateDebugSession(
|
vscode.debug.onDidTerminateDebugSession(
|
||||||
s => {
|
s => {
|
||||||
if (
|
if (
|
||||||
|
@ -455,18 +449,19 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
'Debug: Wasm'
|
'Debug: Wasm'
|
||||||
);
|
);
|
||||||
|
|
||||||
dispose_aft.dispose();
|
disposableAft.dispose();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
disposable_bfr.dispose();
|
disposableBfr.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let disposableRun = vscode.commands.registerCommand('wamride.run', () => {
|
|
||||||
|
const disposableRun = vscode.commands.registerCommand('wamride.run', () => {
|
||||||
if (!isWasmProject) {
|
if (!isWasmProject) {
|
||||||
vscode.window.showErrorMessage('run failed', {
|
vscode.window.showErrorMessage('run failed', {
|
||||||
modal: true,
|
modal: true,
|
||||||
|
@ -489,7 +484,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
'Destroy: Wasm-Container-Before-Run'
|
'Destroy: Wasm-Container-Before-Run'
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let dispose_bfr = vscode.tasks.onDidEndTaskProcess(e => {
|
const disposableAft = vscode.tasks.onDidEndTaskProcess(e => {
|
||||||
if (e.execution.task.name === 'Wasm-Container-Before-Run') {
|
if (e.execution.task.name === 'Wasm-Container-Before-Run') {
|
||||||
/* make sure that run wasm task will be executed after destroy task finish */
|
/* make sure that run wasm task will be executed after destroy task finish */
|
||||||
vscode.commands
|
vscode.commands
|
||||||
|
@ -499,25 +494,24 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (e.exitCode !== 0) {
|
if (e.exitCode !== 0) {
|
||||||
dispose_bfr.dispose();
|
disposableAft.dispose();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dispose_bfr.dispose();
|
disposableAft.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let disposableToggleIncludePath = vscode.commands.registerCommand(
|
const disposableToggleIncludePath = vscode.commands.registerCommand(
|
||||||
'wamride.build.toggleStateIncludePath',
|
'wamride.build.toggleStateIncludePath',
|
||||||
fileUri => {
|
fileUri => {
|
||||||
let pathRelative: string;
|
const path =
|
||||||
let path =
|
|
||||||
fileUri._fsPath !== null && fileUri._fsPath !== undefined
|
fileUri._fsPath !== null && fileUri._fsPath !== undefined
|
||||||
? fileUri._fsPath
|
? fileUri._fsPath
|
||||||
: vscode.Uri.parse(fileUri.path as string).fsPath;
|
: vscode.Uri.parse(fileUri.path as string).fsPath;
|
||||||
pathRelative = path.replace(currentPrjDir, '..');
|
const pathRelative = path.replace(currentPrjDir, '..');
|
||||||
|
|
||||||
if (includePathArr.indexOf(pathRelative) > -1) {
|
if (includePathArr.indexOf(pathRelative) > -1) {
|
||||||
/* this folder has been added to include path, remove it */
|
/* this folder has been added to include path, remove it */
|
||||||
|
@ -531,25 +525,23 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
writeIntoConfigFile(
|
writeIntoConfigFile(
|
||||||
includePathArr,
|
includePathArr,
|
||||||
excludeFileArr,
|
excludeFileArr,
|
||||||
TargetConfigPanel.BUILD_ARGS
|
TargetConfigPanel.buildArgs
|
||||||
);
|
);
|
||||||
|
|
||||||
decorationProvider.updateDecorationsForSource(fileUri);
|
decorationProvider.updateDecorationsForSource(fileUri);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let disposableToggleExcludeFile = vscode.commands.registerCommand(
|
const disposableToggleExcludeFile = vscode.commands.registerCommand(
|
||||||
'wamride.build.toggleStateExclude',
|
'wamride.build.toggleStateExclude',
|
||||||
fileUri => {
|
fileUri => {
|
||||||
let pathRelative: string;
|
const path =
|
||||||
|
|
||||||
let path =
|
|
||||||
fileUri._fsPath !== null && fileUri._fsPath !== undefined
|
fileUri._fsPath !== null && fileUri._fsPath !== undefined
|
||||||
? fileUri._fsPath
|
? fileUri._fsPath
|
||||||
: vscode.Uri.parse(fileUri.path as string).fsPath;
|
: vscode.Uri.parse(fileUri.path as string).fsPath;
|
||||||
|
|
||||||
/* replace the current project absolute path with .. to change to relative path */
|
/* replace the current project absolute path with .. to change to relative path */
|
||||||
pathRelative = path.replace(currentPrjDir, '..');
|
const pathRelative = path.replace(currentPrjDir, '..');
|
||||||
|
|
||||||
if (excludeFileArr.indexOf(pathRelative) > -1) {
|
if (excludeFileArr.indexOf(pathRelative) > -1) {
|
||||||
excludeFileArr = excludeFileArr.filter(val => {
|
excludeFileArr = excludeFileArr.filter(val => {
|
||||||
|
@ -562,7 +554,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
writeIntoConfigFile(
|
writeIntoConfigFile(
|
||||||
includePathArr,
|
includePathArr,
|
||||||
excludeFileArr,
|
excludeFileArr,
|
||||||
TargetConfigPanel.BUILD_ARGS
|
TargetConfigPanel.buildArgs
|
||||||
);
|
);
|
||||||
|
|
||||||
/* update decoration for this source file */
|
/* update decoration for this source file */
|
||||||
|
@ -570,14 +562,14 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let disposableOpenFolder = vscode.commands.registerCommand(
|
const disposableOpenFolder = vscode.commands.registerCommand(
|
||||||
'wamride.openFolder',
|
'wamride.openFolder',
|
||||||
() => {
|
() => {
|
||||||
/* get projects list under current workspace */
|
/* get projects list under current workspace */
|
||||||
let _ok = 'Set up now';
|
const okStr = 'Set up now';
|
||||||
let _cancle = 'Maybe later';
|
const cancelStr = 'Maybe later';
|
||||||
let _create = 'Create now';
|
const createStr = 'Create now';
|
||||||
let curWorkspace = vscode.workspace
|
const curWorkspace = vscode.workspace
|
||||||
.getConfiguration()
|
.getConfiguration()
|
||||||
.get('WAMR-IDE.configWorkspace') as string;
|
.get('WAMR-IDE.configWorkspace') as string;
|
||||||
|
|
||||||
|
@ -586,11 +578,11 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
vscode.window
|
vscode.window
|
||||||
.showWarningMessage(
|
.showWarningMessage(
|
||||||
'Please setup your workspace firstly.',
|
'Please setup your workspace firstly.',
|
||||||
_ok,
|
okStr,
|
||||||
_cancle
|
cancelStr
|
||||||
)
|
)
|
||||||
.then(item => {
|
.then(item => {
|
||||||
if (item === _ok) {
|
if (item === okStr) {
|
||||||
vscode.commands.executeCommand(
|
vscode.commands.executeCommand(
|
||||||
'wamride.changeWorkspace'
|
'wamride.changeWorkspace'
|
||||||
);
|
);
|
||||||
|
@ -611,10 +603,10 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
.get('WAMR-IDE.configWorkspace') +
|
.get('WAMR-IDE.configWorkspace') +
|
||||||
'',
|
'',
|
||||||
},
|
},
|
||||||
_ok
|
okStr
|
||||||
)
|
)
|
||||||
.then(item => {
|
.then(item => {
|
||||||
if (item === _ok) {
|
if (item === okStr) {
|
||||||
vscode.commands.executeCommand(
|
vscode.commands.executeCommand(
|
||||||
'wamride.changeWorkspace'
|
'wamride.changeWorkspace'
|
||||||
);
|
);
|
||||||
|
@ -640,7 +632,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
.filter(dirent => dirent.isDirectory())
|
.filter(dirent => dirent.isDirectory())
|
||||||
.map(dirent => dirent.name);
|
.map(dirent => dirent.name);
|
||||||
|
|
||||||
let projFilesArr = directoryArr.filter(obj => {
|
const projFilesArr = directoryArr.filter(obj => {
|
||||||
if (checkIfWasmProj(path.join(curWorkspace, obj))) {
|
if (checkIfWasmProj(path.join(curWorkspace, obj))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -650,11 +642,11 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
vscode.window
|
vscode.window
|
||||||
.showWarningMessage(
|
.showWarningMessage(
|
||||||
'Current workspace is empty, please create your project firstly.',
|
'Current workspace is empty, please create your project firstly.',
|
||||||
_create,
|
createStr,
|
||||||
_cancle
|
cancelStr
|
||||||
)
|
)
|
||||||
.then(item => {
|
.then(item => {
|
||||||
if (item === _create) {
|
if (item === createStr) {
|
||||||
vscode.commands.executeCommand(
|
vscode.commands.executeCommand(
|
||||||
'wamride.newProject'
|
'wamride.newProject'
|
||||||
);
|
);
|
||||||
|
@ -673,18 +665,18 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _path = curWorkspace.concat(
|
const path = curWorkspace.concat(
|
||||||
OS_PLATFORM === 'win32'
|
osPlatform === 'win32'
|
||||||
? '\\'
|
? '\\'
|
||||||
: OS_PLATFORM === 'linux' ||
|
: osPlatform === 'linux' ||
|
||||||
OS_PLATFORM === 'darwin'
|
osPlatform === 'darwin'
|
||||||
? '/'
|
? '/'
|
||||||
: '',
|
: '',
|
||||||
option
|
option
|
||||||
);
|
);
|
||||||
|
|
||||||
/* open the selected wasm project */
|
/* open the selected wasm project */
|
||||||
openWindoWithSituation(vscode.Uri.file(_path));
|
openWindowWithSituation(vscode.Uri.file(path));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -713,13 +705,14 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openWindoWithSituation(uri: vscode.Uri) {
|
function openWindowWithSituation(uri: vscode.Uri) {
|
||||||
/**
|
/**
|
||||||
* check if the workspace folder is empty,
|
* check if the workspace folder is empty,
|
||||||
* if yes, open new window, else open in current window
|
* if yes, open new window, else open in current window
|
||||||
*/
|
*/
|
||||||
let isWorkspaceEmpty: boolean;
|
const isWorkspaceEmpty = !vscode.workspace.workspaceFolders?.[0]
|
||||||
isWorkspaceEmpty = !vscode.workspace.workspaceFolders?.[0] ? true : false;
|
? true
|
||||||
|
: false;
|
||||||
|
|
||||||
isWorkspaceEmpty === false
|
isWorkspaceEmpty === false
|
||||||
? vscode.commands.executeCommand('vscode.openFolder', uri, {
|
? vscode.commands.executeCommand('vscode.openFolder', uri, {
|
||||||
|
@ -731,11 +724,11 @@ function openWindoWithSituation(uri: vscode.Uri) {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BuildArgs {
|
interface BuildArgs {
|
||||||
output_file_name: string;
|
outputFileName: string;
|
||||||
init_memory_size: string;
|
initMemorySize: string;
|
||||||
max_memory_size: string;
|
maxMemorySize: string;
|
||||||
stack_size: string;
|
stackSize: string;
|
||||||
exported_symbols: string;
|
exportedSymbols: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -748,25 +741,25 @@ export function writeIntoConfigFile(
|
||||||
includePathArr: string[],
|
includePathArr: string[],
|
||||||
excludeFileArr: string[],
|
excludeFileArr: string[],
|
||||||
buildArgs?: BuildArgs
|
buildArgs?: BuildArgs
|
||||||
) {
|
): void {
|
||||||
let jsonStr = JSON.stringify(
|
const jsonStr = JSON.stringify(
|
||||||
{
|
{
|
||||||
include_paths: includePathArr,
|
includePaths: includePathArr,
|
||||||
exclude_files: excludeFileArr,
|
excludeFiles: excludeFileArr,
|
||||||
build_args: buildArgs ? buildArgs : '{}',
|
buildArgs: buildArgs ? buildArgs : '{}',
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
'\t'
|
'\t'
|
||||||
);
|
);
|
||||||
|
|
||||||
let prjConfigDir = path.join(currentPrjDir, '.wamr');
|
const prjConfigDir = path.join(currentPrjDir, '.wamr');
|
||||||
let configFilePath = path.join(prjConfigDir, 'compilation_config.json');
|
const configFilePath = path.join(prjConfigDir, 'compilation_config.json');
|
||||||
writeIntoFile(configFilePath, jsonStr);
|
writeIntoFile(configFilePath, jsonStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readFromConfigFile(): string {
|
export function readFromConfigFile(): string {
|
||||||
let prjConfigDir = path.join(currentPrjDir, '.wamr');
|
const prjConfigDir = path.join(currentPrjDir, '.wamr');
|
||||||
let configFilePath = path.join(prjConfigDir, 'compilation_config.json');
|
const configFilePath = path.join(prjConfigDir, 'compilation_config.json');
|
||||||
return readFromFile(configFilePath);
|
return readFromFile(configFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,9 +771,9 @@ function generateCMakeFile(
|
||||||
excludeFileArr: string[]
|
excludeFileArr: string[]
|
||||||
): void {
|
): void {
|
||||||
// -Wl,--export=${EXPORT_SYMBOLS}
|
// -Wl,--export=${EXPORT_SYMBOLS}
|
||||||
let srcFilePath = path.join(currentPrjDir, 'src');
|
const srcFilePath = path.join(currentPrjDir, 'src');
|
||||||
let prjConfigDir = path.join(currentPrjDir, '.wamr');
|
const prjConfigDir = path.join(currentPrjDir, '.wamr');
|
||||||
let cmakeFilePath = path.join(prjConfigDir, 'project.cmake');
|
const cmakeFilePath = path.join(prjConfigDir, 'project.cmake');
|
||||||
|
|
||||||
let strIncludeList = 'set (PROJECT_INCLUDES';
|
let strIncludeList = 'set (PROJECT_INCLUDES';
|
||||||
let strSrcList = 'set (PROJECT_SRC_LIST';
|
let strSrcList = 'set (PROJECT_SRC_LIST';
|
||||||
|
@ -795,17 +788,16 @@ function generateCMakeFile(
|
||||||
let i, s, e: number;
|
let i, s, e: number;
|
||||||
|
|
||||||
/* change the absolute path into relative path */
|
/* change the absolute path into relative path */
|
||||||
let _re = currentPrjDir;
|
const _re = currentPrjDir;
|
||||||
let _substr = '${CMAKE_CURRENT_SOURCE_DIR}/..';
|
const _substr = '${CMAKE_CURRENT_SOURCE_DIR}/..';
|
||||||
|
|
||||||
let srcPathArr: Array<{ path: string }> | undefined;
|
|
||||||
/**
|
/**
|
||||||
* set PROJECT_SRC_LIST
|
* set PROJECT_SRC_LIST
|
||||||
* default ADD every c OR c++ OR cpp under the src/ path
|
* default ADD every c OR c++ OR cpp under the src/ path
|
||||||
* except the files saved in the exclude_files array
|
* except the files saved in the excludeFiles array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
srcPathArr = getAllSrcFiles(srcFilePath);
|
const srcPathArr = getAllSrcFiles(srcFilePath);
|
||||||
|
|
||||||
if (srcPathArr === undefined) {
|
if (srcPathArr === undefined) {
|
||||||
return;
|
return;
|
||||||
|
@ -818,46 +810,46 @@ function generateCMakeFile(
|
||||||
) === -1
|
) === -1
|
||||||
) {
|
) {
|
||||||
/* replace currentPrjDir with ${CMAKE_CURRENT_SOURCE_DIR} */
|
/* replace currentPrjDir with ${CMAKE_CURRENT_SOURCE_DIR} */
|
||||||
let _newStr = srcPathArr[s].path
|
const newStr = srcPathArr[s].path
|
||||||
.replace(_re, _substr)
|
.replace(_re, _substr)
|
||||||
.replace(/\\/g, '/');
|
.replace(/\\/g, '/');
|
||||||
|
|
||||||
strSrcList = strSrcList.concat(' ', _newStr);
|
strSrcList = strSrcList.concat(' ', newStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strSrcList = strSrcList.concat(' )');
|
strSrcList = strSrcList.concat(' )');
|
||||||
|
|
||||||
for (i = 0; i < includePathArr.length; i++) {
|
for (i = 0; i < includePathArr.length; i++) {
|
||||||
let _newStr = includePathArr[i]
|
const newStr = includePathArr[i]
|
||||||
.replace(/../, _substr)
|
.replace(/../, _substr)
|
||||||
.replace(/\\/g, '/');
|
.replace(/\\/g, '/');
|
||||||
strIncludeList = strIncludeList.concat(' ', _newStr);
|
strIncludeList = strIncludeList.concat(' ', newStr);
|
||||||
}
|
}
|
||||||
strIncludeList = strIncludeList.concat(' )');
|
strIncludeList = strIncludeList.concat(' )');
|
||||||
|
|
||||||
/* set up user customized input in configBuildArgs webview */
|
/* set up user customized input in configBuildArgs webview */
|
||||||
strOutputFileName = strOutputFileName.concat(
|
strOutputFileName = strOutputFileName.concat(
|
||||||
' ',
|
' ',
|
||||||
TargetConfigPanel.BUILD_ARGS.output_file_name + ')'
|
TargetConfigPanel.buildArgs.outputFileName + ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
strInitMemSize = strInitMemSize.concat(
|
strInitMemSize = strInitMemSize.concat(
|
||||||
' ',
|
' ',
|
||||||
TargetConfigPanel.BUILD_ARGS.init_memory_size + ')'
|
TargetConfigPanel.buildArgs.initMemorySize + ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
strMaxMemSize = strMaxMemSize.concat(
|
strMaxMemSize = strMaxMemSize.concat(
|
||||||
' ',
|
' ',
|
||||||
TargetConfigPanel.BUILD_ARGS.max_memory_size + ')'
|
TargetConfigPanel.buildArgs.maxMemorySize + ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
strStackSize = strStackSize.concat(
|
strStackSize = strStackSize.concat(
|
||||||
' ',
|
' ',
|
||||||
TargetConfigPanel.BUILD_ARGS.stack_size + ')'
|
TargetConfigPanel.buildArgs.stackSize + ')'
|
||||||
);
|
);
|
||||||
|
|
||||||
let exportedSymbolArr =
|
const exportedSymbolArr =
|
||||||
TargetConfigPanel.BUILD_ARGS.exported_symbols.split(',');
|
TargetConfigPanel.buildArgs.exportedSymbols.split(',');
|
||||||
|
|
||||||
strExportedSymbols = strExportedSymbols.concat(' "');
|
strExportedSymbols = strExportedSymbols.concat(' "');
|
||||||
|
|
||||||
|
@ -901,7 +893,7 @@ function getAllSrcFiles(_path: string) {
|
||||||
const folders = entries.filter(folder => folder.isDirectory());
|
const folders = entries.filter(folder => folder.isDirectory());
|
||||||
|
|
||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
let fileArr = getAllSrcFiles(path.join(_path, folder.name));
|
const fileArr = getAllSrcFiles(path.join(_path, folder.name));
|
||||||
fileArr ? files.push(...fileArr) : '';
|
fileArr ? files.push(...fileArr) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,7 +903,7 @@ function getAllSrcFiles(_path: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIfBuildSuccess(): Boolean {
|
function checkIfBuildSuccess(): boolean {
|
||||||
try {
|
try {
|
||||||
let wasmExist = false;
|
let wasmExist = false;
|
||||||
const entries = fileSystem.readdirSync(
|
const entries = fileSystem.readdirSync(
|
||||||
|
@ -933,10 +925,10 @@ function checkIfBuildSuccess(): Boolean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIfWasmProj(_path: string): Boolean {
|
function checkIfWasmProj(path: string): boolean {
|
||||||
try {
|
try {
|
||||||
let isWasmProj = false;
|
let isWasmProj = false;
|
||||||
const entries = fileSystem.readdirSync(_path, {
|
const entries = fileSystem.readdirSync(path, {
|
||||||
withFileTypes: true,
|
withFileTypes: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ export class WasmTaskProvider implements vscode.TaskProvider {
|
||||||
public provideTasks(): Thenable<vscode.Task[]> | undefined {
|
public provideTasks(): Thenable<vscode.Task[]> | undefined {
|
||||||
if (!this.wasmPromise) {
|
if (!this.wasmPromise) {
|
||||||
/* target name is used for generated aot target */
|
/* target name is used for generated aot target */
|
||||||
let targetName =
|
const targetName =
|
||||||
TargetConfigPanel.BUILD_ARGS.output_file_name.split('.')[0];
|
TargetConfigPanel.buildArgs.outputFileName.split('.')[0];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
os.platform() === 'linux' ||
|
os.platform() === 'linux' ||
|
||||||
|
@ -219,7 +219,10 @@ export class WasmTaskProvider implements vscode.TaskProvider {
|
||||||
* @param _task
|
* @param _task
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
public resolveTask(_task: vscode.Task): vscode.Task | undefined {
|
public resolveTask(task: vscode.Task): vscode.Task | undefined {
|
||||||
|
if (task) {
|
||||||
|
return task;
|
||||||
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ export function createDirectory(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parent = path.dirname(dest);
|
const parent = path.dirname(dest);
|
||||||
if (!createDirectory(parent, mode)) {
|
if (!createDirectory(parent, mode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ export function createDirectory(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function copyFiles(src: string, dest: string, flags?: number): boolean {
|
export function copyFiles(src: string, dest: string, flags?: number): boolean {
|
||||||
try {
|
try {
|
||||||
fileSystem.copyFileSync(src, dest);
|
fileSystem.copyFileSync(src, dest);
|
||||||
|
@ -64,7 +65,7 @@ export function writeIntoFile(path: string, data: string): void {
|
||||||
|
|
||||||
export function readFromFile(path: string): string {
|
export function readFromFile(path: string): string {
|
||||||
try {
|
try {
|
||||||
let data = fileSystem.readFileSync(path, { encoding: 'utf-8' });
|
const data = fileSystem.readFileSync(path, { encoding: 'utf-8' });
|
||||||
return data as string;
|
return data as string;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
vscode.window.showErrorMessage(err as string);
|
vscode.window.showErrorMessage(err as string);
|
||||||
|
@ -114,9 +115,9 @@ export function checkIfFileExists(path: string): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkFolderName(folderName: string) {
|
export function checkFolderName(folderName: string): boolean {
|
||||||
let invalidCharacterArr: string[] = [];
|
let invalidCharacterArr: string[] = [];
|
||||||
var valid = true;
|
let valid = true;
|
||||||
|
|
||||||
if (folderName.length > 255) {
|
if (folderName.length > 255) {
|
||||||
valid = false;
|
valid = false;
|
||||||
|
@ -143,6 +144,7 @@ export function downloadFile(
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const file = fileSystem.createWriteStream(destinationPath);
|
const file = fileSystem.createWriteStream(destinationPath);
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const stream = request(url, undefined, (error, response, body) => {
|
const stream = request(url, undefined, (error, response, body) => {
|
||||||
if (response.statusCode !== 200) {
|
if (response.statusCode !== 200) {
|
||||||
reject(
|
reject(
|
||||||
|
|
|
@ -9,6 +9,6 @@ export function getUri(
|
||||||
webview: Webview,
|
webview: Webview,
|
||||||
extensionUri: Uri,
|
extensionUri: Uri,
|
||||||
pathList: string[]
|
pathList: string[]
|
||||||
) {
|
): Uri {
|
||||||
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
|
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ function getLLDBUnzipFilePath(destinationFolder: string, filename: string) {
|
||||||
export function getWAMRExtensionVersion(
|
export function getWAMRExtensionVersion(
|
||||||
context: vscode.ExtensionContext
|
context: vscode.ExtensionContext
|
||||||
): string {
|
): string {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
return require(path.join(context.extensionPath, 'package.json')).version;
|
return require(path.join(context.extensionPath, 'package.json')).version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +65,9 @@ export function isLLDBInstalled(context: vscode.ExtensionContext): boolean {
|
||||||
return checkIfFileExists(lldbBinaryPath);
|
return checkIfFileExists(lldbBinaryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function promptInstallLLDB(context: vscode.ExtensionContext) {
|
export async function promptInstallLLDB(
|
||||||
|
context: vscode.ExtensionContext
|
||||||
|
): Promise<void> {
|
||||||
const extensionPath = context.extensionPath;
|
const extensionPath = context.extensionPath;
|
||||||
const setupPrompt = 'setup';
|
const setupPrompt = 'setup';
|
||||||
const skipPrompt = 'skip';
|
const skipPrompt = 'skip';
|
||||||
|
@ -111,5 +114,7 @@ export async function promptInstallLLDB(context: vscode.ExtensionContext) {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove the bundle.zip
|
// Remove the bundle.zip
|
||||||
fs.unlink(lldbZipPath, () => {});
|
fs.unlink(lldbZipPath, () => {
|
||||||
|
return;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,35 +15,37 @@ import {
|
||||||
import { getUri } from '../utilities/getUri';
|
import { getUri } from '../utilities/getUri';
|
||||||
|
|
||||||
export class NewProjectPanel {
|
export class NewProjectPanel {
|
||||||
static USER_SET_WORKSPACE: string;
|
public static userSetWorkSpace: string;
|
||||||
public static currentPanel: NewProjectPanel | undefined;
|
public static currentPanel: NewProjectPanel | undefined;
|
||||||
private readonly _panel: vscode.WebviewPanel;
|
private readonly viewPanel: vscode.WebviewPanel;
|
||||||
private _disposables: vscode.Disposable[] = [];
|
private disposableArr: vscode.Disposable[] = [];
|
||||||
|
|
||||||
static readonly EXCUTION_SUCCESS: number = 0;
|
private static readonly executionSuccess = 0;
|
||||||
static readonly DIR_EXSITED_ERR: number = -1;
|
private static readonly dirExistedError = -1;
|
||||||
static readonly USER_INTPUT_ERR: number = -2;
|
private static readonly userInputError = -2;
|
||||||
static readonly DIR_PATH_INVALID_ERR: number = -3;
|
private static readonly dirPathInvalidError = -3;
|
||||||
|
|
||||||
constructor(extensionUri: vscode.Uri, panel: vscode.WebviewPanel) {
|
constructor(extensionUri: vscode.Uri, panel: vscode.WebviewPanel) {
|
||||||
this._panel = panel;
|
this.viewPanel = panel;
|
||||||
this._panel.webview.html = this._getHtmlForWebview(
|
this.viewPanel.webview.html = this.getHtmlForWebview(
|
||||||
this._panel.webview,
|
this.viewPanel.webview,
|
||||||
extensionUri,
|
extensionUri,
|
||||||
'resource/webview/page/newProject.html'
|
'resource/webview/page/newProject.html'
|
||||||
);
|
);
|
||||||
this._setWebviewMessageListener(this._panel.webview, extensionUri);
|
this._setWebviewMessageListener(this.viewPanel.webview, extensionUri);
|
||||||
this._panel.onDidDispose(this.dispose, null, this._disposables);
|
this.viewPanel.onDidDispose(this.dispose, null, this.disposableArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static render(context: vscode.ExtensionContext) {
|
public static render(context: vscode.ExtensionContext): void {
|
||||||
NewProjectPanel.USER_SET_WORKSPACE = vscode.workspace
|
NewProjectPanel.userSetWorkSpace = vscode.workspace
|
||||||
.getConfiguration()
|
.getConfiguration()
|
||||||
.get('WAMR-IDE.configWorkspace') as string;
|
.get('WAMR-IDE.configWorkspace') as string;
|
||||||
|
|
||||||
/* check if current panel is initialized */
|
/* check if current panel is initialized */
|
||||||
if (NewProjectPanel.currentPanel) {
|
if (NewProjectPanel.currentPanel) {
|
||||||
NewProjectPanel.currentPanel._panel.reveal(vscode.ViewColumn.One);
|
NewProjectPanel.currentPanel.viewPanel.reveal(
|
||||||
|
vscode.ViewColumn.One
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
const panel = vscode.window.createWebviewPanel(
|
const panel = vscode.window.createWebviewPanel(
|
||||||
'newProject',
|
'newProject',
|
||||||
|
@ -62,25 +64,25 @@ export class NewProjectPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _creatNewProject(
|
private createNewProject(
|
||||||
projName: string,
|
projName: string,
|
||||||
template: string,
|
template: string,
|
||||||
extensionUri: vscode.Uri
|
extensionUri: vscode.Uri
|
||||||
): number {
|
): number {
|
||||||
if (projName === '' || template === '') {
|
if (projName === '' || template === '') {
|
||||||
return NewProjectPanel.USER_INTPUT_ERR;
|
return NewProjectPanel.userInputError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkFolderName(projName)) {
|
if (!checkFolderName(projName)) {
|
||||||
return NewProjectPanel.DIR_PATH_INVALID_ERR;
|
return NewProjectPanel.dirPathInvalidError;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ROOT_PATH = path.join(NewProjectPanel.USER_SET_WORKSPACE, projName);
|
const ROOT_PATH = path.join(NewProjectPanel.userSetWorkSpace, projName);
|
||||||
let EXT_PATH = extensionUri.fsPath;
|
const EXT_PATH = extensionUri.fsPath;
|
||||||
|
|
||||||
if (fs.existsSync(ROOT_PATH)) {
|
if (fs.existsSync(ROOT_PATH)) {
|
||||||
if (fs.lstatSync(ROOT_PATH).isDirectory()) {
|
if (fs.lstatSync(ROOT_PATH).isDirectory()) {
|
||||||
return NewProjectPanel.DIR_EXSITED_ERR;
|
return NewProjectPanel.dirExistedError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,14 +100,14 @@ export class NewProjectPanel {
|
||||||
path.join(ROOT_PATH, '.wamr/project.cmake')
|
path.join(ROOT_PATH, '.wamr/project.cmake')
|
||||||
);
|
);
|
||||||
|
|
||||||
return NewProjectPanel.EXCUTION_SUCCESS;
|
return NewProjectPanel.executionSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public _getHtmlForWebview(
|
public getHtmlForWebview(
|
||||||
webview: vscode.Webview,
|
webview: vscode.Webview,
|
||||||
extensionUri: vscode.Uri,
|
extensionUri: vscode.Uri,
|
||||||
templatePath: string
|
templatePath: string
|
||||||
) {
|
): string {
|
||||||
const toolkitUri = getUri(webview, extensionUri, [
|
const toolkitUri = getUri(webview, extensionUri, [
|
||||||
'node_modules',
|
'node_modules',
|
||||||
'@vscode',
|
'@vscode',
|
||||||
|
@ -146,14 +148,14 @@ export class NewProjectPanel {
|
||||||
message => {
|
message => {
|
||||||
switch (message.command) {
|
switch (message.command) {
|
||||||
case 'create_new_project':
|
case 'create_new_project':
|
||||||
let createNewProjectStatus = this._creatNewProject(
|
const createNewProjectStatus = this.createNewProject(
|
||||||
message.projectName,
|
message.projectName,
|
||||||
message.template,
|
message.template,
|
||||||
extensionUri
|
extensionUri
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
createNewProjectStatus ===
|
createNewProjectStatus ===
|
||||||
NewProjectPanel.EXCUTION_SUCCESS
|
NewProjectPanel.executionSuccess
|
||||||
) {
|
) {
|
||||||
webview.postMessage({
|
webview.postMessage({
|
||||||
command: 'proj_creation_finish',
|
command: 'proj_creation_finish',
|
||||||
|
@ -161,17 +163,17 @@ export class NewProjectPanel {
|
||||||
});
|
});
|
||||||
} else if (
|
} else if (
|
||||||
createNewProjectStatus ===
|
createNewProjectStatus ===
|
||||||
NewProjectPanel.DIR_EXSITED_ERR
|
NewProjectPanel.dirExistedError
|
||||||
) {
|
) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
'Project : ' +
|
'Project : ' +
|
||||||
message.projectName +
|
message.projectName +
|
||||||
' exsits in your current root path, please change project name or root path!'
|
' exists in your current root path, please change project name or root path!'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else if (
|
} else if (
|
||||||
createNewProjectStatus ===
|
createNewProjectStatus ===
|
||||||
NewProjectPanel.USER_INTPUT_ERR
|
NewProjectPanel.userInputError
|
||||||
) {
|
) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
'Please fill chart before your submit!'
|
'Please fill chart before your submit!'
|
||||||
|
@ -179,7 +181,7 @@ export class NewProjectPanel {
|
||||||
return;
|
return;
|
||||||
} else if (
|
} else if (
|
||||||
createNewProjectStatus ===
|
createNewProjectStatus ===
|
||||||
NewProjectPanel.DIR_PATH_INVALID_ERR
|
NewProjectPanel.dirPathInvalidError
|
||||||
) {
|
) {
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
|
@ -203,19 +205,18 @@ export class NewProjectPanel {
|
||||||
message.projectName +
|
message.projectName +
|
||||||
' will be opened!'
|
' will be opened!'
|
||||||
);
|
);
|
||||||
let isWorkspaceEmpty: boolean;
|
|
||||||
|
|
||||||
let projPath = path.join(
|
const projPath = path.join(
|
||||||
NewProjectPanel.USER_SET_WORKSPACE,
|
NewProjectPanel.userSetWorkSpace,
|
||||||
message.projectName
|
message.projectName
|
||||||
);
|
);
|
||||||
let uri = vscode.Uri.file(projPath);
|
const uri = vscode.Uri.file(projPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the vscode workspace folder is empty,
|
* check if the vscode workspace folder is empty,
|
||||||
* if yes, open new window, else open in current window
|
* if yes, open new window, else open in current window
|
||||||
*/
|
*/
|
||||||
isWorkspaceEmpty = !vscode.workspace
|
const isWorkspaceEmpty = !vscode.workspace
|
||||||
.workspaceFolders?.[0]
|
.workspaceFolders?.[0]
|
||||||
? true
|
? true
|
||||||
: false;
|
: false;
|
||||||
|
@ -233,7 +234,7 @@ export class NewProjectPanel {
|
||||||
);
|
);
|
||||||
|
|
||||||
case 'close_webview':
|
case 'close_webview':
|
||||||
this._panel.dispose();
|
this.viewPanel.dispose();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -241,16 +242,16 @@ export class NewProjectPanel {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
undefined,
|
undefined,
|
||||||
this._disposables
|
this.disposableArr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private dispose() {
|
private dispose() {
|
||||||
NewProjectPanel.currentPanel = undefined;
|
NewProjectPanel.currentPanel = undefined;
|
||||||
this._panel.dispose();
|
this.viewPanel.dispose();
|
||||||
|
|
||||||
while (this._disposables.length) {
|
while (this.disposableArr.length) {
|
||||||
const disposable = this._disposables.pop();
|
const disposable = this.disposableArr.pop();
|
||||||
if (disposable) {
|
if (disposable) {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,19 @@ import { getUri } from '../utilities/getUri';
|
||||||
|
|
||||||
export class TargetConfigPanel {
|
export class TargetConfigPanel {
|
||||||
public static currentPanel: TargetConfigPanel | undefined;
|
public static currentPanel: TargetConfigPanel | undefined;
|
||||||
private readonly _panel: vscode.WebviewPanel;
|
private readonly viewPanel: vscode.WebviewPanel;
|
||||||
|
|
||||||
private _disposables: vscode.Disposable[] = [];
|
private _disposables: vscode.Disposable[] = [];
|
||||||
public static BUILD_ARGS = {
|
public static buildArgs = {
|
||||||
output_file_name: 'main.wasm',
|
outputFileName: 'main.wasm',
|
||||||
init_memory_size: '131072',
|
initMemorySize: '131072',
|
||||||
max_memory_size: '131072',
|
maxMemorySize: '131072',
|
||||||
stack_size: '4096',
|
stackSize: '4096',
|
||||||
exported_symbols: 'main',
|
exportedSymbols: 'main',
|
||||||
};
|
};
|
||||||
|
|
||||||
static readonly USER_INTPUT_ERR: number = -2;
|
private static readonly userInputError: number = -2;
|
||||||
static readonly EXCUTION_SUCCESS: number = 0;
|
private static readonly executionSuccess: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -31,24 +31,26 @@ export class TargetConfigPanel {
|
||||||
* @param panelName
|
* @param panelName
|
||||||
*/
|
*/
|
||||||
constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
|
constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) {
|
||||||
this._panel = panel;
|
this.viewPanel = panel;
|
||||||
this._panel.webview.html = this._getHtmlForWebview(
|
this.viewPanel.webview.html = this._getHtmlForWebview(
|
||||||
this._panel.webview,
|
this.viewPanel.webview,
|
||||||
extensionUri,
|
extensionUri,
|
||||||
'resource/webview/page/configBuildTarget.html'
|
'resource/webview/page/configBuildTarget.html'
|
||||||
);
|
);
|
||||||
this._panel.onDidDispose(this.dispose, null, this._disposables);
|
this.viewPanel.onDidDispose(this.dispose, null, this._disposables);
|
||||||
this._setWebviewMessageListener(this._panel.webview);
|
this._setWebviewMessageListener(this.viewPanel.webview);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public static render(context: vscode.ExtensionContext) {
|
public static render(context: vscode.ExtensionContext): void {
|
||||||
/* check if current panel is initialized */
|
/* check if current panel is initialized */
|
||||||
if (TargetConfigPanel.currentPanel) {
|
if (TargetConfigPanel.currentPanel) {
|
||||||
TargetConfigPanel.currentPanel._panel.reveal(vscode.ViewColumn.One);
|
TargetConfigPanel.currentPanel.viewPanel.reveal(
|
||||||
|
vscode.ViewColumn.One
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
const panel = vscode.window.createWebviewPanel(
|
const panel = vscode.window.createWebviewPanel(
|
||||||
'targetConfig',
|
'targetConfig',
|
||||||
|
@ -67,59 +69,56 @@ export class TargetConfigPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _configBuildArgs(
|
private configBuildArgs(
|
||||||
outputFileName: string,
|
outputFileName: string,
|
||||||
initmemSize: string,
|
initMemSize: string,
|
||||||
maxmemSize: string,
|
maxMemSize: string,
|
||||||
stackSize: string,
|
stackSize: string,
|
||||||
exportedSymbols: string
|
exportedSymbols: string
|
||||||
): number {
|
): number {
|
||||||
if (
|
if (
|
||||||
outputFileName === '' ||
|
outputFileName === '' ||
|
||||||
initmemSize === '' ||
|
initMemSize === '' ||
|
||||||
maxmemSize === '' ||
|
maxMemSize === '' ||
|
||||||
stackSize === '' ||
|
stackSize === '' ||
|
||||||
exportedSymbols === ''
|
exportedSymbols === ''
|
||||||
) {
|
) {
|
||||||
return TargetConfigPanel.USER_INTPUT_ERR;
|
return TargetConfigPanel.userInputError;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _configStr: string;
|
let includePathArr = [];
|
||||||
let includePathArr = new Array();
|
let excludeFileArr = [];
|
||||||
let excludeFileArr = new Array();
|
|
||||||
let configJson: any;
|
|
||||||
|
|
||||||
let _configObj = {
|
const configObj = {
|
||||||
output_file_name: outputFileName,
|
outputFileName: outputFileName,
|
||||||
init_memory_size: initmemSize,
|
initMemorySize: initMemSize,
|
||||||
max_memory_size: maxmemSize,
|
maxMemorySize: maxMemSize,
|
||||||
stack_size: stackSize,
|
stackSize: stackSize,
|
||||||
exported_symbols: exportedSymbols,
|
exportedSymbols: exportedSymbols,
|
||||||
};
|
};
|
||||||
|
const configStr = readFromConfigFile();
|
||||||
|
|
||||||
TargetConfigPanel.BUILD_ARGS = _configObj;
|
TargetConfigPanel.buildArgs = configObj;
|
||||||
|
|
||||||
_configStr = readFromConfigFile();
|
if (configStr !== '' && configStr !== undefined) {
|
||||||
|
const configJson = JSON.parse(configStr);
|
||||||
if (_configStr !== '' && _configStr !== undefined) {
|
|
||||||
configJson = JSON.parse(_configStr);
|
|
||||||
includePathArr =
|
includePathArr =
|
||||||
configJson['include_paths'] === undefined
|
configJson['includePaths'] === undefined
|
||||||
? []
|
? []
|
||||||
: configJson['include_paths'];
|
: configJson['includePaths'];
|
||||||
excludeFileArr =
|
excludeFileArr =
|
||||||
configJson['exclude_files'] === undefined
|
configJson['excludeFiles'] === undefined
|
||||||
? []
|
? []
|
||||||
: configJson['exclude_files'];
|
: configJson['excludeFiles'];
|
||||||
}
|
}
|
||||||
|
|
||||||
writeIntoConfigFile(
|
writeIntoConfigFile(
|
||||||
includePathArr,
|
includePathArr,
|
||||||
excludeFileArr,
|
excludeFileArr,
|
||||||
TargetConfigPanel.BUILD_ARGS
|
TargetConfigPanel.buildArgs
|
||||||
);
|
);
|
||||||
|
|
||||||
return TargetConfigPanel.EXCUTION_SUCCESS;
|
return TargetConfigPanel.executionSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getHtmlForWebview(
|
private _getHtmlForWebview(
|
||||||
|
@ -158,23 +157,23 @@ export class TargetConfigPanel {
|
||||||
.replace(/(\${styleUri})/, styleUri.toString())
|
.replace(/(\${styleUri})/, styleUri.toString())
|
||||||
.replace(
|
.replace(
|
||||||
/(\${output_file_val})/,
|
/(\${output_file_val})/,
|
||||||
TargetConfigPanel.BUILD_ARGS.output_file_name
|
TargetConfigPanel.buildArgs.outputFileName
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
/(\${initial_mem_size_val})/,
|
/(\${initial_mem_size_val})/,
|
||||||
TargetConfigPanel.BUILD_ARGS.init_memory_size
|
TargetConfigPanel.buildArgs.initMemorySize
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
/(\${max_mem_size_val})/,
|
/(\${max_mem_size_val})/,
|
||||||
TargetConfigPanel.BUILD_ARGS.max_memory_size
|
TargetConfigPanel.buildArgs.maxMemorySize
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
/(\${stack_size_val})/,
|
/(\${stack_size_val})/,
|
||||||
TargetConfigPanel.BUILD_ARGS.stack_size
|
TargetConfigPanel.buildArgs.stackSize
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
/(\${exported_symbols_val})/,
|
/(\${exported_symbols_val})/,
|
||||||
TargetConfigPanel.BUILD_ARGS.exported_symbols
|
TargetConfigPanel.buildArgs.exportedSymbols
|
||||||
);
|
);
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
@ -187,8 +186,8 @@ export class TargetConfigPanel {
|
||||||
case 'config_build_target':
|
case 'config_build_target':
|
||||||
if (
|
if (
|
||||||
message.outputFileName === '' ||
|
message.outputFileName === '' ||
|
||||||
message.initmemSize === '' ||
|
message.initMemSize === '' ||
|
||||||
message.maxmemSize === '' ||
|
message.maxMemSize === '' ||
|
||||||
message.stackSize === '' ||
|
message.stackSize === '' ||
|
||||||
message.exportedSymbols === ''
|
message.exportedSymbols === ''
|
||||||
) {
|
) {
|
||||||
|
@ -197,13 +196,13 @@ export class TargetConfigPanel {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else if (
|
} else if (
|
||||||
this._configBuildArgs(
|
this.configBuildArgs(
|
||||||
message.outputFileName,
|
message.outputFileName,
|
||||||
message.initmemSize,
|
message.initMemSize,
|
||||||
message.maxmemSize,
|
message.maxMemSize,
|
||||||
message.stackSize,
|
message.stackSize,
|
||||||
message.exportedSymbols
|
message.exportedSymbols
|
||||||
) === TargetConfigPanel.EXCUTION_SUCCESS
|
) === TargetConfigPanel.executionSuccess
|
||||||
) {
|
) {
|
||||||
vscode.window
|
vscode.window
|
||||||
.showInformationMessage(
|
.showInformationMessage(
|
||||||
|
@ -211,7 +210,7 @@ export class TargetConfigPanel {
|
||||||
'OK'
|
'OK'
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this._panel.dispose();
|
this.viewPanel.dispose();
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -227,7 +226,7 @@ export class TargetConfigPanel {
|
||||||
|
|
||||||
private dispose() {
|
private dispose() {
|
||||||
TargetConfigPanel.currentPanel = undefined;
|
TargetConfigPanel.currentPanel = undefined;
|
||||||
this._panel.dispose();
|
this.viewPanel.dispose();
|
||||||
|
|
||||||
while (this._disposables.length) {
|
while (this._disposables.length) {
|
||||||
const disposable = this._disposables.pop();
|
const disposable = this._disposables.pop();
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"outDir": "out",
|
"outDir": "out",
|
||||||
"lib": [
|
"lib": ["es6"],
|
||||||
"es6"
|
"sourceMap": true,
|
||||||
],
|
"rootDir": "src",
|
||||||
"sourceMap": true,
|
"strict": true /* enable all strict type-checking options */
|
||||||
"rootDir": "src",
|
/* Additional Checks */
|
||||||
"strict": true /* enable all strict type-checking options */
|
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
/* Additional Checks */
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
},
|
||||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
"exclude": ["node_modules", ".vscode-test"]
|
||||||
},
|
|
||||||
"exclude": [
|
|
||||||
"node_modules",
|
|
||||||
".vscode-test"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user