目前vscode中的rt_studio插件主要支持的是以scons环境的编译,但是RT_Studio使用的是makefile,直接使用vscode打开点击编译是失败的,刚开始我试着把RT_Studio中的项目修改为scons编译,试了一下,编译通过,但是有个Hard警告“warning: cannot find entry symbol Reset_Handler; defaulting to 0000000008000000”,下载到板子后也不运行,网上找了好几种方法,也没有得到很好的解决,后面想了一下,RT_Studio默认创建的就是makefile项目,总不能创建一个项目修改一个项目吧,那还不如直接修改vscode的插件,做个兼容,还一劳永逸。
建议先看一下VS_Code RT_Thread环境搭建与问题解决(一)-CSDN博客
1.修改编译的地方 搜索 scons -j定位到地方,把run修改为如下
run() { this.terminal.sendText(c.getClsLabel());const e = new n.RttStudioSetting("RTT_Studio.Build.Parallel_Jobs"),t = String(e.getSettingValue(this.targetFolder));const fs = require('fs');const debugDir = this.location + "/Debug";if (fs.existsSync(debugDir)) {//return t ? this.terminal.sendText(`make -C ${debugDir} -j ` + t) : this.terminal.sendText(`make -C ${debugDir}`),!0 this.terminal.sendText(`make -C ${debugDir}`),!0 }else {return t ? this.terminal.sendText("scons -j " + t) : this.terminal.sendText("scons"),!0}}
上图是解压缩的样子,注释那里是因为我电脑在vscode使用make -j会卡死,所以只采用了下面那句,如果你电脑不会出现这种问题,可以把注释去掉,然后把下一句注释或者删除都行。
2.修改清除的地方,搜索scons -c定位到地方,把run修改为如下
run() {const fs = require('fs');const debugDir = this.location + "/Debug"; if (fs.existsSync(debugDir)) {return this.terminal.sendText(s.getCDLabel() + this.location), this.terminal.sendText(s.getClsLabel()), this.terminal.sendText(`make clean -C ${debugDir}`), !0}else {return this.terminal.sendText(s.getCDLabel() + this.location), this.terminal.sendText(s.getClsLabel()), this.terminal.sendText("scons -c"), !0}}
保存重启vscode即可