-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildster.py
1725 lines (1716 loc) · 69.9 KB
/
buildster.py
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
# Author: Pierce Brooks
import os
import ast
import ssl
import sys
import json
import shlex
import base64
import hashlib
import pathlib
import logging
import requests
import tempfile
import traceback
import multiprocessing
import xml.etree.ElementTree as xml_tree
from requests_testadapter import Resp
from urllib.parse import urlparse
from copy import deepcopy
try:
from .internal import *
from .internal.utilities import *
from .internal.string import String
from .internal.key import Key
from .internal.value import Value
from .internal.destination import Destination
from .internal.content import Content
from .internal.copier_source import CopierSource
from .internal.copier_destination import CopierDestination
from .internal.copier_rename import CopierRename
from .internal.writer import Writer
from .internal.copier import Copier
from .internal.deleter import Deleter
from .internal.extractor import Extractor
from .internal.downloader import Downloader
from .internal.branch import Branch
from .internal.architecture import Architecture
from .internal.generator import Generator
from .internal.path import Path
from .internal.url import URL
from .internal.label import Label
from .internal.work import Work
from .internal.root import Root
from .internal.term import Term
from .internal.argument import Argument
from .internal.argument_list import ArgumentList
from .internal.native import Native
from .internal.native_list import NativeList
from .internal.exception import Exception
from .internal.exception_list import ExceptionList
from .internal.component import Component
from .internal.component_list import ComponentList
from .internal.hint import Hint
from .internal.hint_list import HintList
from .internal.variable import Variable
from .internal.variable_list import VariableList
from .internal.package import Package
from .internal.package_list import PackageList
from .internal.module import Module
from .internal.module_list import ModuleList
from .internal.definition import Definition
from .internal.definition_list import DefinitionList
from .internal.link import Link
from .internal.link_list import LinkList
from .internal.build import Export
from .internal.export_list import ExportList
from .internal.build import Import
from .internal.import_list import ImportList
from .internal.build_instruction import BuildInstruction
from .internal.build_instruction import PreBuildInstruction
from .internal.build_instruction import PostBuildInstruction
from .internal.cmake_build_instruction import CmakeBuildInstruction
from .internal.shells_build_instruction import ShellsBuildInstruction
from .internal.shell_build_instruction import ShellBuildInstruction
from .internal.commands_build_instruction import CommandsBuildInstruction
from .internal.command_build_instruction import CommandBuildInstruction
from .internal.setter import Setter
from .internal.remote_dependency import RemoteDependency
from .internal.dependency_list import DependencyList
from .internal.local_dependency import LocalDependency
from .internal.username import Username
from .internal.password import Password
from .internal.credentials import Credentials
from .internal.git_repo_dependency import GitRepoDependency
from .internal.w_get_dependency import WGetDependency
from .internal.target_list import TargetList
from .internal.executable_target import ExecutableTarget
from .internal.library_target import LibraryTarget
from .internal.project import Project
from .internal.base import Buildster
from .internal.context import Context
except:
from internal import *
from internal.utilities import *
from internal.string import String
from internal.key import Key
from internal.value import Value
from internal.destination import Destination
from internal.content import Content
from internal.copier_source import CopierSource
from internal.copier_destination import CopierDestination
from internal.copier_rename import CopierRename
from internal.writer import Writer
from internal.copier import Copier
from internal.deleter import Deleter
from internal.extractor import Extractor
from internal.downloader import Downloader
from internal.branch import Branch
from internal.architecture import Architecture
from internal.generator import Generator
from internal.path import Path
from internal.url import URL
from internal.label import Label
from internal.work import Work
from internal.root import Root
from internal.term import Term
from internal.argument import Argument
from internal.argument_list import ArgumentList
from internal.native import Native
from internal.native_list import NativeList
from internal.exception import Exception
from internal.exception_list import ExceptionList
from internal.component import Component
from internal.component_list import ComponentList
from internal.hint import Hint
from internal.hint_list import HintList
from internal.variable import Variable
from internal.variable_list import VariableList
from internal.package import Package
from internal.package_list import PackageList
from internal.module import Module
from internal.module_list import ModuleList
from internal.definition import Definition
from internal.definition_list import DefinitionList
from internal.link import Link
from internal.link_list import LinkList
from internal.build import Export
from internal.export_list import ExportList
from internal.build import Import
from internal.import_list import ImportList
from internal.build_instruction import BuildInstruction
from internal.build_instruction import PreBuildInstruction
from internal.build_instruction import PostBuildInstruction
from internal.cmake_build_instruction import CmakeBuildInstruction
from internal.shells_build_instruction import ShellsBuildInstruction
from internal.shell_build_instruction import ShellBuildInstruction
from internal.commands_build_instruction import CommandsBuildInstruction
from internal.command_build_instruction import CommandBuildInstruction
from internal.setter import Setter
from internal.remote_dependency import RemoteDependency
from internal.dependency_list import DependencyList
from internal.local_dependency import LocalDependency
from internal.username import Username
from internal.password import Password
from internal.credentials import Credentials
from internal.git_repo_dependency import GitRepoDependency
from internal.w_get_dependency import WGetDependency
from internal.target_list import TargetList
from internal.executable_target import ExecutableTarget
from internal.library_target import LibraryTarget
from internal.project import Project
from internal.base import Buildster
from internal.context import Context
# https://stackoverflow.com/a/22989322
class LocalFileAdapter(requests.adapters.HTTPAdapter):
def build_response_from_file(self, request):
file_path = request.url[7:]
with open(file_path, "rb") as file:
buff = bytearray(os.path.getsize(file_path))
file.readinto(buff)
resp = Resp(buff)
r = self.build_response(request, resp)
return r
def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
return self.build_response_from_file(request)
def handle(context, node, tier, parents):
parent = parents[len(parents)-1]
quit = False
result = True
output = []
elements = {}
element = None
null = [True, "", {}]
if (node == None):
return null
tag = node.tag.lower()
context.tier = tier
if not (node in context.parents):
context.parents[node] = parent
context.log(node, tag)
#context.log(node, "NODE_BEGIN\n")
if (context.check(node, parent, parents)):
element = None
if ((tag in context.conditionals) and (("id" in node.attrib) or (context.optional(node, "id")))):
id = None
if ("id" in node.attrib):
id = node.attrib["id"]
if (tag == "if"):
if not (context.find(id)):
context.log(node, id+" does not exist in data!")
children = False
for child in node:
if (child.tag == "else"):
children = True
context.tier = tier
call = handle(context, child, tier+1, parents+[node])
if not (call[0]):
result = False
break
if (child.tag in context.conditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
elif (child.tag in context.nonconditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
for key in call[2]:
value = call[2][key]
if not (value == None):
for i in range(len(value)):
if not (value[i] == None):
if (child.tag in context.conditionals):
if not (key in elements):
elements[key] = []
elements[key].append(value[i])
else:
if not (child.tag in elements):
elements[child.tag] = []
elements[child.tag].append(value[i])
break
if not (children):
return null
return [result, output, elements]
elif (tag == "if_check"):
check = node.attrib["check"]
if not (ensure(context.get(id)).strip() == check):
context.log(node, id+" does not match \""+check+"\" check!")
children = False
for child in node:
if (child.tag == "else"):
children = True
context.tier = tier
call = handle(context, child, tier+1, parents+[node])
if not (call[0]):
result = False
break
if (child.tag in context.conditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
elif (child.tag in context.nonconditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
for key in call[2]:
value = call[2][key]
if not (value == None):
for i in range(len(value)):
if not (value[i] == None):
if (child.tag in context.conditionals):
if not (key in elements):
elements[key] = []
elements[key].append(value[i])
else:
if not (child.tag in elements):
elements[child.tag] = []
elements[child.tag].append(value[i])
break
if not (children):
return null
return [result, output, elements]
elif (tag == "if_exists"):
exists = None
for child in parent:
if (child.tag == "exists"):
exists = child
break
if not (exists == None):
call = handle(context, exists, tier, parents)
if not (call[0]):
context.log(node, "A \"if_exists\" node was blocked by a descendant \"exists\"!\n")
return null
else:
exists = ensure(exists.text).strip()+ensure(call[1]).strip()
exists = exists.strip()
if not (existence(exists)):
context.log(node, id+" does not match \""+exists+"\" check!")
children = False
for child in node:
if (child.tag == "else"):
children = True
context.tier = tier
call = handle(context, child, tier+1, parents+[node])
if not (call[0]):
result = False
break
if (child.tag in context.conditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
elif (child.tag in context.nonconditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
for key in call[2]:
value = call[2][key]
if not (value == None):
for i in range(len(value)):
if not (value[i] == None):
if (child.tag in context.conditionals):
if not (key in elements):
elements[key] = []
elements[key].append(value[i])
else:
if not (child.tag in elements):
elements[child.tag] = []
elements[child.tag].append(value[i])
break
if not (children):
return null
return [result, output, elements]
else:
context.record(node, "No \"exists\" descendant for \"if_exists\" node!\n")
return null
elif (tag == "switch"):
id = node.attrib["id"]
children = False
default = None
for child in node:
if (child.tag == "case"):
check = child.attrib["check"]
if (ensure(context.get(id)).strip() == check):
children = True
context.tier = tier
call = handle(context, child, tier+1, parents+[node])
if not (call[0]):
result = False
break
if (child.tag in context.conditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
elif (child.tag in context.nonconditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail).strip()])
for key in call[2]:
value = call[2][key]
if not (value == None):
for i in range(len(value)):
if not (value[i] == None):
if (child.tag in context.conditionals):
if not (key in elements):
elements[key] = []
elements[key].append(value[i])
else:
if not (child.tag in elements):
elements[child.tag] = []
elements[child.tag].append(value[i])
break
elif (child.tag == "default"):
default = child
if not (children):
if not (default == None):
context.tier = tier
call = handle(context, default, tier+1, parents+[node])
if not (call[0]):
result = False
else:
if (default.tag in context.conditionals):
output.append([ensure(call[1]).strip(), ensure(default.tail).strip()])
elif (default.tag in context.nonconditionals):
output.append([ensure(call[1]).strip(), ensure(default.tail).strip()])
for key in call[2]:
value = call[2][key]
if not (value == None):
for i in range(len(value)):
if not (value[i] == None):
if (default.tag in context.conditionals):
if not (key in elements):
elements[key] = []
elements[key].append(value[i])
else:
if not (default.tag in elements):
elements[default.tag] = []
elements[default.tag].append(value[i])
output = ensure(node.text)+flatten(output).strip()
return [result, output.strip(), elements]
else:
return null
elif (tag == "else"):
if (parent.tag in context.conditionals):
id = None
if ("id" in parent.attrib):
id = parent.attrib["id"]
if (parent.tag == "if"):
if (context.find(id)):
context.log(node, str(id)+" does exist in data for else case!")
return null
elif (parent.tag == "if_check"):
check = parent.attrib["check"]
if (ensure(context.get(id)).strip() == check):
context.log(node, str(id)+" does match \""+check+"\" check for else case!")
return null
elif (parent.tag == "if_exists"):
exists = None
for child in parent:
if (child.tag == "exists"):
exists = child
break
if not (exists == None):
call = handle(context, exists, tier, parents)
if not (call[0]):
context.log(node, "A \"if_exists\" node was blocked by a descendant \"exists\"!\n")
return null
else:
exists = ensure(exists.text).strip()+ensure(call[1]).strip()
exists = exists.strip()
if (existence(exists)):
context.log(node, str(id)+" does match \""+exists+"\" check for else case!")
return null
else:
context.record(node, "No \"exists\" descendant for \"if_exists\" node!\n")
return null
else:
return null
elif (tag == "quit"):
quit = True
result = False
elif (tag == "buildster"):
element = Buildster()
element.context = context
if ("directory" in node.attrib):
element.directory = Path(String(node.attrib["directory"].strip()))
if ("distribution" in node.attrib):
element.distribution = Path(String(node.attrib["distribution"].strip()))
if ("cpp" in node.attrib):
element.cpp = String(node.attrib["cpp"].strip())
else:
element.cpp = String("14")
context.root = element
elif (tag == "project"):
element = Project()
element.context = context
if ("directory" in node.attrib):
element.directory = Path(String(node.attrib["directory"].strip()))
if ("cmake_modules" in node.attrib):
element.cmake_modules = Path(String(node.attrib["cmake_modules"].strip()))
if not (element in context.projects):
context.projects.append(element)
context.project = element
context.project.node = node
context.nodes[node] = element
if not (context.root == None):
element.parent = context.root
context.parents[node] = context.root.node
elif (tag == "dependencies"):
element = DependencyList()
elif (tag == "targets"):
element = TargetList()
elif (tag == "local"):
element = LocalDependency()
elif (tag == "remote"):
element = RemoteDependency()
elif (tag == "git_repo"):
element = GitRepoDependency()
elif (tag == "wget"):
element = WGetDependency()
elif (tag == "target"):
target = node.attrib["type"]
if (target == "executable"):
element = ExecutableTarget()
elif (target == "library"):
element = LibraryTarget()
else:
pass
if ("linkage" in node.attrib):
element.linkage = String(node.attrib["linkage"].strip())
elif (tag == "pre"):
element = PreBuildInstruction()
if ("timing" in node.attrib):
element.timing = String(node.attrib["timing"].strip())
elif (tag == "post"):
element = PostBuildInstruction()
if ("timing" in node.attrib):
element.timing = String(node.attrib["timing"].strip())
elif (tag == "build"):
element = BuildInstruction()
elif (tag == "arguments"):
element = ArgumentList()
elif (tag == "natives"):
element = NativeList()
elif (tag == "variables"):
element = VariableList()
elif (tag == "variable"):
element = Variable()
elif (tag == "packages"):
element = PackageList()
elif (tag == "package"):
element = Package()
elif (tag == "modules"):
element = ModuleList()
elif (tag == "module"):
element = Module()
elif (tag == "components"):
element = ComponentList()
elif (tag == "component"):
element = Component()
elif (tag == "hints"):
element = HintList()
elif (tag == "hint"):
element = Hint()
elif (tag == "exceptions"):
element = ExceptionList()
elif (tag == "exception"):
element = Exception()
elif (tag == "cmake"):
element = CmakeBuildInstruction()
elif (tag == "shells"):
element = ShellsBuildInstruction()
elif (tag == "shell"):
element = ShellBuildInstruction()
elif (tag == "commands"):
element = CommandsBuildInstruction()
elif (tag == "command"):
element = CommandBuildInstruction()
elif (tag == "destination"):
element = Destination()
elif (tag == "content"):
element = Content()
elif (tag == "write"):
element = Writer()
elif (tag == "delete"):
element = Deleter()
elif (tag == "extract"):
element = Extractor()
elif (tag == "download"):
element = Downloader()
elif (tag == "copy"):
element = Copier()
elif (tag == "from"):
element = CopierSource()
elif (tag == "to"):
element = CopierDestination()
elif (tag == "rename"):
element = CopierRename()
elif (tag == "definition"):
element = Definition()
elif (tag == "definitions"):
element = DefinitionList()
elif (tag == "links"):
element = LinkList()
elif (tag == "export"):
element = Export()
elif (tag == "exports"):
element = ExportList()
elif (tag == "imports"):
element = ImportList()
elif (tag == "root"):
element = Root()
elif (tag == "term"):
element = Term()
children = False
for child in node:
if (child.tag == "exists"):
call = ["", ensure(child.tail).strip()]
context.log(node, "A \""+str(tag)+"\" had a \"exists\" child that was replaced with \""+str(call)+"\"")
output.append(call)
continue
children = True
context.tier = tier
call = handle(context, child, tier+1, parents+[node])
if not (call[0]):
result = False
break
if (child.tag.lower() in context.conditionals):
output.append([ensure(call[1]).strip(), ensure(child.tail)])
elif ((child.tag.lower() in context.nonconditionals) or (child.tag.lower() in context.substitutes)):
if (child.tag.lower() in context.substitutes):
output.append([ensure(call[1]), ensure(child.tail)])
else:
output.append([ensure(call[1]).strip(), ensure(child.tail)])
for key in call[2]:
value = call[2][key]
if not (value == None):
for i in range(len(value)):
if not (value[i] == None):
if (child.tag in context.conditionals):
if not (key in elements):
elements[key] = []
elements[key].append(value[i])
else:
if not (child.tag in elements):
elements[child.tag] = []
elements[child.tag].append(value[i])
context.tier = tier
context.log(node, tag)
success = True
if not (tag in context.nodeAttributes):
if (tag == "key"):
output = ensure(node.text)+flatten(output).strip()
element = Key()
element.string = String(output.strip())
elif (tag == "value"):
output = ensure(node.text)+flatten(output).strip()
element = Value()
element.string = String(output.strip())
elif (tag == "definition"):
if ("key" in elements):
for key in elements["key"]:
element.key = key
break
elements["key"] = None
if ("value" in elements):
for value in elements["value"]:
element.value = value
break
elements["value"] = None
elif (tag == "definitions"):
if ("definition" in elements):
for definition in elements["definition"]:
element.addDefinition(definition)
elements["definition"] = None
elif (tag == "exports"):
if ("export" in elements):
for e in elements["export"]:
element.addExport(e)
elements["export"] = None
elif (tag == "imports"):
if ("import" in elements):
for i in elements["import"]:
element.addImport(i)
elements["import"] = None
elif (tag == "links"):
if ("link" in elements):
for link in elements["link"]:
element.addLink(link)
elements["link"] = None
elif (tag == "dependencies"):
if ("dependency" in elements):
for dependency in elements["dependency"]:
element.addDependency(dependency)
elements["dependency"] = None
context.log(node, element.toString()+"\n")
project = get_parent(parents, "project")
if (parent == None):
project = context.project
context.nodes[node] = element
context.parents[node] = project
context.nodes[node].parent = context.parents[node]
elif (tag == "dependency"):
if ("local" in elements):
for local in elements["local"]:
element = local
break
elements["local"] = None
if ("remote" in elements):
for remote in elements["remote"]:
element = remote
break
elements["remote"] = None
if (element == None):
context.record(node, "Dependency polymorphism resolution failure!")
if ("subpath" in elements):
for subpath in elements["subpath"]:
element.subpath = subpath
break
elements["subpath"] = None
if ("label" in elements):
for label in elements["label"]:
element.label = label
break
elements["label"] = None
if ("build" in elements):
for instruction in elements["build"]:
element.instruction = instruction
break
elements["build"] = None
if ("imports" in elements):
for imports in elements["imports"]:
element.imports = imports
break
elements["imports"] = None
if ("exports" in elements):
for exports in elements["exports"]:
element.exports = exports
break
elements["exports"] = None
context.log(node, element.toString()+"\n")
context.nodes[node] = element
context.parents[node] = get_parent(parents, "dependencies")
context.nodes[node].parent = context.parents[node]
elif (tag == "targets"):
if ("target" in elements):
for target in elements["target"]:
element.addTarget(target)
elements["target"] = None
context.log(node, element.toString()+"\n")
project = get_parent(parents, "project")
if (parent == None):
project = context.project
context.nodes[node] = element
context.parents[node] = project
context.nodes[node].parent = context.parents[node]
elif (tag == "local"):
if ("path" in elements):
for path in elements["path"]:
element.path = path
break
elements["path"] = None
elif (tag == "remote"):
if ("git_repo" in elements):
for git_repo in elements["git_repo"]:
element = git_repo
break
elements["git_repo"] = None
if ("wget" in elements):
for w_get in elements["wget"]:
element = w_get
break
elements["wget"] = None
if ("url" in elements):
for url in elements["url"]:
element.url = url
break
elements["url"] = None
elif (tag == "git_repo"):
if ("branch" in elements):
element.branch = elements["branch"][0]
elements["branch"][0] = None
if ("credentials" in elements):
element.credentials = elements["credentials"][0]
elements["credentials"][0] = None
context.log(node, element.toString()+"\n")
elif (tag == "wget"):
output = ensure(node.text)+flatten(output).strip()
element.string = String(output.strip())
elif (tag == "branch"):
output = ensure(node.text)+flatten(output).strip()
element = Branch()
element.string = String(output.strip())
elif (tag == "subpath"):
output = ensure(node.text)+flatten(output).strip()
element = Path()
element.string = String(output.strip())
elif (tag == "path"):
output = ensure(node.text)+flatten(output).strip()
element = Path()
element.string = String(output.strip())
elif (tag == "url"):
output = ensure(node.text)+flatten(output).strip()
element = URL()
element.string = String(output.strip())
elif (tag == "credentials"):
element = Credentials()
if ("username" in elements):
element.username = elements["username"][0]
elements["username"][0] = None
if ("password" in elements):
element.password = elements["password"][0]
elements["password"][0] = None
elif (tag == "username"):
output = ensure(node.text)+flatten(output).strip()
element = Username()
element.string = String(output.strip())
elif (tag == "password"):
output = ensure(node.text)+flatten(output).strip()
element = Password()
element.string = String(output.strip())
elif (tag == "message"):
output = ensure(node.text)+flatten(output).strip()
context.record(node, output.strip()+"\n")
elif (tag == "quit"):
pass
elif (tag == "import"):
output = ensure(node.text)+flatten(output).strip()
element = Import()
element.label = Label(String(output.strip()))
elif (tag == "label"):
output = ensure(node.text)+flatten(output).strip()
element = Label()
element.string = String(output.strip())
if not (parent == None):
if not (element.getContent() in context.labels):
context.nodes[node] = element
context.labels[element.getContent()] = element
else:
context.log(node, "Labels (\""+element.getContent()+"\") must be unique!\n")
result = False
elif (tag == "source"):
output = ensure(node.text)+flatten(output).strip()
element = Path()
element.string = String(output.strip())
elif (tag == "argument"):
output = ensure(node.text)+flatten(output).strip()
element = Argument()
element.string = String(output.strip())
elif (tag == "native"):
output = ensure(node.text)+flatten(output).strip()
element = Native()
element.string = String(output.strip())
elif (tag == "exception"):
output = ensure(node.text)+flatten(output).strip()
element = Exception()
element.string = String(output.strip())
elif (tag == "hint"):
output = ensure(node.text)+flatten(output).strip()
element = Hint()
element.string = String(output.strip())
elif (tag == "component"):
output = ensure(node.text)+flatten(output).strip()
element = Component()
element.string = String(output.strip())
elif (tag == "variable"):
if ("key" in elements):
for key in elements["key"]:
element.key = key
break
elements["key"] = None
if ("value" in elements):
for value in elements["value"]:
element.value = value
break
elements["value"] = None
elif (tag == "module"):
if ("label" in elements):
for label in elements["label"]:
element.label = label
if (label.getContent() in context.labels):
keys = list(context.labels.keys())
for i in range(len(keys)):
key = keys[i]
if (key.strip() == label.getContent().strip()):
del context.labels[key]
break
break
elements["label"] = None
if ("exports" in elements):
for exports in elements["exports"]:
element.exports = exports
break
elements["exports"] = None
elif (tag == "package"):
if ("label" in elements):
for label in elements["label"]:
element.label = label
if (label.getContent() in context.labels):
keys = list(context.labels.keys())
for i in range(len(keys)):
key = keys[i]
if (key.strip() == label.getContent().strip()):
del context.labels[key]
break
break
elements["label"] = None
if ("exports" in elements):
for exports in elements["exports"]:
element.exports = exports
break
elements["exports"] = None
if ("hints" in elements):
for hints in elements["hints"]:
element.hints = hints
break
elements["hints"] = None
if ("components" in elements):
for components in elements["components"]:
element.components = components
break
elements["hints"] = None
if ("variables" in elements):
for variables in elements["variables"]:
element.variables = variables
break
elements["variables"] = None
elif (tag == "work"):
output = ensure(node.text)+flatten(output).strip()
element = Work()
element.string = String(output.strip())
elif (tag == "exceptions"):
if ("exception" in elements):
for exception in elements["exception"]:
element.addException(exception)
elements["exception"] = None
elif (tag == "hints"):
if ("hint" in elements):
for hint in elements["hint"]:
element.addHint(hint)
elements["hint"] = None
elif (tag == "components"):
if ("component" in elements):
for component in elements["component"]:
element.addComponent(component)
elements["component"] = None
elif (tag == "variables"):
if ("variable" in elements):
for variable in elements["variable"]:
element.addVariable(variable)
elements["variable"] = None
elif (tag == "arguments"):
if ("argument" in elements):
for argument in elements["argument"]:
element.addArgument(argument)
elements["argument"] = None
elif (tag == "natives"):
if ("native" in elements):
for native in elements["native"]:
element.addNative(native)
elements["native"] = None
elif (tag == "modules"):
if ("module" in elements):
for module in elements["module"]:
element.addModule(module)
elements["module"] = None
elif (tag == "packages"):
if ("package" in elements):
for package in elements["package"]:
element.addPackage(package)
elements["package"] = None
elif (tag == "build"):
if ("cmake" in elements):
for cmake in elements["cmake"]:
element = cmake
break
elements["cmake"] = None
if ("shells" in elements):
for shells in elements["shells"]:
element = shells
break
elements["shells"] = None
if ("arguments" in elements):
for arguments in elements["arguments"]:
element.arguments = arguments
break
elements["arguments"] = None
if ("pre" in elements):
for pre in elements["pre"]:
element.pre = pre
if not (pre.timing == None):
if (pre.timing.getContent() == "parse"):
if not (pre.build(context.project, os.path.join(wd(), context.root.directory.getContent(), context.project.directory.getContent(), os.path.basename(context.project.directory.getContent())), os.path.join(wd(), context.root.directory.getContent(), context.project.directory.getContent()), os.path.join(wd(), context.root.directory.getContent(), context.project.directory.getContent(), "install"), {}, context.variant)):
context.error = "Parse time pre build stop failure!"
break
elements["pre"] = None
if ("post" in elements):
for post in elements["post"]:
element.post = post
if not (post.timing == None):
if (post.timing.getContent() == "parse"):
if not (post.build(context.project, os.path.join(wd(), context.root.directory.getContent(), context.project.directory.getContent(), os.path.basename(context.project.directory.getContent())), os.path.join(wd(), context.root.directory.getContent(), context.project.directory.getContent()), os.path.join(wd(), context.root.directory.getContent(), context.project.directory.getContent(), "install"), {}, context.variant)):
context.error = "Parse time post build stop failure!"
break
elements["post"] = None
elif (tag == "cmake"):
if ("generator" in elements):
for generator in elements["generator"]:
element.generator = generator
break
elements["generator"] = None
if ("source" in elements):
for source in elements["source"]:
element.source = source
break
elements["source"] = None
if ("natives" in elements):
for natives in elements["natives"]:
element.natives = natives
break
elements["natives"] = None
elif (tag == "root"):
output = ensure(node.text)+flatten(output).strip()
element.string = String(output.strip())
elif (tag == "term"):
output = ensure(node.text)+flatten(output).strip()
element.string = String(output.strip())
elif (tag == "from"):
output = ensure(node.text)+flatten(output).strip()
element.path = Path(String(output.strip()))
elif (tag == "to"):
output = ensure(node.text)+flatten(output).strip()
element.path = Path(String(output.strip()))
elif (tag == "rename"):
output = ensure(node.text)+flatten(output).strip()
element.name = String(output.strip())
elif (tag == "destination"):
output = ensure(node.text)+flatten(output).strip()
element.path = Path(String(output.strip()))
elif (tag == "content"):
output = ensure(node.text)+flatten(output).strip()
element.string = String(output.strip())
elif (tag == "shells"):
if ("shell" in elements):
for shell in elements["shell"]:
element.shells.append(shell)
elements["shell"] = None
elif (tag == "shell"):
if ("commands" in elements):
for commands in elements["commands"]:
element.commands = commands
break
elements["commands"] = None
if ("work" in elements):
for work in elements["work"]:
element.work = work
break
elements["work"] = None
elif (tag == "commands"):
if ("command" in elements):
for command in elements["command"]: