-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathextension.ts
1906 lines (1550 loc) · 77 KB
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
MIT License
Copyright (c) 2019 github0null
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as os from 'os';
import * as node7z from 'node-7z';
import * as NodePath from 'path';
import * as ChildProcess from 'child_process';
import * as yaml from 'yaml';
import { GlobalEvent } from './GlobalEvents';
import { OperationExplorer } from './OperationExplorer';
import { ProjectExplorer } from './EIDEProjectExplorer';
import { ResManager } from './ResManager';
import { LogAnalyzer } from './LogAnalyzer';
import { ResInstaller } from './ResInstaller';
import {
ERROR, WARNING, INFORMATION,
view_str$operation$serialport, view_str$operation$baudrate, view_str$operation$serialport_name,
txt_install_now, txt_yes, view_str$prompt$feedback, rating_text, later_text, sponsor_author_text
} from './StringTable';
import { LogDumper } from './LogDumper';
import { StatusBarManager } from './StatusBarManager';
import { File } from '../lib/node-utility/File';
import { newMessage, ExceptionToMessage } from './Message';
import { SettingManager } from './SettingManager';
import { WorkspaceManager } from './WorkspaceManager';
import { VirtualDocument } from './VirtualDocsProvider';
import * as utility from './utility';
import * as platform from './Platform';
const extension_deps: string[] = [];
let projectExplorer: ProjectExplorer;
let operationExplorer: OperationExplorer;
// set yaml global style
yaml.scalarOptions.str.fold.lineWidth = 1000;
yaml.defaultOptions.indent = 4;
yaml.defaultOptions.indentSeq = true;
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export async function activate(context: vscode.ExtensionContext) {
// init event emiter
RegisterGlobalEvent();
RegisterMsgListener();
GlobalEvent.log_info('Embedded IDE launch begin');
// init platform
try {
platform.init();
} catch (error) {
const msg = (<Error>error).message;
vscode.window.showErrorMessage(msg);
GlobalEvent.log_error(msg);
return;
}
// try active dependence plug-ins
for (const name of extension_deps) {
const extension = vscode.extensions.getExtension(name);
if (extension) {
if (!extension.isActive) {
try {
GlobalEvent.log_info(`Active extension: '${name}'`);
await extension.activate();
} catch (error) {
GlobalEvent.log_warn(error);
}
}
} else {
GlobalEvent.log_warn(`The extension '${name}' is not enabled or installed !`);
}
}
// init eide components
const done = await InitComponents(context);
if (!done) {
vscode.window.showErrorMessage(`${ERROR} : Install eide binaries failed !, You can download offline [vsix package](https://github.com/github0null/eide/releases) and install it !`);
return;
}
// register vscode commands
const subscriptions = context.subscriptions;
// global user commands
subscriptions.push(vscode.commands.registerCommand('eide.ShowUUID', () => ShowUUID()));
subscriptions.push(vscode.commands.registerCommand('eide.c51ToSdcc', () => c51ToSDCC()));
subscriptions.push(vscode.commands.registerCommand('eide.ReloadJlinkDevs', () => reloadJlinkDevices()));
subscriptions.push(vscode.commands.registerCommand('eide.ReloadStm8Devs', () => reloadStm8Devices()));
subscriptions.push(vscode.commands.registerCommand('eide.create.clang-format.file', () => newClangFormatFile()));
subscriptions.push(vscode.commands.registerCommand('eide.cleanCache', () => cleanCache()));
// internal command
// TODO
// operations
operationExplorer = new OperationExplorer(context);
subscriptions.push(vscode.commands.registerCommand('_cl.eide.Operation.Open', () => operationExplorer.OnOpenProject()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.Operation.Create', () => operationExplorer.OnCreateProject()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.Operation.Import', () => operationExplorer.OnImportProject()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.Operation.SetToolchainPath', () => operationExplorer.OnSetToolchainPath()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.Operation.SetupUtilTools', () => operationExplorer.setupUtilTools()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.Operation.openSettings', () => SettingManager.jumpToSettings('@ext:cl.eide')));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.Operation.onlineHelp', () => utility.openUrl('https://discuss.em-ide.com')));
// operations user cmds
subscriptions.push(vscode.commands.registerCommand('eide.operation.install_toolchain', () => operationExplorer.OnSetToolchainPath()));
subscriptions.push(vscode.commands.registerCommand('eide.operation.import_project', () => operationExplorer.OnImportProject()));
subscriptions.push(vscode.commands.registerCommand('eide.operation.new_project', () => operationExplorer.OnCreateProject()));
subscriptions.push(vscode.commands.registerCommand('eide.operation.open_project', () => operationExplorer.OnOpenProject()));
// projects
projectExplorer = new ProjectExplorer(context);
subscriptions.push(vscode.commands.registerCommand('_cl.eide.workspace.build', () => projectExplorer.buildWorkspace()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.workspace.rebuild', () => projectExplorer.buildWorkspace(true)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.workspace.open.config', () => projectExplorer.openWorkspaceConfig()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.workspace.make.template', (item) => projectExplorer.ExportProjectTemplate(undefined, true)));
// project user cmds
subscriptions.push(vscode.commands.registerCommand('eide.project.save', (item) => projectExplorer.saveProject(item)));
subscriptions.push(vscode.commands.registerCommand('eide.project.rebuild', (item) => projectExplorer.BuildSolution(item)));
subscriptions.push(vscode.commands.registerCommand('eide.project.build', (item) => projectExplorer.BuildSolution(item, { not_rebuild: true })));
subscriptions.push(vscode.commands.registerCommand('eide.project.clean', (item) => projectExplorer.BuildClean(item)));
subscriptions.push(vscode.commands.registerCommand('eide.project.uploadToDevice', (item) => projectExplorer.UploadToDevice(item)));
subscriptions.push(vscode.commands.registerCommand('eide.reinstall.binaries', () => checkAndInstallBinaries(true)));
subscriptions.push(vscode.commands.registerCommand('eide.project.flash.erase.all', (item) => projectExplorer.UploadToDevice(item, true)));
subscriptions.push(vscode.commands.registerCommand('eide.project.buildAndFlash', (item) => projectExplorer.BuildSolution(item, { not_rebuild: true, flashAfterBuild: true })));
subscriptions.push(vscode.commands.registerCommand('eide.project.genBuilderParams', (item) => projectExplorer.BuildSolution(item, { not_rebuild: true, onlyDumpBuilderParams: true })));
subscriptions.push(vscode.commands.registerCommand('eide.open.makelibs.cfg', (item) => projectExplorer.openLibsGeneratorConfig(item)));
// operations bar
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.historyRecord', () => projectExplorer.openHistoryRecords()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.clearHistoryRecord', () => projectExplorer.clearAllHistoryRecords()));
// project
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.showBuildParams', (item) => projectExplorer.BuildSolution(item, { onlyDumpCompilerInfo: true })));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.setActive', (item) => projectExplorer.setActiveProject(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.close', (item) => projectExplorer.Close(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.saveAll', () => projectExplorer.SaveAll()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.refresh', () => projectExplorer.Refresh()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.switchMode', (item) => projectExplorer.switchTarget(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.exportAsTemplate', (item) => projectExplorer.ExportProjectTemplate(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.exportXml', (item) => projectExplorer.ExportKeilXml(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.exportMakefile', (item) => projectExplorer.ExportMakefile(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.show_proj_vars', (item) => projectExplorer.ShowProjectVariables(item)));
// project explorer
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.addSrcDir', (item) => projectExplorer.AddSrcDir(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.removeSrcDir', (item) => projectExplorer.RemoveSrcDir(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.sourceRoot.refresh', (item) => projectExplorer.refreshSrcRoot(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.modify.files.options', (item) => projectExplorer.showFilesOptions(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.import.ext.source.struct', (item) => projectExplorer.ImportSourceFromExtProject(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.modify.exclude_list', (item) => projectExplorer.openYamlConfig(item, 'src-exc-cfg')));
// symbol view editor commands
const virtDoc = VirtualDocument.instance();
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.symbol_view.sort_by_addr',
(url) => virtDoc.updateDocument(url.fsPath, undefined, 'addr', virtDoc.getLastGetterArgs(url.fsPath)[1])));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.symbol_view.sort_by_size',
(url) => virtDoc.updateDocument(url.fsPath, undefined, 'size', virtDoc.getLastGetterArgs(url.fsPath)[1])));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.symbol_view.disp_hide_no_sized',
(url) => virtDoc.updateDocument(url.fsPath, undefined, virtDoc.getLastGetterArgs(url.fsPath)[0], 'hide_no_sized')));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.symbol_view.disp_show_all',
(url) => virtDoc.updateDocument(url.fsPath, undefined, virtDoc.getLastGetterArgs(url.fsPath)[0], 'show_all')));
// filesystem files
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.filesystem_folder_add_file', (item) => projectExplorer.fs_folderAddFile(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.filesystem_folder_add', (item) => projectExplorer.fs_folderAdd(item)));
// virtual files
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.virtual_folder_add_file', (item) => projectExplorer.Virtual_folderAddFile(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.virtual_folder_add', (item) => projectExplorer.Virtual_folderAdd(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.virtual_folder_remove', (item, items) => projectExplorer.Virtual_removeFolder(item, items)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.virtual_folder_rename', (item) => projectExplorer.Virtual_renameFolder(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.virtual_file_remove', (item, items) => projectExplorer.Virtual_removeFile(item, items)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.file.modify.extraArgs', (item) => projectExplorer.modifyExtraCompilerArgs('file', item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.file.compile', (item) => projectExplorer.compileSingleFile(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.folder.modify.extraArgs', (item) => projectExplorer.modifyExtraCompilerArgs('folder', item)));
// file other operations
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.excludeSource', (item, items) => projectExplorer.ExcludeSourceFile(item, items)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.unexcludeSource', (item, items) => projectExplorer.UnexcludeSourceFile(item, items)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.excludeFolder', (item, items) => projectExplorer.ExcludeFolder(item, items, false)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.unexcludeFolder', (item, items) => projectExplorer.UnexcludeFolder(item, items, false)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.excludeFolder.childSrcs', (item, items) => projectExplorer.ExcludeFolder(item, items, true)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.unexcludeFolder.childSrcs', (item, items) => projectExplorer.UnexcludeFolder(item, items, true)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.file.show.dir', (item) => projectExplorer.showFileInExplorer(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.modify.path', (item) => projectExplorer.openYamlConfig(item, 'src-path-cfg')));
// package
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.removePackage', (item) => projectExplorer.UninstallKeilPackage(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.addPackage', (item) => projectExplorer.InstallKeilPackage(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.setDevice', (item) => projectExplorer.SetDevice(item.val.projectIndex)));
// - cmsis core packages
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCMSISHeaders', (item) => projectExplorer.installCmsisSourcePack(item, 'header')));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCmsisLibs', (item) => projectExplorer.installCmsisSourcePack(item, 'lib')));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.installCmsisDriverInterface', (item) => projectExplorer.installCmsisSourcePack(item, 'idrv')));
// builder
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.modifyCompileConfig', (item) => projectExplorer.ModifyCompileConfig(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.modifyCompileConfig.openFile', (item) => projectExplorer.ModifyCompileConfig_openFile(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.switchToolchain', (item) => projectExplorer.onSwitchCompileTools(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.configToolchain', (item) => projectExplorer.onConfigureToolchain(item)));
// flasher
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.modifyUploadConfig', (item) => projectExplorer.ModifyUploadConfig(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.switchUploader', (item) => projectExplorer.switchUploader(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.fetchShellFlasher', (item) => projectExplorer.fetchShellFlasher(item)));
// debug cfg gen
subscriptions.push(vscode.commands.registerCommand(
'_cl.eide.project.genDebugConfigTemplate.jlink', (item) => projectExplorer.genDebugConfigTemplate(item, 'jlink')));
subscriptions.push(vscode.commands.registerCommand(
'_cl.eide.project.genDebugConfigTemplate.openocd', (item) => projectExplorer.genDebugConfigTemplate(item, 'openocd')));
subscriptions.push(vscode.commands.registerCommand(
'_cl.eide.project.genDebugConfigTemplate.pyocd', (item) => projectExplorer.genDebugConfigTemplate(item, 'pyocd')));
// project deps
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.addIncludeDir', (item) => projectExplorer.AddIncludeDir(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.addDefine', (item) => projectExplorer.AddDefine(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.addLibDir', (item) => projectExplorer.AddLibDir(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.showIncludeDir', (item) => projectExplorer.showIncludeDir(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.showDefine', (item) => projectExplorer.showDefine(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.showLibDir', (item) => projectExplorer.showLibDir(item.val.projectIndex)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.modifyOtherSettings', (item) => projectExplorer.ModifyOtherSettings(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.modify.deps', (item) => projectExplorer.openYamlConfig(item, 'prj-attr-cfg')));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.editDependenceItem', (item) => projectExplorer.editDependenceItem(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.removeDependenceItem', (item) => projectExplorer.RemoveDependenceItem(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.importDependenceFromPack', (item) => projectExplorer.ImportPackageDependence(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.removeDependenceFromPack', (item) => projectExplorer.RemovePackageDependence(item)));
// tree view global
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.copyItemValue', (item) => projectExplorer.CopyItemValue(item)));
// other project tools
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.show_disassembly', (url) => projectExplorer.showDisassembly(url)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.source.show_cmsis_config_wizard', (url) => projectExplorer.showCmsisConfigWizard(url)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.static-check.cppcheck', (item) => projectExplorer.cppcheckProject(item)));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.static-check.clear', (item) => projectExplorer.clearCppcheckDiagnostic()));
//subscriptions.push(vscode.commands.registerCommand('_cl.eide.project.cppcheck.check_file', (url) => projectExplorer.cppcheckFile(url)));
operationExplorer.on('request_open_project', (fsPath) => projectExplorer.emit('request_open_project', fsPath));
operationExplorer.on('request_create_project', (option) => projectExplorer.emit('request_create_project', option));
operationExplorer.on('request_create_from_template', (option) => projectExplorer.emit('request_create_from_template', option));
operationExplorer.on('request_import_project', (option) => projectExplorer.emit('request_import_project', option));
// status bar
//subscriptions.push(vscode.commands.registerCommand('_cl.eide.statusbar.switch-project', () => projectExplorer.showQuickPickAndSwitchActiveProject()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.statusbar.switch-target', () => projectExplorer.showQuickPickAndSwitchActiveTarget()));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.statusbar.build', () => projectExplorer.BuildSolution(undefined, { not_rebuild: true })));
subscriptions.push(vscode.commands.registerCommand('_cl.eide.statusbar.flash', () => projectExplorer.UploadToDevice(undefined)));
// others
vscode.workspace.registerTextDocumentContentProvider(VirtualDocument.scheme, VirtualDocument.instance());
vscode.workspace.registerTaskProvider(EideTaskProvider.TASK_TYPE_BASH, new EideTaskProvider());
// auto save project
projectExplorer.enableAutoSave(true);
// load project in this workspace
projectExplorer.loadWorkspace();
// hook
postLaunchHook(context);
// launch done
GlobalEvent.emit('extension_launch_done');
GlobalEvent.log_info('Embedded IDE launch done');
}
// this method is called when your extension is deactivated
export function deactivate() {
projectExplorer.onDispose();
operationExplorer.onDispose();
ResManager.instance().onDispose();
LogDumper.getInstance().onDispose();
StatusBarManager.getInstance().disposeAll();
}
function postLaunchHook(extensionCtx: vscode.ExtensionContext) {
const resManager = ResManager.instance();
const appUsrData = resManager.getAppUsrData() || {};
const isFirstLaunch = appUsrData['InstallTime'] == undefined;
// is first launch ?
if (isFirstLaunch) {
// setup install time
resManager.setAppUsrData('InstallTime', Date.now().toString());
// only enable github proxy for GMT+8:00 by default
const timeZone = Math.floor((new Date().getTimezoneOffset() / 60) * -1);
if (timeZone != 8) {
// disable settings: 'EIDE.Repository.UseProxy'
SettingManager.GetInstance().setConfigValue('Repository.UseProxy', false);
}
}
// not first launch
else {
// A few days ago, show feedback message
const some_days = 7 * (24 * 3600 * 1000);
if (!appUsrData['Feedbacked'] &&
Date.now() - appUsrData['InstallTime'] > some_days) {
resManager.setAppUsrData('Feedbacked', true);
const msg = view_str$prompt$feedback;
vscode.window.showInformationMessage(msg, rating_text, sponsor_author_text).then((ans) => {
if (ans == rating_text) {
utility.openUrl(`https://marketplace.visualstudio.com/items?itemName=CL.eide&ssr=false#review-details`);
}
if (ans == sponsor_author_text) {
// https://em-ide.com/sponsor
utility.openUrl(`https://em-ide.com/sponsor`);
}
});
}
}
// refresh external tools now
ResInstaller.instance()
.refreshExternalToolsIndex()
.catch(err => GlobalEvent.log_warn(err));
}
//////////////////////////////////////////////////
// internal vsc-commands funcs
//////////////////////////////////////////////////
function ShowUUID() {
vscode.window.showInputBox({
value: platform.GetUUID()
});
}
function reloadJlinkDevices() {
if (ResManager.GetInstance().loadJlinkDevList()) {
GlobalEvent.emit('msg', newMessage('Info', 'Done !, JLink devices list has been reloaded !'));
}
}
function reloadStm8Devices() {
if (ResManager.GetInstance().loadStm8DevList()) {
GlobalEvent.emit('msg', newMessage('Info', 'Done !, STM8 devices list has been reloaded !'));
}
}
async function newClangFormatFile() {
let root = WorkspaceManager.getInstance().getWorkspaceRoot();
if (!root) {
const li = WorkspaceManager.getInstance().getWorkspaceList();
if (li.length > 0) {
root = li[0];
}
}
if (root) {
const fSrc = File.fromArray([ResManager.GetInstance().GetAppDataDir().path, '.clang-format']);
fs.copyFileSync(fSrc.path, [root.path, '.clang-format'].join(File.sep));
vscode.window.showInformationMessage(`.clang-format file was created in '${fSrc.dir}' !`);
} else {
vscode.window.showWarningMessage(`No opened workspace or folders !`);
}
}
function cleanCache() {
try {
platform.DeleteAllChildren(ResManager.instance().GetTmpDir());
GlobalEvent.emit('msg', newMessage('Info', 'Done.'));
} catch (error) {
GlobalEvent.log_error(error);
}
}
//////////////////////////////////////////////////
// eide binaries installer
//////////////////////////////////////////////////
function checkBinFolder(binFolder: File): boolean {
return binFolder.IsDir() &&
File.fromArray([binFolder.path, 'VERSION']).IsFile();
}
async function checkAndInstallBinaries(forceInstall?: boolean): Promise<boolean> {
const resManager = ResManager.GetInstance();
const binFolder = resManager.GetBinDir();
const eideCfg = resManager.getAppConfig<any>();
const minReqVersion = eideCfg['binary_min_version'];
// !! for compatibility with offline-package !!
// if we found eide binaries in plug-in root folder, move it
const builtInBinFolder = File.fromArray([resManager.getAppRootFolder().path, 'bin'])
if (checkBinFolder(builtInBinFolder)) {
if (os.platform() == 'win32') {
ChildProcess.execSync(`xcopy "${builtInBinFolder.path}" "${binFolder.path}\\" /H /E /Y`);
platform.DeleteDir(builtInBinFolder); // rm it after copy done !
} else {
platform.DeleteDir(binFolder); // rm existed folder
ChildProcess.execSync(`mv -f "${builtInBinFolder.path}" "${binFolder.dir}/"`);
}
}
/* check eide binaries */
// if user force reinstall, delete old 'bin' dir
if (forceInstall) {
platform.DeleteDir(binFolder);
}
// if binaries is installed, we need check binaries's version
else if (checkBinFolder(binFolder)) {
let localVersion: string | undefined;
// get local binary version from disk
// check binaries Main_Ver (<Main_Ver>.xx.xx <=> <Main_Ver>.xx.xx)
const verFile = File.fromArray([binFolder.path, 'VERSION']);
if (verFile.IsFile()) {
const cont = verFile.Read().trim();
if (utility.isVersionString(cont)) {
localVersion = cont;
const mainLocalVersion = parseInt(localVersion.split('.')[0]);
const mainMinReqVersion = parseInt(minReqVersion.split('.')[0]);
if (mainMinReqVersion != mainLocalVersion) { // local Main verson != min Main version
localVersion = undefined; // local binaries is invalid, force update
}
}
}
// try fetch update after 5sec delay
if (localVersion) {
setTimeout(async (curLocalVersion: string) => {
const done = await tryUpdateBinaries(binFolder, curLocalVersion, true); // no prompt
if (!done) {
const msg = `Update eide-binaries failed, please restart vscode to try again !`;
const sel = await vscode.window.showErrorMessage(msg, 'Restart', 'Cancel');
if (sel == 'Restart') {
vscode.commands.executeCommand('workbench.action.reloadWindow');
}
}
}, 5 * 1000, localVersion);
}
// binaries folder is existed, but can not get local binaries version,
// the binaries maybe damaged, we need to force reinstall it
else {
platform.DeleteDir(binFolder); // del existed folder
return await tryUpdateBinaries(binFolder, undefined, true);
}
// export current binaries version
if (localVersion) {
process.env['EIDE_BINARIES_VER'] = localVersion;
}
// clean legacy builder/bin folder
cleanLegacyUnifyBuilder();
return true;
}
// not found binaries folder, install it
return await tryUpdateBinaries(binFolder, undefined, true);
}
async function tryUpdateBinaries(binFolder: File, localVer?: string, notConfirm?: boolean): Promise<boolean> {
const eideCfg = ResManager.GetInstance().getAppConfig<any>();
const minReqVersion = eideCfg['binary_min_version'];
const getVersionFromRepo = async (): Promise<string | Error | undefined> => {
try {
const url = `https://api.github.com/repos/github0null/eide-resource/contents/binaries/${platform.getRuntimeId()}/VERSION`;
const cont = await utility.requestTxt(utility.redirectHost(url));
if (typeof cont != 'string') return cont;
let obj: any = undefined;
try { obj = JSON.parse(cont); } catch (error) { return error; }
if (typeof obj.content != 'string') return obj.content;
return Buffer.from(obj.content, 'base64').toString();
} catch (error) {
return error;
}
};
const getAvailableBinariesVersions = async (): Promise<string[] | Error | undefined> => {
try {
const url = `https://api.github.com/repos/github0null/eide-resource/contents/binaries/${platform.getRuntimeId()}`;
const fList = await utility.readGithubRepoFolder(utility.redirectHost(url));
if (fList instanceof Error) throw fList;
return fList.filter(f => f.name.startsWith('bin-'))
.map(f => f.name.replace('bin-', '').replace('.7z', ''))
.filter(vStr => utility.isVersionString(vStr));
} catch (error) {
return error;
}
};
let preinstallVersion: string | undefined;
// compare version if local version is available
if (localVer) {
const newVersion = await getVersionFromRepo();
if (typeof newVersion == 'string') {
const remotVer = newVersion.trim();
if (utility.isVersionString(remotVer)) {
const localMainVer: string = localVer.split('.')[0];
const remotMainVer: string = remotVer.split('.')[0];
if (localMainVer == remotMainVer && // main version number must be equal
utility.compareVersion(remotVer, localVer) > 0) { // remote version > local version ?
preinstallVersion = remotVer; // local binaries need update
}
}
}
}
// can not match version, get version list from repo
// select the latest version for min version requirment
else {
const vList = await getAvailableBinariesVersions();
if (vList && Array.isArray(vList)) {
const minMainVer: string = minReqVersion.split('.')[0];
const validVerList = vList.filter(ver => ver.split('.')[0] == minMainVer);
if (validVerList.length > 0) {
preinstallVersion = validVerList[0];
for (const ver of validVerList) {
if (utility.compareVersion(ver, preinstallVersion) > 0) {
preinstallVersion = ver;
}
}
}
}
}
// check version
if (localVer) { // binaries is installed, found local version
if (preinstallVersion == undefined) {
return true; // local version is latested, not need update
}
} else { // binaries is not installed
if (preinstallVersion == undefined) {
const err = new Error(`Can not fetch binaries version from remote github repo (binaries minimum version required: '${minReqVersion}'), Check your network and retry !`);
GlobalEvent.emit('error', err);
return false;
}
}
// check bin folder
// show notify to user and request a confirm
if (checkBinFolder(binFolder) && preinstallVersion) {
if (!notConfirm) {
const msg = `New update for eide binaries, version: '${preinstallVersion}', [ChangeLog](https://github.com/github0null/eide-resource/pulls?q=is%3Apr+is%3Aclosed), install now ?`;
const sel = await vscode.window.showInformationMessage(msg, 'Yes', 'Later');
if (sel != 'Yes') { return true; } // user canceled
}
// del old bin folder before install
platform.DeleteDir(binFolder);
}
return await tryInstallBinaries(binFolder, preinstallVersion);
}
async function tryInstallBinaries(binFolder: File, binVersion: string): Promise<boolean> {
// zip type
const binType = '7z';
// binaries download site
let downloadSites: string[] = [
`https://raw-github.em-ide.com/github0null/eide-resource/master/binaries/${platform.getRuntimeId()}/bin-${binVersion}.${binType}`,
`https://raw.githubusercontent.com/github0null/eide-resource/master/binaries/${platform.getRuntimeId()}/bin-${binVersion}.${binType}`
];
// random order
{
const sValMap: Map<string, number> = new Map();
downloadSites.forEach(s => sValMap.set(s, Math.floor(Math.random() * 100)));
downloadSites = downloadSites.sort((a, b) => (sValMap.get(a) || 0) - (sValMap.get(b) || 0));
}
let installedDone = false;
try {
const tmpFile = File.fromArray([os.tmpdir(), `eide-binaries-${binVersion}.${binType}`]);
/* make dir */
binFolder.CreateDir(true);
const done = await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: 'Downloading eide binaries',
cancellable: false
}, async (progress, token): Promise<boolean> => {
let res: Buffer | undefined | Error = undefined;
for (const site of downloadSites) {
res = await utility.downloadFileWithProgress(site, tmpFile.name, progress, token);
if (res instanceof Buffer) { break; } /* if done, exit loop */
progress.report({ message: 'failed, switch to next download site ...' });
}
if (res instanceof Error) { /* download failed */
GlobalEvent.emit('msg', ExceptionToMessage(res, 'Warning'));
return false;
} else if (res == undefined) { /* canceled */
return false;
}
/* save to file */
fs.writeFileSync(tmpFile.path, res);
return true;
});
/* download done, unzip and install it */
if (done) {
installedDone = await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: `Installing eide binaries`,
cancellable: false
}, async (progress, __): Promise<boolean> => {
return new Promise((resolve_) => {
let resolved = false;
const resolveIf = (data: boolean) => {
if (!resolved) {
resolved = true;
resolve_(data);
}
};
let prevPercent: number = 0;
// start unzip
node7z.extractFull(tmpFile.path, binFolder.path, {
$bin: ResManager.GetInstance().Get7za().path,
$progress: true,
recursive: true
})
// unzip done
.on('end', () => {
progress.report({ message: `Install eide binaries done !` });
setTimeout(() => resolveIf(true), 500);
})
// unzip error
.on('error', (err) => {
GlobalEvent.emit('error', err);
resolveIf(false);
})
// progress
.on('progress', (info) => {
prevPercent = info.percent;
})
// file info
.on('data', (data) => {
progress.report({ message: `${prevPercent}%, in '${data.file}'` });
});
});
});
}
/* del tmp file */
if (tmpFile.IsFile()) {
try { fs.unlinkSync(tmpFile.path) } catch (error) { }
}
} catch (error) {
GlobalEvent.emit('error', error);
}
/* clear dir if failed */
if (!installedDone) {
platform.DeleteDir(binFolder);
}
if (installedDone) {
onBinariesInstallDone();
}
return installedDone;
}
function onBinariesInstallDone() {
const resManager = ResManager.GetInstance();
// chmod +x for other executable files
if (os.platform() != 'win32') {
const exeLi: string[] = [];
// get exe file list from folders
for (const dir of [
File.fromArray([resManager.GetBinDir().path, 'scripts']),
File.fromArray([resManager.getLegacyBuilderDir().path, 'utils'])
]) {
dir.GetList(undefined, File.EXCLUDE_ALL_FILTER)
.forEach((f) => {
if (!f.suffix) { // nosuffix file is an exe file
exeLi.push(f.path);
}
});
}
if (exeLi.length > 0)
GlobalEvent.emit('globalLog.append', 'Setup binaries permissions -> ' + os.EOL);
for (const path of exeLi) {
try {
const cmd = `chmod +x "${path}"`;
GlobalEvent.emit('globalLog.append', cmd + os.EOL);
ChildProcess.execSync(cmd);
} catch (error) {
GlobalEvent.log_error(error);
GlobalEvent.emit('globalLog.show');
}
}
}
// delete legacy builder dir
cleanLegacyUnifyBuilder();
}
function cleanLegacyUnifyBuilder() {
const resManager = ResManager.GetInstance();
const legacyDir = File.fromArray([resManager.getLegacyBuilderDir().path, 'bin']);
if (legacyDir.IsDir()) {
platform.DeleteDir(legacyDir);
}
}
//////////////////////////////////////////////////
// environment sutup
//////////////////////////////////////////////////
let isEnvSetuped: boolean = false;
function exportEnvToSysPath(context?: vscode.ExtensionContext) {
const settingManager = SettingManager.GetInstance();
const resManager = ResManager.GetInstance();
const legacyBuilderDir = resManager.getLegacyBuilderDir();
// export some eide binaries path to system env path
const prependSystemPaths: string[] = [
File.normalize(`${resManager.getUnifyBuilderExe().dir}`),
File.normalize(`${legacyBuilderDir.path}/utils`), // C:\Users\<USER-NAME>\.eide\bin\builder\utils
File.normalize(`${legacyBuilderDir.dir}/scripts`), // C:\Users\<USER-NAME>\.eide\bin\scripts
File.normalize(`${resManager.Get7zDir().path}`), // builtin 7za tool
File.normalize(`${resManager.getBuiltInToolsDir().path}/utils`) // builtin util tools
];
//
const eideToolsFolder = new File(File.normalize(`${platform.userhome()}/.eide/tools`));
if (!eideToolsFolder.IsDir()) {
try {
new File(eideToolsFolder.path).CreateDir(true);
} catch (error) {
// nothing todo
}
}
// export def tools path to system env path from extension setting
const pathList: { key: string, path: string, extraPath?: string[] }[] = [];
// try to export some user setted tools path to env
[
{ key: 'EIDE_TOOL_GCC_ARM', path: `${settingManager.getGCCDir().path}${File.sep}bin` },
{ key: 'EIDE_TOOL_JLINK', path: `${settingManager.getJlinkDir()}` },
{ key: 'EIDE_TOOL_OPENOCD', path: `${NodePath.dirname(settingManager.getOpenOCDExePath())}` }
].forEach(o => {
if (File.IsDir(o.path)) {
pathList.push(o);
}
});
// search tools folder and export path to system env
eideToolsFolder.GetList(File.EXCLUDE_ALL_FILTER).forEach((subDir) => {
if (!/^\w+$/.test(subDir.name)) return; // filter dir name
let binFolderPaths: string[] = [];
// try get path from 'BIN_PATH' file
const BIN_PATH_FILE = File.fromArray([subDir.path, 'BIN_PATH']);
if (BIN_PATH_FILE.IsFile()) {
let binDirs: string[] = [];
try {
binDirs = BIN_PATH_FILE.Read().split(/\r\n|\n/)
.map(s => s.trim())
.filter(s => s != '');
} catch (error) {
GlobalEvent.log_warn(error);
}
binDirs.forEach(dir => {
const binFolder = File.normalize(`${subDir.path}/${dir}`);
if (File.IsDir(binFolder)) {
binFolderPaths.push(binFolder);
}
});
}
// try use ./bin
if (binFolderPaths.length == 0) {
const binFolder = File.normalize(`${subDir.path}/bin`);
if (File.IsDir(binFolder)) {
binFolderPaths.push(binFolder);
}
}
// export bin folder if we found
if (binFolderPaths.length > 0) {
const keyName = `EIDE_TOOL_${subDir.name.toUpperCase()}`;
if (pathList.findIndex(o => o.key == keyName) != -1) return; // skip repeat key name
pathList.push({
key: keyName,
path: binFolderPaths[0],
extraPath: binFolderPaths.length > 1 ? binFolderPaths.slice(1) : undefined
});
}
});
// search built-in tools and export path to system env
legacyBuilderDir.GetList(File.EXCLUDE_ALL_FILTER).forEach((subDir) => {
const binFolder = File.normalize(`${subDir.path}/bin`);
if (File.IsDir(binFolder)) {
const key_name = `EIDE_${subDir.name.toUpperCase()}`;
// check msys is enabled
if (key_name == 'EIDE_MSYS' && !settingManager.isEnableMsys())
return;
pathList.push({
key: key_name,
path: binFolder
});
}
});
// prepend/append all tools to system env paths
pathList
.filter((env) => File.IsDir(env.path))
.forEach(envInfo => {
prependSystemPaths.push(envInfo.path);
if (envInfo.extraPath) {
envInfo.extraPath.forEach(p => prependSystemPaths.push(p));
}
});
/* append to System Path if we not */
if (isEnvSetuped == false) {
isEnvSetuped = true;
platform.prependToSysEnv(process.env, prependSystemPaths);
}
/* update env key value */
for (const env of pathList) {
if (File.IsDir(env.path)) {
process.env[env.key] = env.path;
} else {
process.env[env.key] = '';
}
}
// .NET 工具会收集用法数据,帮助我们改善你的体验。它由 Microsoft 收集并与社区共享。
// 你可通过使用喜欢的 shell 将 DOTNET_CLI_TELEMETRY_OPTOUT 环境变量设置为 "1" 或 "true" 来选择退出遥测。
// 阅读有关 .NET CLI 工具遥测的更多信息: https://aka.ms/dotnet-cli-telemetry
process.env['DOTNET_CLI_TELEMETRY_OPTOUT'] = '1'; // disable telemetry
// 支持运行时回滚
// https://learn.microsoft.com/zh-cn/dotnet/core/whats-new/dotnet-core-3-0#major-version-runtime-roll-forward
process.env['DOTNET_ROLL_FORWARD'] = 'Major';
SettingManager.GetInstance().syncGlobalEnvVariablesToNodeEnv();
}
async function checkAndInstallRuntime() {
const dotnet_chk_cmd = `dotnet --list-runtimes`;
//
// if not found dotnet, preset dotnet root folder into system env
// dotnet path: 'C:\Program Files\dotnet'
//
if (os.platform() == 'win32') {
try {
ChildProcess.execSync(dotnet_chk_cmd);
} catch (error) {
if (platform.osType() == 'win32') {
platform.appendToSysEnv(process.env, ['C:\\Program Files\\dotnet']); // for win x64
platform.appendToSysEnv(process.env, ['C:\\Program Files (x86)\\dotnet']); // for win x86
}
}
}
//
// check/install .NET
//
try {
GlobalEvent.log_info('Checking .NET runtime ...');
GlobalEvent.log_info(`Exec cmd: '${dotnet_chk_cmd}'`);
const dotnetInfo = ChildProcess.execSync(dotnet_chk_cmd).toString().trim();
GlobalEvent.emit('globalLog.append', dotnetInfo + os.EOL);
// check dotnet version
let dotnetVerLine: string | undefined;
const lines = dotnetInfo.trim().split(/\r\n|\n/);
for (const line_ of lines) {
const line = line_.trim();
const m = /Microsoft\.NETCore\.App (\d+)\./i.exec(line);
if (m && m.length > 1) {
const rt_ver = parseInt(m[1]);
if (rt_ver >= 6) {
dotnetVerLine = line;
GlobalEvent.log_info(`.NET runtime: '${dotnetVerLine}' found !`);
break;
}
}
}
if (!dotnetVerLine) {
throw new Error(`Not found available .NET Core runtime`);
}
} catch (error) {
GlobalEvent.log_error(error);
GlobalEvent.emit('globalLog.show'); // show error log for user
GlobalEvent.log_info('Not found [.NET6 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) !');
/* @deprecated
const msg = `Not found [.NET6 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0), please install it !`;
const sel = await vscode.window.showWarningMessage(msg, txt_install_now);
if (!sel) { return } // user canceled */
// for other platform, user need install it manually
if (os.platform() != 'win32') {
const msg = `Not found [.NET6 runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) on your pc, please install it !`;
vscode.window.showWarningMessage(msg);
// https://dotnet.microsoft.com/en-us/download/dotnet/scripts
// utility.openUrl(`https://dotnet.microsoft.com/en-us/download/dotnet/scripts`);
}
// win32, we can auto install it
else {
const defPkgName = 'dotnet-runtime-6.0.5-win-x64.exe';
let pkgReady: boolean = false;
let pkgFile: File;
// if found local installer pkg, use it
const localPkg = File.fromArray([ResManager.GetInstance().getAppRootFolder().path, defPkgName]);
if (localPkg.IsFile()) {
pkgReady = true;
pkgFile = localPkg;
}
// if not found local installer pkg, download it
else {
pkgFile = File.fromArray([os.tmpdir(), defPkgName]);
if (pkgFile.IsFile()) { // if we have a cached old file, check it
const sevenZip = utility.newSevenZipperInstance();
const pkgSha256 = sevenZip.sha256(pkgFile);
const reqSha256 = 'A085714B879DC1CB85538109640E22A2CBFF2B91195DF540A5F98AEA09AF2C1E'.toLowerCase();