Skip to content

Commit f87faec

Browse files
committed
Add libs generator
1 parent 45765e4 commit f87faec

File tree

9 files changed

+366
-102
lines changed

9 files changed

+366
-102
lines changed

package.json

Lines changed: 91 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,91 @@
499499
}
500500
],
501501
"commands": [
502+
{
503+
"command": "eide.open.makelibs.cfg",
504+
"category": "eide",
505+
"title": "%eide.function.open_libs.yml%"
506+
},
507+
{
508+
"command": "eide.reinstall.binaries",
509+
"category": "eide",
510+
"title": "%eide.function.reinstall.binaries%"
511+
},
512+
{
513+
"command": "eide.create.clang-format.file",
514+
"category": "eide",
515+
"title": "%eide.function.gen_clang_format%"
516+
},
517+
{
518+
"command": "eide.project.buildAndFlash",
519+
"category": "eide",
520+
"title": "%eide.project.buildAndFlash%"
521+
},
522+
{
523+
"command": "eide.project.build",
524+
"category": "eide",
525+
"title": "%eide.project.build%",
526+
"icon": {
527+
"dark": "./res/icon/BuildSelection_16x.svg",
528+
"light": "./res/icon/BuildSelection_16x.svg"
529+
}
530+
},
531+
{
532+
"command": "eide.project.rebuild",
533+
"category": "eide",
534+
"title": "%eide.project.rebuild%",
535+
"icon": {
536+
"dark": "./res/icon/BuildSolution_16x.svg",
537+
"light": "./res/icon/BuildSolution_16x.svg"
538+
}
539+
},
540+
{
541+
"command": "eide.project.clean",
542+
"category": "eide",
543+
"title": "%eide.project.clean%",
544+
"icon": {
545+
"dark": "./res/icon/clean_dark_16x.svg",
546+
"light": "./res/icon/clean_light_16x.svg"
547+
}
548+
},
549+
{
550+
"command": "eide.project.uploadToDevice",
551+
"title": "%eide.project.upload%",
552+
"category": "eide",
553+
"icon": {
554+
"dark": "./res/icon/TransferDownload_16x.svg",
555+
"light": "./res/icon/TransferDownload_16x.svg"
556+
}
557+
},
558+
{
559+
"command": "eide.project.flash.erase.all",
560+
"title": "%eide.project.flash.erase.all%",
561+
"category": "eide",
562+
"icon": {
563+
"dark": "./res/icon/TransferDownload_16x.svg",
564+
"light": "./res/icon/TransferDownload_16x.svg"
565+
}
566+
},
567+
{
568+
"command": "eide.ShowUUID",
569+
"category": "eide",
570+
"title": "%eide.function.show.uuid%"
571+
},
572+
{
573+
"command": "eide.c51ToSdcc",
574+
"category": "eide",
575+
"title": "%eide.function.convert.keil.to.sdcc%"
576+
},
577+
{
578+
"command": "eide.ReloadJlinkDevs",
579+
"category": "eide",
580+
"title": "%eide.function.reload.jlink.dev.list%"
581+
},
582+
{
583+
"command": "eide.ReloadStm8Devs",
584+
"category": "eide",
585+
"title": "%eide.function.reload.stm8.dev.list%"
586+
},
502587
{
503588
"command": "eide.project.save",
504589
"title": "%eide.project.save%"
@@ -523,16 +608,6 @@
523608
"command": "eide.operation.open_project",
524609
"title": "Open an eide project"
525610
},
526-
{
527-
"command": "eide.reinstall.binaries",
528-
"category": "eide",
529-
"title": "%eide.function.reinstall.binaries%"
530-
},
531-
{
532-
"command": "eide.create.clang-format.file",
533-
"category": "eide",
534-
"title": "Create a new .clang-format template file"
535-
},
536611
{
537612
"command": "_cl.eide.project.show_proj_vars",
538613
"title": "%eide.project.show_project_vars%"
@@ -701,66 +776,18 @@
701776
"command": "_cl.eide.project.setActive",
702777
"title": "%eide.project.active%"
703778
},
704-
{
705-
"command": "eide.project.buildAndFlash",
706-
"category": "eide",
707-
"title": "%eide.project.buildAndFlash%"
708-
},
709-
{
710-
"command": "eide.project.build",
711-
"category": "eide",
712-
"title": "%eide.project.build%",
713-
"icon": {
714-
"dark": "./res/icon/BuildSelection_16x.svg",
715-
"light": "./res/icon/BuildSelection_16x.svg"
716-
}
717-
},
718-
{
719-
"command": "eide.project.rebuild",
720-
"category": "eide",
721-
"title": "%eide.project.rebuild%",
722-
"icon": {
723-
"dark": "./res/icon/BuildSolution_16x.svg",
724-
"light": "./res/icon/BuildSolution_16x.svg"
725-
}
726-
},
727-
{
728-
"command": "eide.project.clean",
729-
"category": "eide",
730-
"title": "%eide.project.clean%",
731-
"icon": {
732-
"dark": "./res/icon/clean_dark_16x.svg",
733-
"light": "./res/icon/clean_light_16x.svg"
734-
}
735-
},
736-
{
737-
"command": "eide.project.uploadToDevice",
738-
"title": "%eide.project.upload%",
739-
"category": "eide",
740-
"icon": {
741-
"dark": "./res/icon/TransferDownload_16x.svg",
742-
"light": "./res/icon/TransferDownload_16x.svg"
743-
}
744-
},
745-
{
746-
"command": "eide.project.flash.erase.all",
747-
"title": "%eide.project.flash.erase.all%",
748-
"category": "eide",
749-
"icon": {
750-
"dark": "./res/icon/TransferDownload_16x.svg",
751-
"light": "./res/icon/TransferDownload_16x.svg"
752-
}
753-
},
754779
{
755780
"command": "_cl.eide.project.showBuildParams",
756781
"title": "%eide.project.show.commands%"
757782
},
758783
{
759784
"command": "_cl.eide.project.installCMSISHeaders",
785+
"category": "eide",
760786
"title": "Install CMSIS Core Headers"
761787
},
762788
{
763789
"command": "_cl.eide.project.installCmsisLibs",
790+
"category": "eide",
764791
"title": "Install CMSIS Core Libs"
765792
},
766793
{
@@ -1019,26 +1046,6 @@
10191046
"dark": "./res/icon/TableToFile_16x.svg",
10201047
"light": "./res/icon/TableToFile_16x.svg"
10211048
}
1022-
},
1023-
{
1024-
"command": "eide.ShowUUID",
1025-
"category": "eide",
1026-
"title": "%eide.function.show.uuid%"
1027-
},
1028-
{
1029-
"command": "eide.c51ToSdcc",
1030-
"category": "eide",
1031-
"title": "%eide.function.convert.keil.to.sdcc%"
1032-
},
1033-
{
1034-
"command": "eide.ReloadJlinkDevs",
1035-
"category": "eide",
1036-
"title": "%eide.function.reload.jlink.dev.list%"
1037-
},
1038-
{
1039-
"command": "eide.ReloadStm8Devs",
1040-
"category": "eide",
1041-
"title": "%eide.function.reload.stm8.dev.list%"
10421049
}
10431050
],
10441051
"keybindings": [
@@ -1330,6 +1337,10 @@
13301337
"command": "_cl.eide.project.show_proj_vars",
13311338
"when": "viewItem == SOLUTION && view == cl.eide.view.projects"
13321339
},
1340+
{
1341+
"command": "eide.open.makelibs.cfg",
1342+
"when": "viewItem == SOLUTION && view == cl.eide.view.projects"
1343+
},
13331344
{
13341345
"command": "_cl.eide.project.excludeSource",
13351346
"group": "inline",

package.nls.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"eide.function.reload.jlink.dev.list": "Reload JLink Devices List",
1212
"eide.function.reload.stm8.dev.list": "Reload STM8 Devices List",
1313
"eide.function.reinstall.binaries": "Reinstall eide binaries",
14+
"eide.function.gen_clang_format": "Create new .clang-format template file",
15+
"eide.function.open_libs.yml": "Open Libs Generator Configuration",
1416

1517
"eide.project.show_project_vars": "Show All Project Variables",
1618
"eide.project.save": "Save Project",
@@ -29,7 +31,7 @@
2931
"eide.project.upload": "Program Flash",
3032
"eide.project.flash.erase.all": "Erase Chip",
3133
"eide.project.modify.files.options": "Show Source Files Extra Compiler Options",
32-
"eide.project.import.ext.project.src.struct": "Import source tree from other projects",
34+
"eide.project.import.ext.project.src.struct": "Import SourceFile Tree From Other Project",
3335
"eide.project.generate_builder_params": "Generate builder.params",
3436

3537
"eide.prj.menus.main.cppcheck": "Static Check",

package.nls.zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"eide.function.reload.jlink.dev.list": "重新加载 JLink 芯片信息列表",
1212
"eide.function.reload.stm8.dev.list": "重新加载 STM8 芯片信息列表",
1313
"eide.function.reinstall.binaries": "重新安装 eide binaries",
14+
"eide.function.gen_clang_format": "新建 .clang-format 代码格式化配置模板",
15+
"eide.function.open_libs.yml": "打开lib生成器配置",
1416

1517
"eide.project.show_project_vars": "显示所有可用的项目变量",
1618
"eide.project.save": "保存项目",

res/data/template.libs.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
##########################################################################################
2+
# Generate libs for your project
3+
# syntax:
4+
# ---
5+
# <your lib name>:
6+
# - <obj file 1>
7+
# - <obj file 2>
8+
#
9+
# For more syntax, please refer to: https://www.npmjs.com/package/micromatch
10+
#
11+
##########################################################################################
12+
13+
## ----------------------------
14+
## examples
15+
## This examples will generate 2 libs after build done,
16+
## they are: 'app.lib', 'test.lib'
17+
## ----------------------------
18+
#app:
19+
# - '**/src/app.o'
20+
# - '**/src/a.o'
21+
# - '**/src/a/*.o'
22+
#
23+
#test:
24+
# - '**/test/app.o'
25+
# - '**/test/c.o'
26+
# - '**/test/c/*.o'

src/CodeBuilder.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,8 @@ export abstract class CodeBuilder {
131131
paramsModTime?: number;
132132
} {
133133

134-
const srcList: { path: string, virtualPath?: string; }[] = [];
135134
const srcParams: { [name: string]: string; } = {};
136-
const fGoups = this.project.getFileGroups();
137-
const filter = AbstractProject.getSourceFileFilter();
138-
139-
// filter source files
140-
for (const group of fGoups) {
141-
if (group.disabled) continue; // skip disabled group
142-
for (const source of group.files) {
143-
if (source.disabled) continue; // skip disabled file
144-
if (!filter.some((reg) => reg.test(source.file.path))) continue; // skip non-source
145-
const rePath = this.project.ToRelativePath(source.file.path);
146-
const fInfo: any = { path: rePath || source.file.path }
147-
if (AbstractProject.isVirtualSourceGroup(group)) {
148-
fInfo.virtualPath = `${group.name}/${source.file.name}`;
149-
}
150-
srcList.push(fInfo);
151-
}
152-
}
135+
const srcList: { path: string, virtualPath?: string; }[] = this.project.getAllSources();
153136

154137
// append user options for files
155138
try {
@@ -483,6 +466,25 @@ export abstract class CodeBuilder {
483466
// handle options
484467
this.preHandleOptions(builderOptions.options);
485468

469+
// gen libs.makefile
470+
const mkfile = File.fromArray([this.project.ToAbsolutePath(outDir), 'libs.makefile']);
471+
const mk_txt = this.project.genLibsMakefileContent(mkfile.name);
472+
if (mk_txt) {
473+
try {
474+
mkfile.Write(mk_txt);
475+
let command: any = {
476+
name: 'make libs',
477+
command: `make --directory=./${outDir} --makefile=./${mkfile.name} all`
478+
};
479+
if (builderOptions.options.afterBuildTasks == undefined)
480+
builderOptions.options.afterBuildTasks = [];
481+
builderOptions.options.afterBuildTasks = [command].concat(builderOptions.options.afterBuildTasks);
482+
} catch (error) {
483+
GlobalEvent.emit('msg', newMessage('Warning', `Generating '${mkfile.name}' failed !`));
484+
GlobalEvent.emit('globalLog', ExceptionToMessage(error, 'Error'));
485+
}
486+
}
487+
486488
// generate hash for compiler options
487489
builderOptions.sha = this.genHashFromCompilerOptions(builderOptions);
488490

0 commit comments

Comments
 (0)