Implement WAMR-IDE with vscode extension (#943)

Implement WAMR-IDE with vscode extension to enable developing
WebAssembly applications with coding, building, running and
debugging support. Support both Linux and Windows, and only
support putting all the tools in a docker image, e.g. wasi-sdk, wamrc,
iwasm and so on.

Co-authored-by: Wang Ning <justdoitwn@163.com>
This commit is contained in:
Wenyong Huang
2022-01-25 10:10:12 +08:00
committed by GitHub
parent 90a0057d33
commit d925369a1f
66 changed files with 2769 additions and 0 deletions

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
import fileSystem = require('fs');
import vscode = require('vscode');
import path = require('path');
/**
*
* @param path destination path
*/
export function CreateDirectory(
dest: string,
mode: string | number | null | undefined = undefined
): boolean {
try {
if (fileSystem.existsSync(dest)) {
if (fileSystem.lstatSync(dest).isDirectory()) {
return true;
} else {
return false;
}
}
if (!path) {
return false;
}
let parent = path.dirname(dest);
if (!CreateDirectory(parent, mode)) {
return false;
}
fileSystem.mkdirSync(dest, mode);
return true;
} catch (error) {
vscode.window.showErrorMessage(error as string);
return false;
}
}
export function CopyFiles(src: string, dest: string, flags?: number): boolean {
try {
fileSystem.copyFileSync(src, dest);
return true;
} catch (error) {
vscode.window.showErrorMessage(error as string);
return false;
}
}
export function WriteIntoFile(path: string, data: string): void {
try {
fileSystem.writeFileSync(path, data, null);
} catch (err) {
vscode.window.showErrorMessage(err as string);
}
}
export function ReadFromFile(path: string): string {
try {
let data = fileSystem.readFileSync(path, { encoding: 'utf-8' });
return data as string;
} catch (err) {
vscode.window.showErrorMessage(err as string);
return '';
}
}
export function WriteIntoFileAsync(
path: string,
data: string,
callback: fileSystem.NoParamCallback
): void {
try {
fileSystem.writeFile(path, data, callback);
} catch (err) {
vscode.window.showErrorMessage(err as string);
return;
}
}

View File

@ -0,0 +1,14 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
import { Uri, Webview } from 'vscode';
export function getUri(
webview: Webview,
extensionUri: Uri,
pathList: string[]
) {
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
}