This repository has been archived by the owner on Jun 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patheclipse_cproject.lua
1036 lines (944 loc) · 31.9 KB
/
eclipse_cproject.lua
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
--
-- Name: eclipse/eclipse_cproject.lua
-- Purpose: Generate a Eclipse .cproject file.
-- Author: Manu Evans
-- Created: 2014/12/22
-- Copyright: (c) 2008-2014 Jason Perkins and the Premake project
--
local p = premake
local eclipse = p.modules.eclipse
local tree = p.tree
local project = p.project
local config = p.config
local m = eclipse
local function getvalue(v, default, arg, arg2)
if type(v) == "function" then
v = v(arg, arg2)
end
return v or default
end
m.cdt = {
types = {
WindowedApp = "exe",
ConsoleApp = "exe",
Makefile = "", -- TODO??
SharedLib = "so", -- /dll??
StaticLib = "lib",
},
typenames = {
WindowedApp = "Executable",
ConsoleApp = "Executable",
Makefile = "", -- TODO??
SharedLib = "Shared Library",
StaticLib = "Static Library",
},
extensions = {
pe = { id = "org.eclipse.cdt.core.PE", point = "org.eclipse.cdt.core.BinaryParser" },
elf = { id = "org.eclipse.cdt.core.ELF", point = "org.eclipse.cdt.core.BinaryParser" },
macho = { id = "org.eclipse.cdt.core.MachO64", point = "org.eclipse.cdt.core.BinaryParser" },
gas = { id = "org.eclipse.cdt.core.GASErrorParser", point = "org.eclipse.cdt.core.ErrorParser" },
gld = { id = "org.eclipse.cdt.core.GLDErrorParser", point = "org.eclipse.cdt.core.ErrorParser" },
gcc = { id = "org.eclipse.cdt.core.GCCErrorParser", point = "org.eclipse.cdt.core.ErrorParser" },
gmake = { id = "org.eclipse.cdt.core.GmakeErrorParser", point = "org.eclipse.cdt.core.ErrorParser" },
cwd = { id = "org.eclipse.cdt.core.CWDLocator", point = "org.eclipse.cdt.core.ErrorParser" },
},
toolsets = {
gcc = {
name = "Linux GCC",
project = "cdt.managedbuild.target.gnu",
config = "cdt.managedbuild.config.gnu",
extensions = { "elf", "gas", "gmake", "gld", "cwd", "gcc" },
class = "cdt.managedbuild.toolchain.gnu",
target = "cdt.managedbuild.target.gnu.platform",
tools = {
as = {
class = "cdt.managedbuild.tool.gnu.assembler",
},
ar = {
class = "cdt.managedbuild.tool.gnu.archiver",
},
c = {
class = "cdt.managedbuild.tool.gnu.c.compiler",
scannerProfile = ""
},
cpp = {
class = "cdt.managedbuild.tool.gnu.cpp.compiler",
scannerProfile = ""
},
ld = {
class = "cdt.managedbuild.tool.gnu.c.linker",
},
ldpp = {
class = "cdt.managedbuild.tool.gnu.cpp.linker",
},
},
},
clang = {
project = "",
config = "",
extensions = { },
tools = {
},
},
mingw = {
name = "MinGW GCC",
class = "cdt.managedbuild.toolchain.gnu.mingw",
project = "cdt.managedbuild.target.gnu.mingw",
config = "cdt.managedbuild.config.gnu.mingw",
target = "cdt.managedbuild.target.gnu.platform.mingw",
builder = "cdt.managedbuild.tool.gnu.builder.mingw",
extensions = function(cfg)
-- TODO: collect binaryparser and errorparser's properly
-- local toolset = cfg.eclipse.toolset
-- local ext = {}
-- table.insert(ext, toolset.binaryparser)
-- for tool in toolset.tools do
-- if tool.errorparser then
-- -- TODO: if tool is active (buildpair ~= "base")
-- table.insert(ext, tool.errorparser)
-- end
-- end
-- TODO: hack!! we should rather collect these from the 'active' tools
local ext = { "pe", "gas", "gcc" }
if cfg.kind ~= "StaticLib" then
table.insert(ext, "gld")
end
return ext
end,
binaryparser = "pe",
tools = {
as = {
name = "GCC Assembler",
class = "cdt.managedbuild.tool.gnu.assembler.mingw",
input = "cdt.managedbuild.tool.gnu.assembler.input",
errorparser = "gas",
command = function(cfg)
if cfg.gccprefix then return cfg.gccprefix .. "as" end
end,
options = {
{
name = "Assembler flags",
class = "gnu.both.asm.option.flags",
type = "string",
},
{
name = "Include paths (-I)",
class = "gnu.both.asm.option.include.paths",
type = "includePath",
value = function(cfg)
return cfg.includedirs
end,
},
{
name = "Suppress warnings (-W)",
class = "gnu.both.asm.option.warnings.nowarn",
type = "boolean",
value = function(cfg)
return iif(cfg.warnings == "Off", "true")
end,
},
},
},
ar = {
name = "GCC Archiver",
class = "cdt.managedbuild.tool.gnu.archiver.mingw",
command = function(cfg)
if cfg.gccprefix then return cfg.gccprefix .. "ar" end
end,
buildpair = function(cfg)
return iif(cfg.project.kind == "StaticLib", cfg.eclipse.buildpair, "base") -- TODO: confirm this is correct
end,
options = {
{
name = "Archiver flags",
class = "gnu.both.lib.option.flags",
type = "string",
},
},
},
c = {
name = "GCC C Compiler",
class = "cdt.managedbuild.tool.gnu.c.compiler.mingw",
input = "cdt.managedbuild.tool.gnu.c.compiler.input",
scannerProfile = "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC",
errorparser = "gcc",
command = function(cfg)
if cfg.gccprefix then return cfg.gccprefix .. "gcc" end
end,
options = {
{
name = "Optimization Level",
class = function(cfg)
return "gnu.c.compiler.mingw." .. cfg.eclipse.buildpair .. ".option.optimization.level"
end,
type = "enumerated",
default = "gnu.c.optimization.level.none",
value = function(cfg, optiondesc)
return optiondesc.values[cfg.optimize]
end,
values = {
Off = "gnu.c.optimization.level.none", -- -O0
Debug = "gnu.c.optimization.level.none", -- -O0
On = "gnu.c.optimization.level.more", -- -O2
Size = "gnu.c.optimization.level.size", -- -Os
Speed = "gnu.c.optimization.level.most", -- -O3
Full = "gnu.c.optimization.level.most", -- -O3
-- "gnu.c.optimization.level.optimize" -- -O1
},
},
{
name = "Debug Level",
class = function(cfg)
return "gnu.c.compiler.mingw." .. cfg.eclipse.buildpair .. ".option.debugging.level"
end,
type = "enumerated",
value = function(cfg)
return iif(cfg.flags.Symbols, "gnu.c.debugging.level.default")
end,
values = {
"gnu.c.debugging.level.none",
"gnu.c.debugging.level.minimal",
"gnu.c.debugging.level.default",
"gnu.c.debugging.level.max",
},
},
{
name = "Preprocess only (-E)",
class = "gnu.c.compiler.option.preprocessor.preprocess",
type = "boolean",
},
{
name = "Do not search system directories (-nostdinc)",
class = "gnu.c.compiler.option.preprocessor.nostdinc",
type = "boolean",
},
{
name = "Defined symbols (-D)",
class = "gnu.c.compiler.option.preprocessor.def.symbols",
type = "definedSymbols",
value = function(cfg)
return cfg.defines
end,
},
{
name = "Undefined symbols (-U)",
class = "gnu.c.compiler.option.preprocessor.undef.symbol",
type = "undefDefinedSymbols",
value = function(cfg)
return cfg.undefines
end,
},
{
name = "Include paths (-I)",
class = "gnu.c.compiler.option.include.paths",
type = "includePath",
value = function(cfg)
return cfg.includedirs
end,
},
{
name = "Include files (-include)",
class = "gnu.c.compiler.option.include.files",
type = "includeFiles",
value = function(cfg)
return cfg.forceincludes
end,
},
{
name = "Other optimization flags",
class = "gnu.c.compiler.option.optimization.flags",
type = "string",
},
{
name = "Other debugging flags",
class = "gnu.c.compiler.option.debugging.other",
type = "string",
},
{
name = "Generate prof information (-p)",
class = "gnu.c.compiler.option.debugging.prof",
type = "boolean",
},
{
name = "Generate gprof information (-pg)",
class = "gnu.c.compiler.option.debugging.gprof",
type = "boolean",
},
{
name = "Check syntax only (-fsyntax-only)",
class = "gnu.c.compiler.option.warnings.syntax",
type = "boolean",
},
{
name = "Pedantic (-pedantic)",
class = "gnu.c.compiler.option.warnings.pedantic",
type = "boolean",
},
{
name = "Pedantic warnings as errors (-pedantic-errors)",
class = "gnu.c.compiler.option.warnings.pedantic.error",
type = "boolean",
},
{
name = "Inhibit all warnings (-w)",
class = "gnu.c.compiler.option.warnings.nowarn",
type = "boolean",
value = function(cfg)
return iif(cfg.warnings == "Off", "true")
end,
},
{
name = "All warnings (-Wall)",
class = "gnu.c.compiler.option.warnings.allwarn",
type = "boolean",
value = function(cfg)
return iif(cfg.warnings == "Off", "false")
end,
},
{
name = "Extra warnings (-Wextra)",
class = "gnu.c.compiler.option.warnings.extrawarn",
type = "boolean",
value = function(cfg)
return iif(cfg.warnings == "Extra", "true")
end,
},
{
name = "Warnings as errors (-Werror)",
class = "gnu.c.compiler.option.warnings.toerrors",
type = "boolean",
value = function(cfg)
return iif(cfg.flags.FatalCompileWarnings and cfg.warnings ~= "Off", "true")
end,
},
{
name = "Implicit conversion warnings (-Wconversion)",
class = "gnu.c.compiler.option.warnings.wconversion",
type = "boolean",
},
{
name = "Support ANSI programs (-ansi)",
class = "gnu.c.compiler.option.misc.ansi",
type = "boolean",
},
{
name = "Position Independent Code (-fPIC)",
class = "gnu.c.compiler.option.misc.pic",
type = "boolean",
value = function(cfg)
return iif(cfg.pic == "On", "true")
end,
},
{
name = "Other flags",
class = "gnu.c.compiler.option.misc.other",
type = "string",
value = function(cfg)
return table.implode(cfg.buildoptions, "", "", " ")
end,
},
},
},
cpp = {
name = "GCC C++ Compiler",
class = "cdt.managedbuild.tool.gnu.cpp.compiler.mingw",
input = "cdt.managedbuild.tool.gnu.cpp.compiler.input",
scannerProfile = "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP",
errorparser = "gcc",
command = function(cfg)
if cfg.gccprefix then return cfg.gccprefix .. "g++" end
end,
options = {
{
name = "Optimization Level",
class = function(cfg)
return "gnu.cpp.compiler.mingw." .. cfg.eclipse.buildpair .. ".option.optimization.level"
end,
type = "enumerated",
value = function(cfg, optiondesc)
return optiondesc.values[cfg.optimize]
end,
values = {
Off = "gnu.cpp.compiler.optimization.level.none", -- -O0
Debug = "gnu.cpp.compiler.optimization.level.none", -- -O0
On = "gnu.cpp.compiler.optimization.level.more", -- -O2
Size = "gnu.cpp.compiler.optimization.level.size", -- -Os
Speed = "gnu.cpp.compiler.optimization.level.most", -- -O3
Full = "gnu.cpp.compiler.optimization.level.most", -- -O3
-- "gnu.cpp.compiler.optimization.level.optimize" -- -O1
},
},
{
name = "Debug Level",
class = function(cfg)
return "gnu.cpp.compiler.mingw." .. cfg.eclipse.buildpair .. ".option.debugging.level"
end,
type = "enumerated",
value = function(cfg)
return iif(cfg.flags.Symbols, "gnu.cpp.compiler.debugging.level.default")
end,
values = {
"gnu.cpp.compiler.debugging.level.none",
"gnu.cpp.compiler.debugging.level.minimal",
"gnu.cpp.compiler.debugging.level.default",
"gnu.cpp.compiler.debugging.level.max",
},
},
{
name = "Do not search system directories (-nostdinc)",
class = "gnu.cpp.compiler.option.preprocessor.nostdinc",
type = "boolean",
},
{
name = "Preprocess only (-E)",
class = "gnu.cpp.compiler.option.preprocessor.preprocess",
type = "boolean",
},
{
name = "Defined symbols (-D)",
class = "gnu.cpp.compiler.option.preprocessor.def",
type = "definedSymbols",
value = function(cfg)
return cfg.defines
end,
},
{
name = "Undefined symbols (-U)",
class = "gnu.cpp.compiler.option.preprocessor.undef",
type = "undefDefinedSymbols",
value = function(cfg)
return cfg.undefines
end,
},
{
name = "Include paths (-I)",
class = "gnu.cpp.compiler.option.include.paths",
type = "includePath",
value = function(cfg)
return cfg.includedirs
end,
},
{
name = "Include files (-include)",
class = "gnu.cpp.compiler.option.include.files",
type = "includeFiles",
value = function(cfg)
return cfg.forceincludes
end,
},
{
name = "Other optimization flags",
class = "gnu.cpp.compiler.option.optimization.flags",
type = "string",
},
{
name = "Other debugging flags",
class = "gnu.cpp.compiler.option.debugging.other",
type = "string",
},
{
name = "Generate prof information (-p)",
class = "gnu.cpp.compiler.option.debugging.prof",
type = "boolean",
},
{
name = "Generate gprof information (-pg)",
class = "gnu.cpp.compiler.option.debugging.gprof",
type = "boolean",
},
{
name = "Check syntax only (-fsyntax-only)",
class = "gnu.cpp.compiler.option.warnings.syntax",
type = "boolean",
},
{
name = "Pedantic (-pedantic)",
class = "gnu.cpp.compiler.option.warnings.pedantic",
type = "boolean",
},
{
name = "Pedantic warnings as errors (-pedantic-errors)",
class = "gnu.cpp.compiler.option.warnings.pedantic.error",
type = "boolean",
},
{
name = "Inhibit all warnings (-w)",
class = "gnu.cpp.compiler.option.warnings.nowarn",
type = "boolean",
value = function(cfg)
return iif(cfg.warnings == "Off", "true")
end,
},
{
name = "All warnings (-Wall)",
class = "gnu.cpp.compiler.option.warnings.allwarn", -- *****
type = "boolean",
value = function(cfg)
return iif(cfg.warnings == "Off", "false")
end,
},
{
name = "Extra warnings (-Wextra)",
class = "gnu.cpp.compiler.option.warnings.extrawarn",
type = "boolean",
value = function(cfg)
return iif(cfg.warnings == "Extra", "true")
end,
},
{
name = "Warnings as errors (-Werror)",
class = "gnu.cpp.compiler.option.warnings.toerrors",
type = "boolean",
value = function(cfg)
return iif(cfg.flags.FatalCompileWarnings and cfg.warnings ~= "Off", "true")
end,
},
{
name = "Implicit conversion warnings (-Wconversion)",
class = "gnu.cpp.compiler.option.warnings.wconversion",
type = "boolean",
},
{
name = "Position Independent Code (-fPIC)",
class = "gnu.cpp.compiler.option.other.pic",
type = "boolean",
value = function(cfg)
return iif(cfg.pic == "On", "true")
end,
},
{
name = "Other flags",
class = "gnu.cpp.compiler.option.other.other",
type = "string",
value = function(cfg)
return table.implode(cfg.buildoptions, "", "", " ")
end,
},
},
},
ld = {
name = "MinGW C Linker",
class = "cdt.managedbuild.tool.gnu.c.linker.mingw",
input = "cdt.managedbuild.tool.gnu.c.linker.input",
errorparser = "gld",
command = function(cfg)
if cfg.gccprefix then return cfg.gccprefix .. "gcc" end -- should we use ld? eclipse seems to link with the compiler
end,
buildpair = function(cfg)
return iif(cfg.project.kind == "StaticLib", "base", cfg.eclipse.buildpair) -- TODO: confirm this is correct
end,
options = {
},
},
ldpp = {
name = "MinGW C++ Linker",
class = "cdt.managedbuild.tool.gnu.cpp.linker.mingw",
input = "cdt.managedbuild.tool.gnu.cpp.linker.input",
errorparser = "gld",
command = function(cfg)
if cfg.gccprefix then return cfg.gccprefix .. "g++" end -- should we use ld? eclipse seems to link with the compiler
end,
buildpair = function(cfg)
return iif(cfg.project.kind == "StaticLib", "base", cfg.eclipse.buildpair) -- TODO: confirm this is correct
end,
options = {
{
name = "Libraries (-l)",
class = "gnu.cpp.link.option.libs",
type = "libs",
value = function(cfg)
-- TODO: only system libs (no siblings)
return cfg.links
end,
},
{
name = "Other objects",
class = "gnu.cpp.link.option.userobjs",
type = "userObjs",
value = function(cfg)
-- TODO: sibling libs (relative path, full filename)
return nil
end,
},
{
name = "Do not use standard start files (-nostartfiles)",
class = "gnu.cpp.link.option.nostart",
type = "boolean",
},
{
name = "Do not use default libraries (-nodefaultlibs)",
class = "gnu.cpp.link.option.nodeflibs",
type = "boolean",
},
{
name = "No startup or default libs (-nostdlib)",
class = "gnu.cpp.link.option.nostdlibs",
type = "boolean",
},
{
name = "Omit all symbol information (-s)",
class = "gnu.cpp.link.option.strip",
type = "boolean",
},
{
name = "Library search path (-L)",
class = "gnu.cpp.link.option.paths",
type = "libPaths",
value = function(cfg)
return cfg.libdirs
end,
},
{
name = "Linker flags",
class = "gnu.cpp.link.option.flags",
type = "string",
value = function(cfg)
return table.implode(cfg.linkoptions, "", "", " ")
end,
},
{
name = "Other options (-Xlinker [option])",
class = "gnu.cpp.link.option.other",
type = "stringList",
},
{
name = "Shared (-shared)",
class = "gnu.cpp.link.option.shared",
type = "boolean",
value = function(cfg)
return iif(cfg.kind == "SharedLib", "true")
end,
},
{
name = "Shared object name (-Wl,-soname=)",
class = "gnu.cpp.link.option.soname",
type = "string",
},
{
name = "Import Library name (-Wl,--out-implib=)",
class = "gnu.cpp.link.option.implname",
type = "string",
},
{
name = "DEF file name (-Wl,--output-def=)",
class = "gnu.cpp.link.option.defname",
type = "string",
},
{
name = "Generate prof information (-p)",
class = "gnu.cpp.link.option.debugging.prof",
type = "boolean",
},
{
name = "Generate gprof information (-pg)",
class = "gnu.cpp.link.option.debugging.gprof",
type = "boolean",
},
},
},
},
},
cygwin = {
project = "",
config = "",
extensions = { },
tools = {
},
},
osx = {
name = "MacOSX GCC",
project = "cdt.managedbuild.target.gnu.macosx",
config = "cdt.managedbuild.config.gnu.macosx",
extensions = { "elf", "gas", "gmake", "gld", "cwd", "gcc" },
tools = {
},
},
msc = {
project = "org.eclipse.cdt.msvc.projectType",
config = "", -- ??? perhaps: org.eclipse.cdt.msvc
extensions = { "pe" },
tools = {
c = {
class = "org.eclipse.cdt.msvc.cl.c",
input = "org.eclipse.cdt.msvc.cl.inputType.c",
scannerProfile = "org.eclipse.cdt.msw.build.clScannerInfo",
},
cpp = {
class = "org.eclipse.cdt.msvc.cl",
input = "org.eclipse.cdt.msvc.cl.inputType",
scannerProfile = "org.eclipse.cdt.msw.build.clScannerInfo",
},
},
},
},
}
function m.build(cfg)
-- Note: isDebugBuild is kinda broken, we need to imprive it
return iif(config.isDebugBuild(cfg), "debug", "release")
end
function m.cfgname(cfg)
local cfgname = cfg.buildcfg
-- TODO: multi-platform builds need a matrix of configs...
-- if codelite.solution.multiplePlatforms then
-- cfgname = string.format("%s|%s", cfg.platform, cfg.buildcfg)
-- end
return cfgname
end
function m.getcompiler(cfg)
local tool
if cfg then
tool = _OPTIONS.cc or cfg.toolset or p.GCC
else
-- TODO: this is a problem case, the tool can be requested outside of configuration scope...
tool = _OPTIONS.cc or p.GCC
end
-- TODO: this is pretty blunt!!
if tool == "gcc" then
if os.is("windows") then
tool = "mingw"
end
end
return tool
end
function m.cproject.config_configurationDataProvider(cfg)
local e = cfg.eclipse
e.errorParsers = {}
_p(3, '<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="%s" moduleId="org.eclipse.cdt.core.settings" name="%s">', e.class, e.cfgname)
_p(4, '<externalSettings/>')
_p(4, '<extensions>')
local ext = getvalue(cfg.eclipse.toolset.extensions, nil, cfg)
for _, extension in ipairs(ext) do
local ext = eclipse.cdt.extensions[extension]
_p(5, '<extension id="%s" point="%s"/>', ext.id, ext.point)
-- make a collection of error parsers, which will be used later...
if ext.point == "org.eclipse.cdt.core.ErrorParser" then
table.insert(e.errorParsers, ext.id)
end
end
_p(4, '</extensions>')
_p(3, '</storageModule>')
end
function m.cproject.toolchain_targetPlatform(cfg)
local e = cfg.eclipse
_p(7, '<targetPlatform id="%s.%s.%s" name="Debug Platform" superClass="%s.%s"/>', e.toolset.target, e.buildpair, eclipse.uid(), e.toolset.target, e.buildpair)
end
function m.cproject.toolchain_builder(cfg)
local e = cfg.eclipse
local path = "${workspace_loc:/e_app}/Debug" -- TODO: path is wrong!
local type = e.type or "base" -- TODO: when is 'base' used?!
-- TODO: we can supply parallel build options here...
local parallel = "" -- 'parallelBuildOn="true" parallelizationNumber="optimal" '
_p(7, '<builder buildPath="%s" id="%s.%s.%s" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" %ssuperClass="%s.%s"/>', path, e.toolset.builder, type, eclipse.uid(), parallel, e.toolset.builder, type)
end
function m.cproject.tool_option(cfg, optiondesc, value)
local class = getvalue(optiondesc.class, nil, cfg, optiondesc)
value = getvalue(optiondesc.value, value, cfg, optiondesc)
if value == "" or (type(value) == "table" and table.isempty(value)) then
value = nil
end
if value and optiondesc.format then
value = optiondesc.format(value, cfg, optiondesc)
end
local isList = type(value) == "table"
local valueField = ""
local defaultField = ""
if not value then
if optiondesc.default then
defaultField = 'defaultValue="' .. optiondesc.default .. '" '
else
return
end
elseif not isList then
valueField = 'value="' .. value .. '" '
end
_x(8, '<option %sid="%s.%s" name="%s" superClass="%s" %svalueType="%s"%s>', defaultField, class, eclipse.uid(), optiondesc.name, class, valueField, optiondesc.type, iif(isList, "", "/"))
if isList then
for _, v in ipairs(value) do
_x(9, '<listOptionValue builtIn="false" value="%s"/>', v)
end
_p(8, '</option>')
end
end
function m.cproject.toolchain_tool(cfg, tool, name)
local e = cfg.eclipse
local buildpair = getvalue(tool.buildpair, e.buildpair, cfg)
local hasOptions = buildpair ~= "base" -- TODO: I don't know if this is a good way to detect this...
local command = getvalue(tool.command, nil, cfg)
if command then
command = 'command="' .. command .. '" '
else
command = ""
end
local errorParser = ""
if tool.errorparser and hasOptions then
errorParser = 'errorParsers="' .. m.cdt.extensions[tool.errorparser].id .. '" '
end
local uid = iif(name == "c", e.c.uid, nil) or iif(name == "cpp", e.cpp.uid, nil) or eclipse.uid()
_p(7, '<tool %s%sid="%s.%s.%s" name="%s" superClass="%s.%s"%s>', command, errorParser, tool.class, buildpair, uid, tool.name, tool.class, buildpair, iif(not hasOptions, "/", ""))
if hasOptions then
for _, opt in ipairs(tool.options) do
m.cproject.tool_option(cfg, opt)
end
if tool.input then
-- TODO: this shouldn't always be present...
uid = iif(name == "c", e.c.inputuid, nil) or iif(name == "cpp", e.cpp.inputuid, nil) or eclipse.uid()
_p(8, '<inputType id="%s.%s" superClass="%s"/>', tool.input, uid, tool.input)
-- TODO: linker outputType has: outputPrefix="lib"
-- cfg.targetprefix
end
_p(7, '</tool>')
end
end
function m.cproject.config_cdtBuildSystem(cfg)
local e = cfg.eclipse
-- TODO: should we insert the project name directly?
local outputName = "${ProjName}" .. (cfg.targetsuffix or "")
local extension = ""
if cfg.targetextension then
-- TODO: cfg.targetextension must remove leading '.'!
extension = 'artifactExtension="' .. cfg.targetextension .. '" '
end
local cleanCmd = "rm -rf"
local description = ""
local buildEvents = ""
if cfg.postbuildmessage then
buildEvents = buildEvents .. ' postannouncebuildStep="' .. cfg.postbuildmessage .. '"'
end
if cfg.postbuildcommands then
-- TODO: eclipse seems to only execute one command, but we have a table
-- buildEvents = buildEvents .. ' postbuildStep="' .. cfg.postbuildcommands .. '"'
end
if cfg.prebuildmessage then
buildEvents = buildEvents .. ' preannouncebuildStep="' .. cfg.prebuildmessage .. '"'
end
if cfg.prebuildcommands then
-- TODO: eclipse seems to only execute one command, but we have a table
-- buildEvents = buildEvents .. ' prebuildStep="' .. cfg.prebuildcommands .. '"'
end
local errorParser = ""
if not table.isempty(e.errorParsers) then
errorParser = 'errorParsers="' .. table.implode(e.errorParsers, "", "", ";") .. '" '
end
_p(3, '<storageModule moduleId="cdtBuildSystem" version="4.0.0">')
_x(4, '<configuration %sartifactName="%s" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.%s" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.%s,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.%s" cleanCommand="%s" description="%s" %sid="%s" name="%s" parent="%s.%s"%s>',
extension, outputName, e.type, e.type, e.build, cleanCmd, description, errorParser, e.class, e.cfgname, e.toolset.config, e.buildpair, buildEvents)
_p(5, '<folderInfo id="%s." name="/" resourcePath="">', e.class)
_p(6, '<toolChain id="%s.%s.%s" name="%s" superClass="%s.%s">', e.toolset.class, e.buildpair, eclipse.uid(), e.toolset.name, e.toolset.class, e.buildpair)
m.cproject.toolchain_targetPlatform(cfg)
m.cproject.toolchain_builder(cfg)
for _, tool in ipairs({ "as", "ar", "c", "cpp", "ld", "ldpp" }) do
m.cproject.toolchain_tool(cfg, e.toolset.tools[tool], tool)
end
_p(6, '</toolChain>')
_p(5, '</folderInfo>')
_p(4, '</configuration>')
_p(3, '</storageModule>')
end
function m.cproject.config_externalSettings(cfg)
_p(3, '<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>')
end
function m.cproject.configsettings(cfg)
_x(2, '<cconfiguration id="%s">', cfg.eclipse.class)
m.cproject.config_configurationDataProvider(cfg)
m.cproject.config_cdtBuildSystem(cfg)
m.cproject.config_externalSettings(cfg)
_p(2, '</cconfiguration>')
end
function m.cproject.settings(prj)
_p(1, '<storageModule moduleId="org.eclipse.cdt.core.settings">')
for cfg in project.eachconfig(prj) do
-- populate the cfg with eclipse stuff...
cfg.eclipse = {}
local e = cfg.eclipse
e.uid = eclipse.uid()
e.compiler = m.getcompiler(cfg)
e.toolset = m.cdt.toolsets[e.compiler]
e.type = prj.eclipse.type
if not e.toolset or not e.type then
error("Invalid compiler for config: " .. compiler)
end
e.build = m.build(cfg)
e.buildpair = e.type .. "." .. e.build
e.class = e.toolset.config .. "." .. e.buildpair .. "." .. e.uid
e.cfgname = m.cfgname(cfg)
e.c = {}
e.c.uid = eclipse.uid()
e.c.inputuid = eclipse.uid()
e.cpp = {}
e.cpp.uid = eclipse.uid()
e.cpp.inputuid = eclipse.uid()
m.cproject.configsettings(cfg)
end
_p(1, '</storageModule>')
end
function m.cproject.cdtbuildsystem(prj)
_p(1, '<storageModule moduleId="cdtBuildSystem" version="4.0.0">')
_x(2, '<project id="%s" name="%s" projectType="%s.%s"/>', prj.eclipse.class, m.cdt.typenames[prj.kind], prj.eclipse.toolset.project, prj.eclipse.type)
_p(1, '</storageModule>')
end
function m.cproject.scannerconfiguration(prj)
_p(1, '<storageModule moduleId="scannerConfiguration">')
_p(2, '<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>')
for cfg in project.eachconfig(prj) do
local e = cfg.eclipse
for _, cc in ipairs({ "cpp", "c" }) do
local tool = e.toolset.tools[cc]
if tool then
local compiler = tool.class .. "." .. e.buildpair .. "." .. e[cc].uid
local input = tool.input .. "." .. e[cc].inputuid
_p(2, '<scannerConfigBuildInfo instanceId="%s;%s.;%s;%s">', e.class, e.class, compiler, input)
_p(3, '<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="%s"/>', tool.scannerProfile)
_p(2, '</scannerConfigBuildInfo>')
end
end
end
_p(1, '</storageModule>')
end
function m.cproject.languagesettingsproviders(prj)
_p(1, '<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>')
end
function m.cproject.refreshscope(prj)
_p(1, '<storageModule moduleId="refreshScope"/>')
-- _p(1, '<storageModule moduleId="refreshScope" versionNumber="2">')
-- _p(1, '</storageModule>')
-- looks like v2 has configurations
-- <storageModule moduleId="refreshScope" versionNumber="2">
-- <configuration configurationName="Release">
-- <resource resourceType="PROJECT" workspacePath="/cock"/>
-- </configuration>
-- <configuration configurationName="Debug">
-- <resource resourceType="PROJECT" workspacePath="/cock"/>
-- </configuration>
-- </storageModule>
-- v1 has no configurations?
-- <storageModule moduleId="refreshScope" versionNumber="1">
-- <resource resourceType="PROJECT" workspacePath="/udPlatform"/>
-- </storageModule>