opensumi / ide-electron

OpenSumi Electron Version
https://opensumi.com
MIT License
171 stars 56 forks source link

如何调用我们开发的编译器? #67

Closed justin2gh closed 1 year ago

justin2gh commented 1 year ago

我们想集成我们开发的汇编编译器到opensumi,如何调用?我们的编译器已经编译成Windows平台的exe文件,已经可以通过命令行调用执行: C:\compiler.exe C:\projectsFolder

yantze commented 1 year ago

都可以用插件的方式集成

  1. 可以用 task 的方式,OpenSumi 的插件兼容 VSCode https://code.visualstudio.com/Docs/editor/tasks
  2. 使用 Terminal 的方式 https://code.visualstudio.com/api/references/vscode-api createTerminal 接口
justin2gh commented 1 year ago

我们不想用插件的方式,那会展示在插件列表里面,我们已经实现了在vscode上以插件的形式完成项目代码的编译,我们希望直接集成到opensumi

erha19 commented 1 year ago

@justin2gh 可以详细描述一下具体需求,集成到哪里?在哪里调用?以什么方式调用等。

另外,本身你也可以依赖前后端的通信能力,在后端 Node 进程中执行任意自定义脚本,可以参考案例:

https://opensumi.com/zh/docs/develop/sample/overview

justin2gh commented 1 year ago

我们开发了我们自己的MCU,正在寻找IDE框架集成我们的编译器,我们希望完整的定制编译器的功能。正在尝试在opensumi上做相关探索,发现资料和案例很少,定制起来很困难。以下是第一阶段的需求:

IDE Stage 1 OKR

Objective: Successfully develop a customized desktop IDE software based on opensumi(Electron), and promote it to the market.

Key Result 1: Integrate the assembler compiler and successfully integrate it

Key Result 2: Assemble project compilation by clicking icons or command panels

Key Result 3: Implement error locating function

Key Result 4: Package the IDE tool project into an exe installation file and provide it to customers for use

Key Result 5: UI interface conforms to the company's brand identification, including logo, about, etc.

justin2gh commented 1 year ago

以下代码已经在VScode中,把编译器以扩展插件的方式集成到VScode。

import as vscode from 'vscode'; import as child_process from 'child_process';

let BuildStatusBarItem:vscode.StatusBarItem;

export function activate(context: vscode.ExtensionContext) {

BuildStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left,100); BuildStatusBarItem.command = ".compile"; BuildStatusBarItem.text = " Build";

let cmdBuild = vscode.commands.registerCommand('.compile', async () => { var CompilerPath:string = context.extensionPath + "\" + "compiler.exe"; let outputChannel = vscode.window.createOutputChannel(" Compiler Output");

let child = child_process.execFile(CompilerPath, [getWorkingDir()], (error, stdout, stderr) => {
  if (error !== null) {
    outputChannel.appendLine(`Error: ${error.message}`);
  }
  outputChannel.appendLine(stdout);
  outputChannel.appendLine(stderr);
});

child.stdout?.on('data', (data: string) => {
  outputChannel.append(data);
});

child.stderr?.on('data', (data: string) => {
  outputChannel.append(data);
});

outputChannel.show();

});

context.subscriptions.push(BuildStatusBarItem); context.subscriptions.push(cmdBuild); BuildStatusBarItem.show();

}

function getWorkingDir():string{ if(vscode.workspace.workspaceFolders !== undefined) { var wd:string = capitalizeFirstLetter(vscode.workspace.workspaceFolders[0].uri.fsPath) + "\" ; return wd; } else { let message = "Working folder not found, open a folder an try again" ; vscode.window.showErrorMessage(message); return ""; } }

function capitalizeFirstLetter(input: string): string { if (input.length === 0) { return ""; }

const firstChar = input.charAt(0).toUpperCase(); const restOfString = input.slice(1);

return ${firstChar}${restOfString}; }

justin2gh commented 1 year ago

by the way, 基于opensumi定制IDE,需要开发人员具备哪些技能?

erha19 commented 1 year ago

@justin2gh 我们提供了一些拓展案例,可以看这里 https://github.com/opensumi/opensumi-module-samples#samples ,看你这里的基础逻辑,其实只需要把执行构建的逻辑封装为一个 Node 层方法即可,可以参考 Connection Sample 这个案例。

基于opensumi定制IDE,需要开发人员具备哪些技能?

NodeJS/Typescript/React 开发能力,辅助性的如:VS Code 插件开发经验,依赖注入,Electron 开发知识

justin2gh commented 1 year ago

@erha19 非常感谢,后续开发过程中有问题再来提问。