forked from vmrp/MythroadSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mrpbuilder.py
2315 lines (2116 loc) · 108 KB
/
mrpbuilder.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
start_file = '\n\n/*************************************************************************************\n\xce\xc4\xbc\xfe\xcb\xb5\xc3\xf7: \xb1\xbe\xce\xc4\xbc\xfe\xca\xb5\xcf\xd6\xc1\xcb\xc8\xe7\xba\xce\xbd\xab\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xbd\xf8\xd0\xd0\xb7\xd6\xc1\xf7\xb3\xc9\xb6\xe0\xb8\xf6\xb6\xa8\xca\xb1\n \xc6\xf7\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060707\xb4\xb4\xbd\xa8\n*************************************************************************************/\n\ntimer = {}\n\ndef debugTrace()\nend\n\n\n/******************************************************************************\ntim_struct =\n{\ntimerId \xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4id\xba\xc5 \xd5\xe2\xb8\xf6\xb1\xd8\xd0\xeb\xca\xc7\xce\xa8\xd2\xbb\xb5\xc4\xa3\xac\xb2\xa2\xc7\xd2\xc6\xe4\xcb\xfb\xb5\xc4\xc4\xa3\xbf\xe9\n \xb1\xd8\xd0\xeb\xcd\xa8\xb9\xfd\xd5\xe2\xb8\xf6id\xb2\xc5\xc4\xdc\xbd\xf8\xd0\xd0\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xcf\xe0\xb9\xd8\xb2\xd9\xd7\xf7\xa1\xa3\ntimTime \xb5\xb1\xc7\xb0\xb6\xa8\xb6\xa8\xca\xb1\xc6\xf7\xc6\xf4\xb6\xaf\xb5\xc4\xca\xb1\xbc\xe4\xbc\xe4\xb8\xf4\ntimActive \xb5\xb1\xc7\xb0\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xca\xc7\xb7\xf1\xb1\xbb\xbc\xa4\xbb\xee\ntimRepeat \xb6\xa8\xca\xb1\xc6\xf7\xca\xc7\xb7\xf1\xca\xc7\xbf\xc9\xd6\xd8\xb8\xb4\xb5\xc4\nautoDelete \xd0\xe8\xd2\xaa\xc9\xbe\xb3\xfd\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xd3\xc3\xd3\xda\xbf\xd8\xd6\xc6\xd4\xda\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xbb\xd8\xb5\xf7\xba\xaf\xca\xfd\xd6\xd0\n \xd3\xd0\xd0\xe8\xd2\xaa\xc9\xbe\xb3\xfd\xb6\xa8\xca\xb1\xc6\xf7\xc7\xeb\xc7\xf3\xb5\xc4\xa1\xa3\ntimLeft \xb6\xa8\xca\xb1\xc6\xf7\xca\xa3\xd3\xe0\xb5\xc4\xca\xb1\xbc\xe4\ntimFunc \xb6\xa8\xca\xb1\xc6\xf7\xb6\xd4\xd3\xa6\xb5\xc4\xbb\xd8\xb5\xf7\xba\xaf\xca\xfd\n}\n******************************************************************************/ \n#define TIME_METHOD_2\n//#define TIME_METHOD_1\n//\xd3\xc3\xd3\xda\xb7\xbd\xb7\xa82\xa3\xac\xd7\xf7\xce\xaa\xd0\xc4\xcc\xf8\xa1\xa3\xd3\xc3\xd3\xda\xd1\xad\xbb\xb7\xbc\xec\xb2\xe2\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xa1\xa3\n#define TIME_TICK 200 \nlocal timList = {}\n//timer\xb5\xc4id\xa3\xac\xb4\xd31000\xbf\xaa\xca\xbc\xbc\xc6\xca\xfd\xa3\xac\xc3\xbf\xb4\xce\xd4\xf6\xbc\xd31\xa1\xa3\nlocal timeIdUuid\n//\xd3\xc3\xd3\xda\xb6\xd4\xd3\xda\xbb\xd8\xb5\xf7\xba\xaf\xca\xfd\xd6\xd0\xbb\xe1\xb3\xf6\xcf\xd6\xc6\xf4\xb6\xaf\xb6\xa8\xca\xb1\xc6\xf7\xa1\xa2\xcd\xa3\xd6\xb9\xb6\xa8\xca\xb1\xc6\xf7\xba\xcd\xc9\xbe\xb3\xfd\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xc7\xe9\xbf\xf6\xa3\xac\xd3\xc3\xd3\xda\xbb\xa5\xb3\xe2\xa1\xa3\nlocal timeInSystemCycleCb \n//local TIM_timInit, TIM_timCreate, TIM_timStart, TIM_timStop, TIM_timSetTime, TIM_timDelete\nlocal TIM_timInit\nlocal i_timCompare, sortTimerList, i_timGetUuid, i_timAdjust, i_timStart, i_timStop, i_timCycleCb\n/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n\xcb\xb5\xc3\xf7: \xb6\xd4\xcd\xe2\xb5\xc4\xbd\xd3\xbf\xda\n TIM_timCreate(aTimTime, aTimFunc) \xb4\xb4\xbd\xa8\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xb7\xb5\xbb\xd8\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4timerId\n TIM_timStart(aTimRepeat, aTimerId) \xc6\xf4\xb6\xaf\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa3\xacaRimRepeat\xca\xc7\xb7\xf1\xd6\xd8\xb8\xb4\n TIM_timStop(aTimerId)\xd4\xdd\xcd\xa3\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xb5\xab\xca\xc7\xd7\xee\xbd\xfc\xd2\xbb\xb4\xce\xb5\xc4\xbb\xd8\xb5\xf7\xd2\xb2\xd2\xf2\xb4\xcb\n \xbf\xc9\xc4\xdc\xb1\xbb\xd4\xdd\xcd\xa3\xb5\xf4\xa1\xa3\n TIM_timSetTime(aTimerId, aTimTime)\xd6\xd8\xd0\xc2\xc9\xe8\xd6\xc3\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xca\xb1\xbc\xe4\xbc\xe4\xb8\xf4\xa3\xac\xb5\xab\xca\xc7\n \xc8\xe7\xb9\xfb\xd5\xe2\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xd2\xd1\xbe\xad\xb1\xbb\xc6\xf4\xb6\xaf\xbf\xc9\xc4\xdc\xb2\xbb\xbb\xe1\xb6\xd4\xd7\xee\xbd\xfc\xb5\xc4\n \xd2\xbb\xb4\xce\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xbb\xd8\xb5\xf7\xd3\xd0\xd3\xb0\xcf\xec\xa1\xa3\n TIM_timDelete(aTimerId) \xc9\xbe\xb3\xfd\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xb2\xa2\xc7\xd2\xd7\xee\xbd\xfc\xb5\xc4\xd2\xbb\xb4\xce\xbb\xd8\xb5\xf7\xd2\xb2\xb2\xbb\xbb\xe1\n \xb1\xbb\xd6\xb4\xd0\xd0\n \n TIM_timInit() \xb6\xa8\xca\xb1\xc6\xf7\xb9\xa6\xc4\xdc\xb2\xbf\xb7\xd6\xb5\xc4\xb3\xf5\xca\xbc\xbb\xaf\xa1\xa3\xd6\xbb\xd3\xd0\xd4\xda\xb3\xcc\xd0\xf2\xb3\xf5\xca\xbc\xbb\xaf\n \xb5\xc4\xca\xb1\xba\xf2\xb5\xf7\xd3\xc3\xa1\xa3\n \n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710 \xb4\xb4\xbd\xa8\xd5\xe2\xb2\xbf\xb7\xd6\xb4\xfa\xc2\xeb\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: TIM_timInit()\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xb6\xa8\xca\xb1\xc6\xf7\xb3\xf5\xca\xbc\xbb\xaf\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef TIM_timInit()\n debugTrace ("TIM_timInit")\n timList= {}\n timeIdUuid = 1000\n timeInSystemCycleCb = 0\n #ifdef TIME_METHOD_2\n i_timStart(TIME_TICK) \n #endif\n\nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: TIM_timCreate(aTimTime, aTimFunc)\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xb4\xb4\xbd\xa8\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xd5\xe2\xc0\xef\xd0\xe8\xd2\xaa\xd7\xa2\xd2\xe2\xb5\xc4\xca\xc7\xb4\xb4\xbd\xa8\xc1\xcb\xb5\xc4\n \xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xd0\xe8\xd2\xaa\xd4\xda\xc6\xf4\xb6\xaf\xd2\xd4\xba\xf3\xb2\xc5\xc4\xdc\xbf\xaa\xca\xbc\xa1\xa3\xc1\xed\xcd\xe2\xd2\xaa\xc7\xf3\n \xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xd7\xee\xd0\xa1\xca\xb1\xbc\xe4\xbc\xe4\xb8\xf4\xca\xc7100ms\xa1\xa3\xb1\xd8\xd0\xeb\xd2\xaa\xd3\xd0\xbb\xd8\xb5\xf7\n \xba\xaf\xca\xfd\n\xba\xaf\xca\xfd\xb7\xb5\xbb\xd8: \xb4\xb4\xbd\xa8\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4id\xa3\xac\xc8\xe7\xb9\xfbid\xce\xaa0\xa3\xac\xc4\xc7\xc3\xb4\xbe\xcd\xb1\xed\xca\xbe\xd3\xd0\xce\xca\xcc\xe2 \n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef timer.create(aTimTime, aTimFunc)\n local time = {}\n \n if aTimFunc == nil then\n debugTrace ("TIM_timCreate error aTimFunc if nil")\n return 0\n end\n debugTrace ("TIM_timCreate time.time " .. aTimTime)\n \n if aTimTime <100 then \n aTimTime =100\n end\n \n time.timRepeat = 0\n time.timActive = 0\n time.timLeft = 0 \n time.autoDelete = 0 \n time.timTime = aTimTime\n time.timFunc = aTimFunc\n time.timerId = i_timGetUuid()\n time.autoDelete = 0\n \n table.insert(timList, time)\n \n return time.timerId\nend\n\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: TIM_timStart(aTimRepeat, aTimerId)\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xc6\xf4\xb6\xaf\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa1\xa3\xd5\xe2\xc0\xef\xd3\xd0\xd2\xbb\xb5\xe3\xd0\xe8\xd2\xaa\xd7\xa2\xd2\xe2\xb5\xc4\xca\xc7\xc8\xe7\xb9\xfb\n \xb6\xa8\xca\xb1\xc6\xf7\xd2\xd1\xbe\xad\xc6\xf4\xb6\xaf\xa3\xac\xc4\xc7\xc3\xb4\xbd\xab\xb2\xbb\xbb\xe1\xb6\xd4\xd6\xae\xc7\xb0\xb5\xc4timleft\xc9\xe8\xd6\xc3\n \xb2\xfa\xc9\xfa\xd3\xb0\xcf\xec\xa1\xa3\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef timer.start(aTimRepeat, aTimerId)\n local time = {}\n local timNum = table.getn(timList)\n\n if aTimRepeat == nil || timNum == 0 then\n return\n end\n\n if(aTimerId ==nil || aTimerId <1000) then\n debugTrace ("TIM_timStop error id")\n return\n end\n debugTrace ("TIM_timStart aTimerId =" .. aTimerId .. " numoftimetable = ".. timNum)\n \n for i = 1, timNum do\n time = timList[i] \n if time.timerId == aTimerId then\n debugTrace ("TIM_timStart aTimerId is found")\n if time.timActive == 1 then\n debugTrace ("TIM_timStart tim is activing")\n else\n time.timLeft = time.timTime + TIME_TICK/2\n end\n time.timRepeat = aTimRepeat \n time.timActive = 1\n break\n end // if time.timerId == aTimerId then\n end // for i = 1, timNum do\n /*\n \xc8\xe7\xb9\xfb\xb5\xb1\xc7\xb0\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4timleft\xb2\xbb\xb4\xf3\xd3\xda\xc1\xd0\xb1\xed\xd6\xd0\xb5\xda\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4timleft\n \xd4\xf2\xd0\xe8\xd2\xaa\xc6\xf4\xb6\xaf\xd2\xbb\xb4\xce\xcf\xb5\xcd\xb3\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xb1\xa3\xd6\xa4\xb6\xa8\xca\xb1\xc6\xf7\xd5\xfd\xb3\xa3\xd4\xcb\xd0\xd0\n \xc8\xe7\xb9\xfb\xb6\xa8\xca\xb1\xc6\xf7\xb5\xb1\xc7\xb0\xd5\xfd\xd4\xda\xd1\xad\xbb\xb7\xa3\xac\xc4\xc7\xc3\xb4\xbe\xcd\xb2\xbb\xd0\xe8\xd2\xaa\xbd\xf8\xd0\xd0\xc5\xc5\xd0\xf2\xba\xcd\n \xc6\xf4\xb6\xaf\xa3\xac\xcf\xb5\xcd\xb3\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xbb\xd8\xb5\xf7\xba\xaf\xca\xfd\xd6\xd0\xa3\xac\xd7\xd4\xbc\xba\xbb\xe1\xcd\xea\xb3\xc9h\n\n \xd5\xe2\xb8\xf6\xb5\xd8\xb7\xbd\xd4\xad\xcf\xc8\xd3\xd0bug\xa3\xac\xbc\xd9\xc9\xe8\xb5\xb1\xc7\xb0\xc1\xd0\xb1\xed\xd6\xd0\xc3\xbb\xd3\xd0\xbc\xa4\xbb\xee\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xc4\xc7\xc3\xb4\xd6\xbb\xca\xc7\xd6\xd8\xd0\xc2\xc5\xc5\xd0\xf2\n \xc4\xc7\xc3\xb4\xb1\xd8\xc8\xbb\xbb\xe1\xb3\xf6\xcf\xd6\xb5\xc4\xce\xca\xcc\xe2\xbe\xcd\xca\xc7\xc3\xbb\xd3\xd0\xb6\xa8\xca\xb1\xc6\xf7\xbb\xe1\xd4\xcb\xd0\xd0\xa1\xa3\n*/\n if timeInSystemCycleCb == 0 then\n if timList[1].timActive == 0 then\n sortTimerList()\n \n #ifdef TIME_METHOD_1\n local nextTime = (timList[1].timLeft < 100 && 100) || timList[1].timLeft \n i_timStart(nextTime)\n i_timAdjust(nextTime)\t\n #endif\n elif time.timLeft > timList[1].timLeft then\n //table.sort(timList, i_timCompare)\n debugTrace ("TIM_timStart time1")\n sortTimerList()\n else\n //table.sort(timList, i_timCompare)\n sortTimerList()\n\n #ifdef TIME_METHOD_1\n local nextTime = (timList[1].timLeft < 100 && 100) || timList[1].timLeft \n debugTrace ("TIM_timStart nextTime = " .. nextTime)\n i_timStart(nextTime)\n i_timAdjust(nextTime)\t \n #endif\n end\n end\n\n return\nend\n\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: TIM_timStop(aTimerId)\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xd4\xdd\xcd\xa3\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xbd\xab\xb6\xa8\xca\xb1\xc6\xf7\xd6\xc3\xce\xbb\xb7\xc7\xbb\xee\xa3\xac\xbd\xab\xb6\xa8\xca\xb1\xc6\xf7\n \xb5\xc4timleft\xd6\xc3\xce\xbb\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef timer.stop(aTimerId)\n local time = {}\n local timNum = table.getn(timList)\n \n if(aTimerId ==nil || aTimerId <1000 || timNum == 0) then\n debugTrace ("TIM_timStop error id")\n return\n end\n debugTrace ("TIM_timStop aTimerId = " .. aTimerId .." numoftimetable = ".. timNum)\n \n for i = 1, timNum do\n time = timList[i] \n if time.timerId == aTimerId then\n if time.timActive == 1 then\n \t debugTrace ("TIM_timStop tim is activing")\n else\n \t debugTrace ("TIM_timStop tim is inactive")\n end\n time.timRepeat = 0\n time.timActive = 0\n time.timLeft = 0\n end // if time.timerId == aTimerId then\n end // for i = 1, timNum do\n \n if timeInSystemCycleCb == 0 then\n //table.sort(timList, i_timCompare)\n sortTimerList()\n end\n \n return\nend\n\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: TIM_timSetTime(aTimerId, aTimTime)\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xd6\xd8\xd0\xc2\xc9\xe8\xd6\xc3\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xb6\xa8\xca\xb1\xca\xb1\xbc\xe4\xa3\xac\xd5\xe2\xc0\xef\xd0\xe8\xd2\xaa\xd7\xa2\xd2\xe2\n \xb5\xc4\xca\xc7\xa3\xac\xc8\xe7\xb9\xfb\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xca\xb1\xbc\xe4\xd4\xad\xcf\xc8\xd2\xd1\xbe\xad\xb1\xbb\xbc\xa4\xbb\xee\xa3\xac\xc4\xc7\xc3\xb4\n \xd5\xe2\xb4\xce\xd0\xde\xb8\xc4\xb2\xbb\xbb\xe1\xd3\xb0\xcf\xec\xb5\xbd\xd6\xae\xc7\xb0\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xca\xa3\xd3\xe0\xca\xb1\xbc\xe4\xc9\xe8\xd6\xc3\xa1\xa3\n \xb5\xb1\xc8\xbb\xbf\xc9\xd2\xd4\xcf\xc8\xb5\xf7\xd3\xc3TIM_timSetTime\xa3\xac\xc8\xbb\xba\xf3\xd4\xda\xb5\xf7\xd3\xc3TIM_timStart\xa1\xa3\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef timer.setTime(aTimerId, aTimTime)\n local time = {}\n local timNum = table.getn(timList)\n \n if(aTimerId ==nil || aTimerId <1000 || timNum == 0) then\n debugTrace ("TIM_timSetTime error id")\n return\n end\n //debugTrace ("TIM_timSetTime aTimerId =" .. aTimerId)\n \n for i = 1, timNum do\n time = timList[i] \n if time.timerId == aTimerId then\n if time.timActive == 1 then\n \tdebugTrace ("TIM_timSetTime tim is activing")\n else\n \tdebugTrace ("TIM_timSetTime tim is inactive")\n end\n time.timTime = aTimTime\n end\n end\n \n return\nend\n\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: TIM_timDelete(aTimerId)\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xc9\xbe\xb3\xfd\xd2\xbb\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xc8\xe7\xb9\xfb\xd4\xad\xcf\xc8\xb6\xa8\xca\xb1\xc6\xf7\xca\xc7\xb1\xbb\xbc\xa4\xbb\xee\xa3\xac\n \xc4\xc7\xc3\xb4\xc9\xbe\xb3\xfd\xd5\xe2\xb8\xf6\xb6\xa8\xca\xb1\xc6\xf7\xbd\xab\xb5\xbc\xd6\xc2\xba\xaf\xca\xfd\xb2\xbb\xbb\xe1\xb1\xbb\xb5\xf7\xd3\xc3\xa1\xa3\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef timer.delete(aTimerId)\n local time = {}\n local timNum = table.getn(timList)\n \n if(aTimerId ==nil || aTimerId <1000 || timNum == 0) then\n debugTrace ("TIM_timDelete error id")\n return\n end\n// debugTrace ("TIM_timDelete aTimerId =" .. aTimerId .." numoftimetable = ".. timNum)\n \n for i = 1, timNum do\n time = timList[i] \n if time.timerId == aTimerId then\n if time.timActive == 1 then\n debugTrace ("TIM_timDelete tim is activing")\n else\n debugTrace ("TIM_timDelete tim is inactive")\n end\n if timeInSystemCycleCb == 0 then\n table.remove(timList , i)\n else\n time.autoDelete = 1\t \t\n debugTrace ("TIM_timDelete time.autoDelete")\n end \t \n return\n end // if time.timerId == aTimerId then\n end // for i = 1, timNum do\n \n local timNum = table.getn(timList)\n \n debugTrace ("TIM_timDelete aTimerId =" .. aTimerId .." numoftimetable = ".. timNum)\n \n debugTrace ("TIM_timDelete error not foud aTimerId =" .. aTimerId)\n \n return\nend // def TIM_timDelete(aTimerId)\n\n\n/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n\xcb\xb5\xc3\xf7: \xc4\xda\xb2\xbf\xca\xb5\xcf\xd6\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060707 \xb4\xb4\xbd\xa8\xd5\xe2\xb2\xbf\xb7\xd6\xb4\xfa\xc2\xeb\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/\n /******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: i_timCompare()\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xb1\xc8\xbd\xcf\xb6\xa8\xca\xb1\xc6\xf7\xc1\xd0\xb1\xed\xd6\xd0\xc1\xbd\xb8\xf6\xd4\xaa\xcb\xd8\xb5\xc4\xb4\xf3\xd0\xa1\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef i_timCompare(aTimer1, aTimer2)\n if aTimer2.timActive == 0 then\n\t return true\n end\n if aTimer1.timActive == 0 && aTimer2.timActive == 1 then\n\t return false\n end\n return aTimer1.timLeft <= aTimer2.timLeft\nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: sortTimerList()\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xc1\xd0\xb1\xed\xbd\xf8\xd0\xd0\xc5\xc5\xd0\xf2\xa1\xa3\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef sortTimerList()\n local time1 = {}\n local time2 = {}\n local timNum = table.getn(timList)\n\n for i = 1,timNum-1 do\n time1 = timList[i]\n for j = i+1, timNum do\n\t time2 = timList[j]\n if i_timCompare(time1, time2) then\n\t //do nothing\n\t else\n\t timList[i] = timList[j]\n\t timList[j] = time1\n\t time1 = timList[i] \n\t end\n end\n end\nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: i_timGetUuid()\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xbb\xf1\xc8\xa1\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4id\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef i_timGetUuid()\n timeIdUuid = timeIdUuid +1\n return timeIdUuid\nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: i_timAdjust(nextTimeLeft)\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xcd\xb3\xd2\xbb\xbd\xab\xb6\xa8\xca\xb1\xc6\xf7\xd6\xd0\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xb5\xb1\xc7\xb0\xd6\xb5\xbc\xf5\xc8\xa51\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef i_timAdjust(nextTimeLeft)\t \n for n,timeItem in timList do\n //debugTrace ("i_timAdjust n " .. n .. " timeItem.timLeft " .. timeItem.timLeft)\t \n timeItem.timLeft = timeItem.timLeft - nextTimeLeft\t\n end\nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: i_systemTimFunc()\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xcf\xb5\xcd\xb3\xbb\xd8\xb5\xf7\xba\xaf\xca\xfd\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ni_systemTimFunc = def()\n //debugTrace ("i_systemTimFunc \\n")\n //\xb5\xf7\xca\xd4\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xb5\xf7\xca\xd4\xcd\xea\xb3\xc9\xc9\xbe\xb3\xfd\n #ifdef TIME_METHOD_2\n i_timStart(TIME_TICK) \n i_timAdjust(TIME_TICK)\n //i_timStart(TIME_TICK) \n #endif\n \n timeInSystemCycleCb = 1 \n local nextTimeLeft = i_timCycleCb()\n //\xb5\xf7\xca\xd4\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xb5\xf7\xca\xd4\xcd\xea\xb3\xc9\xc9\xbe\xb3\xfd\n \n timeInSystemCycleCb = 0\n #ifdef TIME_METHOD_1\n if nextTimeLeft != 0 then \n if (nextTimeLeft <100 ) then\n nextTimeLeft = 100\n end\n i_timAdjust(nextTimeLeft)\n //debugTrace ("i_systemTimFunc nextTimeLeft" .. nextTimeLeft)\t \n i_timStart(nextTimeLeft)\n end\n #endif \nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: i_timStart(ms)\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xc6\xf4\xb6\xaf\xcf\xb5\xcd\xb3\xb6\xa8\xca\xb1\xc6\xf7\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef i_timStart(ms)\n TimerStop(0)\n TimerStart(0, ms, "i_systemTimFunc")\n //\xb5\xf7\xca\xd4\xb6\xa8\xca\xb1\xc6\xf7\xa3\xac\xb5\xf7\xca\xd4\xcd\xea\xb3\xc9\xc9\xbe\xb3\xfd\nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: i_timStop()\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xcd\xa3\xd6\xb9\xcf\xb5\xcd\xb3\xb6\xa8\xca\xb1\xc6\xf7\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef i_timStop()\n TimerStop(0)\nend\n\n/******************************************************************************\n\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6: i_timCycleCb()\n\xb2\xce\xca\xfd\xcb\xb5\xc3\xf7: \n\xba\xaf\xca\xfd\xcb\xb5\xc3\xf7: \xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xc4\xda\xb2\xbf\xd1\xad\xbb\xb7\xba\xaf\xca\xfd\n\xb4\xb4\xbd\xa8\xd5\xdf : \xcc\xc6\xd1\xe5\n\xc0\xfa\xca\xb7\xbc\xc7\xc2\xbc: 20060710\xb4\xb4\xbd\xa8\n******************************************************************************/ \ndef i_timCycleCb()\n\n local time = {}\n local timNum = table.getn(timList)\n\n if timNum <= 0 then\n return 0;\n end\n \n if (timList[1].timActive == 0) then\n debugTrace ("i_timCycleCb error ocur no active timer")\n sortTimerList()\n return 0\n end\n\n\n \n for i = 1, timNum do\n time = timList[i] \n \n if time.timActive != 0 then\n if time.timLeft < 1 then\n // debugTrace ("tim func is execute timid = " .. time.timerId)\n\t time.timActive = 0 \t\n\t time.timLeft = 0 \n if time.timRepeat == 1 && time.autoDelete == 0 then\n //debugTrace ("tim func")\n time.timLeft = time.timTime\n time.timActive = 1\n end // if time.timRepeat == 1 && time.autoDelete == 0 \n\t //\xd3\xc3\xd3\xda\xb5\xf7\xca\xd4\xb6\xa8\xca\xb1\xc6\xf7\xcd\xa3\xd6\xb9\xce\xca\xcc\xe2\xa3\xac\xcd\xea\xb3\xc9\xba\xf3\xc9\xbe\xb3\xfd\n time.timFunc()\n\t //\xd3\xc3\xd3\xda\xb5\xf7\xca\xd4\xb6\xa8\xca\xb1\xc6\xf7\xcd\xa3\xd6\xb9\xce\xca\xcc\xe2\xa3\xac\xcd\xea\xb3\xc9\xba\xf3\xc9\xbe\xb3\xfd\n end // if time.timeLeft < 1 then\n end//if time.timActive != 0 then\n end// for i = 1, timNum do\n\n //\xcd\xb3\xd2\xbb\xc9\xbe\xb3\xfd\xc4\xc4\xd0\xa9\xd4\xda\xbb\xd8\xb5\xf7\xba\xaf\xca\xfd\xd6\xd0\xd2\xaa\xc7\xf3\xc9\xbe\xb3\xfd\xb5\xc4\xb6\xa8\xca\xb1\xc6\xf7\n for n,timeItem in timList do\n if timeItem.autoDelete == 1 then\n\t//debugTrace ("timeItem.autoDelete")\n table.remove(timList , n)\n end\t\t \t\n end\n\n local timNum = table.getn(timList)\n \n if timNum <= 0 then\n return 0;\n end\n //\xb6\xd4\xb6\xa8\xca\xb1\xc6\xf7\xb5\xc4\xb6\xd3\xc1\xd0\xbd\xf8\xd0\xd0\xc5\xc5\xd0\xf2\n //for i = 1, timNum do\n // debugTrace ("i_timCycleCb 1 timerId == " .. timList[i].timerId .. " timeItem.timLeft = " .. timList[i].timLeft) \n // end\n \n // table.sort(timList, i_timCompare)\n sortTimerList()\n \n // for i = 1, timNum do\n // debugTrace ("i_timCycleCb 1 timerId == " .. timList[i].timerId .. " timeItem.timLeft = " .. timList[i].timLeft) \n // end\n \n if timList[1].timActive == 1 then\n return timList[1].timLeft\nelse\n return 0\nend\nend\n\n//end do\nTIM_timInit()\n\nprint("mythroad init finish")\n_loadFile("main.mr")()\n'
import sys
import os
import re
import mr
import getopt
import struct
import string
import copy
import time
import zlib
import _winreg
import random
import MRC_ConfigParser
import mr_compilev2
import win32api
if ((not (hasattr(os, 'spawnvpe') or hasattr(os, 'spawnvp'))) and (hasattr(os, 'spawnve') and hasattr(os, 'spawnv'))):
def _os__spawnvpe(mode, file, args, env = None):
import sys
from errno import ENOENT, ENOTDIR
from os import path, spawnve, spawnv, environ, defpath, pathsep, error
if (env is not None):
func = spawnve
argrest = (args,
env)
else:
func = spawnv
argrest = (args)
env = environ
(head, tail,) = path.split(file)
if head:
return func(mode, file, *argrest)
if ('PATH' in env):
envpath = env['PATH']
else:
envpath = defpath
PATH = envpath.split(pathsep)
if (((os.name == 'nt') or (os.name == 'os2')) and PATH.insert(0, '')):
pass
saved_exc = None
saved_tb = None
for dir in PATH:
fullname = path.join(dir, file)
try:
return func(mode, fullname, *argrest)
except error, e:
tb = sys.exc_info()[2]
if ((e.errno != ENOENT) and ((e.errno != ENOTDIR) and (saved_exc is None))):
saved_exc = e
saved_tb = tb
if saved_exc:
raise error, saved_exc, saved_tb
raise error, e, tb
def _os_spawnvp(mode, file, args):
return os._spawnvpe(mode, file, args)
def _os_spawnvpe(mode, file, args, env):
return os._spawnvpe(mode, file, args, env)
def _os_spawnlp(mode, file, *args):
return os._spawnvpe(mode, file, args)
def _os_spawnlpe(mode, file, *args):
return os._spawnvpe(mode, file, args[:-1], args[-1])
os._spawnvpe = _os__spawnvpe
os.spawnvp = _os_spawnvp
os.spawnvpe = _os_spawnvpe
os.spawnlp = _os_spawnlp
os.spawnlpe = _os_spawnlpe
os.__all__.extend(['spawnvp',
'spawnvpe',
'spawnlp',
'spawnlpe'])
def get_start_lines():
lines = string.split(start_file, '\n')
for n in range(0, len(lines)):
lines[n] = (lines[n] + '\n')
return lines
def debuginfo(s):
if DEBUG_MOD:
print s
def infoprint(s):
print s
def extractFilename(filename):
return filename[(string.rfind(filename, '\\') + 1):]
def extractFileDir(filename):
if (string.rfind(filename, '\\') == -1):
return '.'
else:
return filename[:string.rfind(filename, '\\')]
def auth_infoprint(s):
if (mr_authorization == 'mr'):
pass
def addfile2cache(filename, data, origin_len = -1):
filecache.append((extractFilename(filename),
data,
origin_len))
def addcfile2cache(filename, localfilecahe = None):
if ((None == localfilecahe) and cfilecache.append(filename)):
pass
def dealclib(project_path, output_file, localfilecahe = None):
if (localfilecahe == None):
localfilecahe = cfilecache
if (len(localfilecahe) == 0):
return
infoprint('making c lib...')
filelist = ''
for filename in localfilecahe:
filelist = ((filelist + ' ') + filename)
param = ' r '
param = (param + output_file)
param = ((param + ' ') + filelist)
debuginfo(param)
try:
ret = os.spawnlpe(os.P_WAIT, 'armar', param, armenv)
except:
infoprint('run armar error!')
raise
if (ret != 0):
raise
def dealcfiles(project_path, with_c_global = None, c_address = None, c_helper = None, localfilecahe = None, extname = 'cfunction', c_scatter = None, exram_fix = None, fileparams = []):
if (with_c_global == None):
with_c_global = WITH_C_GLOBAL
if (c_address == None):
c_address = C_Address
if (c_helper == None):
c_helper = WITH_C_HELPER
if (localfilecahe == None):
localfilecahe = cfilecache
if (len(localfilecahe) == 0):
return
if infoprint('linking c module...'):
filelist = ''
for filename in localfilecahe:
filelist = ((filelist + ' ') + filename)
temp_file = (((os.environ['TMP'] + '\\mr_') + extname) + '.fmt')
param = ''
if (c_scatter == None):
if (c_address == None):
if (project['plat'] == 'mstar'):
param = (param + '--ropi --rwpi')
param = (param + ' "--ro-base" 0x80000')
param = (param + ' --remove ')
if (MR_C_Compiler != 'thumb'):
param = (param + ' --first mr_c_function_load')
param = (param + ' --entry mr_c_function_load ')
else:
param = (param + ' --first mr_c_function_load')
param = (param + ' --entry mr_c_function_load ')
else:
param = (param + '-ropi -rwpi')
param = (param + ' "-ro-base" 0x80000')
param = (param + ' -remove ')
if (MR_C_Compiler != 'thumb'):
param = (param + ' -first mr_c_function_load')
param = (param + ' -entry mr_c_function_load ')
elif (bmp_mode == 2):
param = (param + ' -first mr_c_function_load_thumb')
param = (param + ' -entry mr_c_function_load_thumb ')
else:
param = (param + ' -first mr_c_function_load')
param = (param + ' -entry mr_c_function_load ')
else:
param = (((param + ' "-ro-base" ') + c_address) + '')
if (MR_C_Compiler != 'thumb'):
param = (param + ' -first mr_c_function_load ')
else:
param = (param + ' -first mr_c_function_load_thumb')
else:
param = (((param + ' -scatter ') + c_scatter) + ' ')
if (MR_C_Compiler != 'thumb'):
param = (param + ' -entry mr_c_function_load ')
else:
param = (param + ' -entry mr_c_function_load_thumb ')
if (RAM_Address == None):
pass
else:
param = (((param + ' "-rw-base" ') + RAM_Address) + ' ')
if (DEBUG_MOD or WITH_C_MAP):
if (project['plat'] == 'mstar'):
param = ((((param + ' ') + '--map --info sizes,totals,veneers --xref --symbols --list ') + extname) + '.txt')
else:
param = ((((param + ' ') + '-map -info sizes,totals,veneers -xref -symbols -list ') + extname) + '.txt')
param = (param + ' -o ')
param = (param + temp_file)
param = ((param + ' ') + filelist)
if (bmp_mode == 2):
helper_lib = 'mr_helpersp'
elif (project['plat'] == 'via'):
helper_lib = 'mr_helperv4'
elif (project['plat'] == 'mstar'):
helper_lib = 'mr_helpermstar'
else:
helper_lib = 'mr_helper'
if (MR_C_Compiler == 'thumb'):
helper_lib = (helper_lib + 't')
if auth_infoprint(param):
if (c_helper == True):
base_helper_lib = helper_lib
if (project['plugin_now'] == 'plugin'):
base_helper_lib = (helper_lib + 'pluginext')
elif (project['plugin_now'] == 'app'):
base_helper_lib = (helper_lib + 'pluginapp')
elif (project['plugin_now'] == 'speed'):
base_helper_lib = (helper_lib + 'pluginspeed')
elif (project['plugin_now'] == 'main'):
base_helper_lib = (helper_lib + 'pluginmain')
elif (project['plugin_now'] == 'mainns'):
base_helper_lib = (helper_lib + 'pluginmainns')
elif (project['plugin_now'] == 'reg'):
base_helper_lib = (helper_lib + 'pluginreg')
elif (project['sdk_stack'] == 1):
base_helper_lib = (helper_lib + 'stack')
elif (project['sms_indication'] == 1):
base_helper_lib = (helper_lib + 'sms')
if (mr_authorization == 'mr'):
param = ((((param + ' ') + builder_path) + base_helper_lib) + '.lib(mr_helper.o) ')
param = ((((param + ' ') + builder_path) + base_helper_lib) + '.lib ')
else:
param = ((((param + ' ') + builder_path) + base_helper_lib) + '.lib(mr_helper.o) ')
param = ((((param + ' ') + builder_path) + base_helper_lib) + '.lib(mr_helper_s.o) ')
param = ((((param + ' ') + builder_path) + helper_lib) + 'exf.lib ')
param = (((param + builder_path) + helper_lib) + 'exb.lib ')
if ((MR_C_Compiler == 'thumb') and (c_scatter == None)):
if ((with_c_global == True) and (bmp_mode == 2)):
param = ((((param + ' ') + builder_path) + helper_lib) + 'exd.lib(mr_helper_thumb.o) ')
if project['c_flags']:
param = ((param + ' ') + project['c_flags'])
auth_infoprint(param)
try:
ret = os.spawnlpe(os.P_WAIT, (COMMAND_PATH + MR_LINK), param, armenv)
except:
infoprint('run armlink error!')
raise
if (ret != 0):
raise
if (c_scatter == None):
extfile = (((os.environ['TMP'] + '\\mr_') + extname) + '.ext')
else:
extfile = ((os.environ['TMP'] + '\\mr_') + extname)
param = ''
if (project['plat'] == 'mstar'):
param = ((param + ' --bin -o ') + extfile)
else:
param = ((param + ' -bin -o ') + extfile)
param = ((param + ' ') + temp_file)
auth_infoprint(param)
try:
ret = os.spawnlpe(os.P_WAIT, (COMMAND_PATH + MR_FROMELF), param, armenv)
except:
infoprint('run fromelf error!')
raise
if (ret != 0):
raise
if (c_scatter == None):
data = get_file(extfile, 'rb')
data = ('MRPGCMAP' + data)
if ('unzip' in fileparams):
zip_data = data
else:
zip_data = zipfile(data)
addfile2cache((extname + '.ext'), zip_data, len(data))
else:
files = os.listdir(extfile)
for f in files:
data = get_file(((extfile + '\\') + f), 'rb')
debuginfo(('before head len = ' + hex(len(data))))
data = ('MRPGCMAP' + data)
if ('unzip' in fileparams):
zip_data = data
else:
zip_data = zipfile(data)
addfile2cache((f + '.ext'), zip_data, len(data))
def unpackfile_remove(filename, fileparams = []):
for fileparam in fileparams:
m = re.match(('^\\s*remove\\s*=\\s*%s\\s*' % filename), fileparam)
if (m != None):
return True
return False
def unpackfile_filehead(fileparams = []):
for fileparam in fileparams:
m = re.match('^\\s*remain_head\\s*', fileparam)
if (m != None):
return True
return False
def unpackfile_rename(filename, fileparams = []):
for fileparam in fileparams:
m = re.match(('^\\s*rename\\s*=\\s*%s\\s*\\:\\s*(\\S+)' % filename), fileparam)
if ((m != None) and infoprint(("rename '%s' as '%s'" % (filename,
m.group(1))))):
return m.group(1)
return filename
def unpackfile(packfilename, fileparams = []):
global filehead
data = get_file(packfilename, 'rb')
(t1, headlen, t3, indexoffset,) = struct.unpack('<IIII', data[:16])
if unpackfile_filehead(fileparams):
project['filehead'] = 1
if (headlen > 232):
filehead = data[:indexoffset]
indexlen = ((headlen + 8) - indexoffset)
pos = 0
index = data[indexoffset:(headlen + 8)]
debuginfo(index)
while (pos < indexlen):
(filenamelen,) = struct.unpack('<I', index[pos:(pos + 4)])
pos = (pos + 4)
filename = index[pos:((pos + filenamelen) - 1)]
pos = (pos + filenamelen)
(filestart, filelen,) = struct.unpack('<II', index[pos:(pos + 8)])
pos = (pos + 12)
filename = unpackfile_rename(filename, fileparams)
if (unpackfile_remove(filename, fileparams) and infoprint(("remove '%s' in the pack '%s'" % (filename,
packfilename)))):
pass
else:
filehead = data[:(headlen + 8)]
mrplen = len(data)
pos = (headlen + 8)
while (pos < mrplen):
(filenamelen,) = struct.unpack('<I', data[pos:(pos + 4)])
pos = (pos + 4)
filename = data[pos:(pos + filenamelen)]
pos = (pos + filenamelen)
(filelen,) = struct.unpack('<I', data[pos:(pos + 4)])
pos = (pos + 4)
filename = unpackfile_rename(filename, fileparams)
if (unpackfile_remove(filename, fileparams) and infoprint(("remove '%s' in the pack '%s'" % (filename,
packfilename)))):
pass
pos = (pos + filelen)
def zipfile(data):
if (WITH_ZIP and debuginfo(('before zip len = ' + hex(len(data))))):
return mr.mrzip(data)
def getstr(s, l):
s_len = len(s)
if (s_len >= l):
return s[:l]
else:
return (s + ('\x00' * (l - s_len)))
def get_str_from_mpr(section, key, report = True, default = 'default'):
try:
ret = project_config.get(section, key)
except:
if (report and infoprint((((((('Can not open project file "' + sys.argv[1]) + '" or miss the key "') + key) + '" in section "') + section) + '"!'))):
sys.exit(-1)
return ret
def get_int_from_mpr(section, key, report = True, default = 0):
try:
ret = project_config.getint(section, key)
except:
if (report and infoprint((((('project file miss the key "' + key) + '" in section "') + section) + '"!'))):
sys.exit(-1)
return ret
def get_section_from_mpr(section, report = True, default = []):
try:
ret = project_config.options(section)
except:
if (report and infoprint((('project file miss the section "' + section) + '"!'))):
sys.exit(-1)
return ret
def readprojectconfig():
config = get_str_from_mpr('information', 'config')
debuginfo(('information->config=' + config))
project['config'] = config.split(',')
def buildfilehead(project_path):
global filehead
if (project['visible'] == 0):
flag = 0
else:
flag = 1
if (project['filehead'] == 1):
return
flag = (flag + (project['cpu'] * 2))
flag = (flag + (project['shell'] * 8))
filehead = 'MRPG'
filehead = (filehead + ('\x00' * 4))
filehead = (filehead + ('\x00' * 4))
filehead = (filehead + ('\x00' * 4))
filehead = (filehead + getstr(project['filename'], 12))
filehead = (filehead + getstr(project['appname'], 24))
filehead = ((((((((((filehead + g_host_auth_str[2]) + g_host_auth_str[4]) + g_host_auth_str[8]) + g_host_auth_str[9]) + g_host_auth_str[11]) + g_host_auth_str[12]) + g_host_auth_str[1]) + g_host_auth_str[7]) + g_host_auth_str[6]) + ('\x00' * 7))
filehead = (filehead + struct.pack('<i', project['appid']))
filehead = (filehead + struct.pack('<i', project['version']))
filehead = (filehead + struct.pack('<i', flag))
filehead = (filehead + struct.pack('<i', 10002))
filehead = (filehead + ('\x00' * 4))
filehead = (filehead + getstr(project['vendor'], 40))
filehead = (filehead + getstr(project['description'], 64))
filehead = (filehead + struct.pack('>i', project['appid']))
filehead = (filehead + struct.pack('>i', project['version']))
filehead = (filehead + ('\x00' * 4))
filehead = (filehead + struct.pack('<H', project['scr_w']))
filehead = (filehead + struct.pack('<H', project['scr_h']))
if ((project['plat'] == 'mtk') or (project['plat'] == 'mstar')):
filehead = (filehead + struct.pack('<B', 1))
elif (project['plat'] == 'spreadtrum'):
filehead = (filehead + struct.pack('<B', 2))
else:
filehead = (filehead + struct.pack('<B', 0))
filehead = (filehead + ('\x00' * 31))
if (project['head_append'] != None):
filehead = (filehead + get_file((project_path + project['head_append']), 'rb'))
def adjustfilehead():
global filehead
filehead_len = len(filehead)
debuginfo(('adjustfilehead:filehead_len:' + str(len(filehead))))
indexbuf_len = len(indexbuf)
filesbuf_len = len(filesbuf)
appinfo_len = ((filehead_len + indexbuf_len) - 8)
index_pos = filehead_len
file_len = ((filehead_len + indexbuf_len) + filesbuf_len)
filehead = ((((filehead[:4] + struct.pack('<i', appinfo_len)) + struct.pack('<i', file_len)) + struct.pack('<i', index_pos)) + filehead[16:])
crc = zlib.crc32(((filehead + indexbuf) + filesbuf))
filehead = ((filehead[:84] + struct.pack('<i', crc)) + filehead[88:])
def write_file(name, s, mode = 'w'):
try:
f = file(name, mode)
try:
f.write(s)
finally:
f.close()
except:
infoprint((('Can not open file "' + name) + '"!'))
raise
def packfiles():
global filesbuf
global indexbuf
index_len = 0
for (filename, data, origin_len,) in filecache:
index_len = (((index_len + len(filename)) + 1) + 16)
filehead_len = len(filehead)
debuginfo(('filehead_len:' + str(len(filehead))))
filesbuf = ''
indexbuf = ''
filebuf_pos = (filehead_len + index_len)
infoprint(('%-*s%*s %*s' % (30,
' File Name',
18,
'Size',
18,
'Origin Size')))
for (filename, data, origin_len,) in filecache:
datasize = (len(data) / 1024.0)
if (origin_len < 0):
origin_len_str = 'UNKNOW'
else:
origin_len_str = ('%5.1f' % (origin_len / 1024.0))
if (filename == MR_START_FILE):
pass
else:
if ((filename == 'cfunction.ext') and infoprint(('%-*s%*s KB%*s KB' % (30,
'Main Module',
15,
('%5.1f' % datasize),
15,
origin_len_str)))):
pass
name_len = (len(filename) + 1)
data_len = len(data)
name_buf = ((struct.pack('<i', name_len) + filename) + '\x00')
filesbuf = (((filesbuf + name_buf) + struct.pack('<i', data_len)) + data)
filebuf_pos = ((filebuf_pos + len(name_buf)) + 4)
indexbuf = ((indexbuf + name_buf) + struct.pack('<iii', filebuf_pos, data_len, 0))
filebuf_pos = (filebuf_pos + data_len)
return (indexbuf + filesbuf)
def get_file(filename, mode = 'r'):
try:
f = file(filename, mode)
try:
data = f.read()
finally:
f.close()
except:
infoprint((('can not open file "' + filename) + '"'))
sys.exit(-1)
return data
def compliecfile(src_file, obj_file, with_c_global, c_address, c_helper, local_cdefine_map, local_cinclude_map, local_filecache = None, exram_fix = None, cpu = 'ARM7EJ-S'):
param = ''
if (MR_C_Compiler == 'thumb'):
if (src_file[-2:] == '.c'):
command = 'tcc'
else:
command = 'tcpp'
if (project['plat'] == 'mstar'):
param = (param + ' --thumb ')
elif (src_file[-2:] == '.c'):
command = 'armcc'
else:
command = 'armcpp'
param = (param + '-c -I. -c ')
if (MR_C_Optimization_Lever != 'none'):
param = (((param + '-O') + MR_C_Optimization_Lever) + ' ')
else:
param = (param + '-O2 ')
if (MR_C_Optimization_Type != 'none'):
param = (((param + '-O') + MR_C_Optimization_Type) + ' ')
else:
param = (param + '-Otime ')
if (exram_fix == None):
if (MR_C_Compiler == 'thumb'):
if (bmp_mode == 2):
param = (param + '-DGET_C_FUNCTION_P()=(*(((mr_c_function_st**)mr_c_function_load_thumb)-1)) ')
param = (param + '-DGET_HELPER()=(*(((mr_table**)mr_c_function_load_thumb)-2)) ')
else:
param = (param + '-DGET_C_FUNCTION_P()=(*(((mr_c_function_st**)mr_c_function_load)-1)) ')
param = (param + '-DGET_HELPER()=(*(((mr_table**)mr_c_function_load)-2)) ')
else:
param = (param + '-DGET_C_FUNCTION_P()=(*(((mr_c_function_st**)mr_c_function_load)-1)) ')
param = (param + '-DGET_HELPER()=(*(((mr_table**)mr_c_function_load)-2)) ')
else:
param = (((param + '-DGET_C_FUNCTION_P()=(*(((mr_c_function_st**)') + exram_fix) + ')+1)) ')
param = (((param + '-DGET_HELPER()=(*(((mr_table**)') + exram_fix) + '))) ')
param = (param + get_cdefine(local_cdefine_map))
param = (param + get_cinclude(local_cinclude_map))
if (with_c_global == True):
if (c_address == None):
if (bmp_mode == 2):
param = (param + '-DMR_SPREADTRUM_MOD -DMR_BIG_ENDIAN -bi -apcs /ropi/rwpi/interwork/swst -fy -fa -zo ')
elif (project['plat'] == 'mstar'):
param = (param + '--apcs /ropi/rwpi/interwork --bss_threshold=0 --cpu 5TEJ --fpu softvfp --min_array_alignment=4 --split_sections ')
else:
param = (((param + '-cpu ') + cpu) + ' -littleend -apcs /ropi/rwpi/interwork -fa -zo ')
elif (bmp_mode == 2):
param = (param + '-DMR_SPREADTRUM_MOD -DMR_BIG_ENDIAN -bi -fy -fa -zo ')
param = (param + '-apcs /interwork/swst ')
else:
param = (((param + '-cpu ') + cpu) + ' -littleend -fa -zo ')
param = (param + '-apcs /interwork ')
elif (bmp_mode == 2):
param = (param + '-DMR_SPREADTRUM_MOD -DMR_BIG_ENDIAN -bi -apcs /ropi/interwork/norwpi/swst -fy -fa -zo ')
else:
param = (((param + '-cpu ') + cpu) + ' -littleend -apcs /ropi/interwork/norwpi -fa -zo ')
param = (param + '-o ')
param = (param + obj_file)
param = ((param + ' ') + src_file)
auth_infoprint(param)
auth_infoprint((COMMAND_PATH + command))
addcfile2cache(obj_file, local_filecache)
try:
ret = os.spawnlpe(os.P_WAIT, (COMMAND_PATH + command), param, armenv)
except:
infoprint('run armcc error!')
raise
if (ret != 0):
raise
def compliesfile(src_file, obj_file, with_c_global, c_address, c_helper, local_filecache = None):
param = ''
param = (((param + ' ') + src_file) + ' ')
if (with_c_global == True):
if (c_address == None):
if (bmp_mode == 2):
param = (param + '-bi -apcs /ropi/interwork/rwpi/swst ')
else:
param = (param + '-apcs /rwpi/interwork/ropi ')
elif (bmp_mode == 2):
param = (param + '-bi -apcs /interwork ')
else:
param = (param + '-apcs /interwork ')
elif (bmp_mode == 2):
param = (param + '-bi -apcs /ropi/interwork/norwpi ')
else:
param = (param + '-apcs /ropi/interwork/norwpi ')
param = (param + '-o ')
param = (param + obj_file)
auth_infoprint(param)
addcfile2cache(obj_file, local_filecache)
try:
ret = os.spawnlpe(os.P_WAIT, (COMMAND_PATH + 'armasm'), param, armenv)
except:
infoprint('run armasm error!')
raise
if (ret != 0):
raise
def compileextfile(extconfig, extname, project_path, fileparams, cpu):
name = extconfig[:-4]
with_c_global = get_str_from_mpr(('config_' + name), 'with_c_global', False, WITH_C_GLOBAL)
if (with_c_global == 'false'):
with_c_global = False
else:
with_c_global = True
c_address = get_str_from_mpr(('config_' + name), 'c_address', False, C_Address)
c_helper = get_str_from_mpr(('config_' + name), 'with_c_helper', False, WITH_C_HELPER)
exram_fix = get_str_from_mpr(('config_' + name), 'exram_fix', False, None)
project['plugin_now'] = get_str_from_mpr(('config_' + name), 'plugin', False, project['plugin'])
if (WITH_PLUGGIN and (project['plugin_now'] == 'normal')):
if infoprint("Can not compile a pluggin ext without 'pluggin' setting!"):
raise
if ((((project['plugin_now'] == 'main') or (project['plugin_now'] == 'mainns')) and (not ((extname == 'cfunction.ext') or (extname == 'logo.ext')))) and infoprint("Can not compile a sub ext with 'main' config!")):
raise
if ((c_helper == 'false') or (c_helper == False)):
c_helper = False
else:
c_helper = True
c_scatter = get_str_from_mpr(('config_' + name), 'c_scatter', False, None)
files = get_section_from_mpr(('files_' + name))
localfilecahe = []
for f in files:
filename = get_str_from_mpr(('files_' + name), f, False)
filename = string.lower(filename)
if (((filename[-2:] == '.c') or (filename[-4:] == '.cpp')) and infoprint((('compiling c\\c++ file ' + filename) + '...'))):
obj_file = (((os.environ['TMP'] + '\\mr_') + string.replace(filename[:-2], '\\', '_')) + '.o')
compliecfile(filename, obj_file, with_c_global, c_address, c_helper, cdefine_map, cinclude_map, localfilecahe, exram_fix, cpu)
dealcfiles(project_path, with_c_global, c_address, c_helper, localfilecahe, extname[:-4], c_scatter, exram_fix, fileparams)
def unique(s):
u = []
for x in s:
if ((x not in u) and u.append(x)):
pass
return u
def get_name(s):
m = re.match('^([^\\(]+)', s)
if (m != None):
return m.group(1)
else:
return s
def get_params(s):
m = re.search('\\s*\\(\\s*([^\\(\\)]+)\\s*', s)
if (m != None):
return string.split(m.group(1), ',')
else:
return []
def buildproject(projectfile):
global ARMCPU
global cfilecache
global WITH_ZIP
global bmp_mode
global COMMAND_PATH
global armenv
global MR_C_Optimization_Lever
global MR_C_Optimization_Type
global MR_C_Compiler
global WITH_C_HELPER
global filecache
project_path = (extractFileDir(projectfile) + '\\')
armenv = copy.deepcopy(os.environ)
armenv['LM_LICENSE_FILE'] = 'license.dat'
commandline_define = copy.deepcopy(define_map)
commandline_cdefine = copy.deepcopy(cdefine_map)
commandline_cinclude = copy.deepcopy(cinclude_map)
readprojectconfig()
for config_real in project['config']:
config = get_str_from_mpr(('config_' + config_real), 'config', False, config_real)
ResetDefine(commandline_define, commandline_cdefine, commandline_cinclude)
project['plat'] = get_str_from_mpr(('config_' + config_real), 'plat', False, get_str_from_mpr(('config_' + config), 'plat', False, get_str_from_mpr('information', 'plat', False, 'none')))
if (project['plat'] == 'none'):
bmp_config = get_str_from_mpr(('config_' + config_real), 'bmp_mode', False, get_str_from_mpr(('config_' + config), 'bmp_mode', False, get_str_from_mpr('information', 'bmp_mode', False, 'normal')))
if (bmp_config == 'spreadtrum'):
bmp_mode = 2
else:
bmp_mode = 0
elif (project['plat'] == 'spreadtrum'):
bmp_mode = 2
elif (project['plat'] == 'via'):
bmp_mode = 0
ARMCPU = 'ARM7TDMI'
elif (project['plat'] == 'mstar'):
bmp_mode = 0
armenv['LM_LICENSE_FILE'] = (armenv['RVCT22BIN'] + '/license.dat')
COMMAND_PATH = (armenv['RVCT22BIN'] + '/')
else:
bmp_mode = 0
output_format_config = get_str_from_mpr(('config_' + config_real), 'output_format', False, get_str_from_mpr(('config_' + config), 'output_format', False, get_str_from_mpr('information', 'output_format', False, 'none')))
infoprint(((((('dealing ' + config_real) + '(') + config) + ')') + ' config...'))
MR_C_Optimization_Lever = get_str_from_mpr(('config_' + config_real), 'optimization_lever', False, get_str_from_mpr(('config_' + config), 'optimization_lever', False, get_str_from_mpr('information', 'optimization_lever', False, 'none')))
cpu = get_str_from_mpr(('config_' + config_real), 'armcpu', False, get_str_from_mpr(('config_' + config), 'armcpu', False, get_str_from_mpr('information', 'armcpu', False, ARMCPU)))
MR_C_Optimization_Type = get_str_from_mpr(('config_' + config_real), 'optimization_type', False, get_str_from_mpr(('config_' + config), 'optimization_type', False, get_str_from_mpr('information', 'optimization_type', False, 'none')))
MR_C_Compiler = get_str_from_mpr(('config_' + config_real), 'c_compiler', False, get_str_from_mpr(('config_' + config), 'c_compiler', False, get_str_from_mpr('information', 'c_compiler', False, 'arm')))
project['c_flags'] = get_str_from_mpr(('config_' + config_real), 'c_flags', False, get_str_from_mpr(('config_' + config), 'c_flags', False, get_str_from_mpr('information', 'c_flags', False, None)))
outputfile = get_str_from_mpr(('config_' + config_real), 'output', False, get_str_from_mpr(('config_' + config), 'output', False, get_str_from_mpr('information', 'output', False, OUTPUT_FILE)))
project['sdk_stack'] = get_int_from_mpr(('config_' + config_real), 'sdk_stack', False, get_int_from_mpr(('config_' + config), 'sdk_stack', False, get_int_from_mpr('information', 'sdk_stack', False, 0)))
project['plugin'] = get_str_from_mpr(('config_' + config_real), 'plugin', False, get_str_from_mpr(('config_' + config), 'plugin', False, get_str_from_mpr('information', 'plugin', False, 'normal')))
project['scr_w'] = get_int_from_mpr(('config_' + config_real), 'scr_w', False, get_int_from_mpr(('config_' + config), 'scr_w', False, get_int_from_mpr('information', 'scr_w', False, 0)))
project['scr_h'] = get_int_from_mpr(('config_' + config_real), 'scr_h', False, get_int_from_mpr(('config_' + config), 'scr_h', False, get_int_from_mpr('information', 'scr_h', False, 0)))
project['sms_indication'] = get_int_from_mpr(('config_' + config_real), 'sms_indication', False, get_int_from_mpr(('config_' + config), 'sms_indication', False, get_int_from_mpr('information', 'sms_indication', False, 0)))
project['head_append'] = get_str_from_mpr(('config_' + config_real), 'head_append', False, get_str_from_mpr(('config_' + config), 'head_append', False, get_str_from_mpr('information', 'head_append', False, None)))
project['visible'] = get_int_from_mpr(('config_' + config_real), 'visible', False, get_int_from_mpr(('config_' + config), 'visible', False, get_int_from_mpr('information', 'visible', False, 1)))
project['cpu'] = get_int_from_mpr(('config_' + config_real), 'cpu', False, get_int_from_mpr(('config_' + config), 'cpu', False, get_int_from_mpr('information', 'cpu', False, 1)))
project['shell'] = get_int_from_mpr(('config_' + config_real), 'shell', False, get_int_from_mpr(('config_' + config), 'shell', False, get_int_from_mpr('information', 'shell', False, 0)))
project['filename'] = get_str_from_mpr(('config_' + config_real), 'filename', False, get_str_from_mpr(('config_' + config), 'filename', False, get_str_from_mpr('information', 'filename', False, FILE_NAME)))
project['appname'] = get_str_from_mpr(('config_' + config_real), 'appname', False, get_str_from_mpr(('config_' + config), 'appname', False, get_str_from_mpr('information', 'appname')))
project['appid'] = get_int_from_mpr(('config_' + config_real), 'appid', False, get_int_from_mpr(('config_' + config), 'appid', False, get_int_from_mpr('information', 'appid', False, APP_ID)))
project['version'] = get_int_from_mpr(('config_' + config_real), 'version', False, get_int_from_mpr(('config_' + config), 'version', False, get_int_from_mpr('information', 'version')))
project['vendor'] = get_str_from_mpr(('config_' + config_real), 'vendor', False, get_str_from_mpr(('config_' + config), 'vendor', False, get_str_from_mpr('information', 'vendor')))
project['description'] = get_str_from_mpr(('config_' + config_real), 'description', False, get_str_from_mpr(('config_' + config), 'description', False, get_str_from_mpr('information', 'description')))
project['loader'] = get_str_from_mpr(('config_' + config_real), 'loader', False, get_str_from_mpr(('config_' + config), 'loader', False, get_str_from_mpr('information', 'loader', False, 'mr')))
define_config = get_str_from_mpr(('config_' + config_real), 'define', False, get_str_from_mpr(('config_' + config), 'define', False, get_str_from_mpr('information', 'define', False, '')))
if (mr_authorization == 'mr'):
pass
else:
define_config = ('MRC_CP_MOD,' + define_config)
define_config = re.sub('\\(\\$_VERSION\\)', str(project['version']), define_config)
define_configs = define_config.split(',')
for define in define_configs:
AddDefine(define)
include_config = get_str_from_mpr(('config_' + config_real), 'include', False, get_str_from_mpr(('config_' + config), 'include', False, get_str_from_mpr('information', 'include', False, '')))
include_configs = include_config.split(',')
for include in include_configs:
AddInclude(include)
project['files'] = get_section_from_mpr('files')
project['files'] = (project['files'] + get_section_from_mpr(('files_' + config), False))
project['files'] = (project['files'] + ADD_SINGLE_FILE)
project['files'] = unique(project['files'])
project['filehead'] = None
with_c_global = get_str_from_mpr(('config_' + config), 'with_c_global', False, get_str_from_mpr('information', 'with_c_global', False, WITH_C_GLOBAL))
if ((with_c_global == 'false') or (with_c_global == False)):
with_c_global = False
else:
with_c_global = True
c_address = get_str_from_mpr(('config_' + config), 'c_address', False, get_str_from_mpr('information', 'c_address', False, C_Address))
c_helper = get_str_from_mpr(('config_' + config), 'with_c_helper', False, get_str_from_mpr('information', 'with_c_helper', False, WITH_C_HELPER))
with_zip = get_str_from_mpr(('config_' + config), 'zip', False, get_str_from_mpr('information', 'zip', False, WITH_ZIP))
exram_fix = get_str_from_mpr(('config_' + config), 'exram_fix', False, get_str_from_mpr('information', 'exram_fix', False, None))
if ((exram_fix != None) and AddDefine(('EXRAM_FIX=' + exram_fix))):
pass
if ((c_helper == 'false') or (c_helper == False)):
c_helper = False
WITH_C_HELPER = False
else:
c_helper = True
WITH_C_HELPER = True
if ((with_zip == 'false') or (with_zip == False)):
WITH_ZIP = False
else:
WITH_ZIP = True
c_scatter = get_str_from_mpr(('config_' + config), 'c_scatter', False, None)
filecache = []
cfilecache = []
if ((WITH_START == True) and mr_compilev2.init_compile(copy.deepcopy(define_map))):
lines = get_start_lines()
data = mr_compilev2.complie(MR_START_FILE, lines)
zip_data = zipfile(data)
if addfile2cache(MR_START_FILE, zip_data, len(data)):
pass
if ((c_helper and ((project['plugin'] == 'normal') or ((project['plugin'] == 'main') or (project['plugin'] == 'mainns')))) and ((project['plat'] == 'mstar') and (project['loader'] == 'c'))):
if infoprint("Warnning:Mstar mode don't support c loader!"):
project['loader'] = 'mr'
if ((mr_authorization != 'mr') and (project['loader'] == 'c')):
mr_helper_filename = '\\mr_helperk.mrp'
unpackfile((builder_path + mr_helper_filename))
fileparams = []
if ADD_FILE:
filename_params = string.lower(ADD_FILE)
filename = get_name(filename_params)
fileparams = get_params(filename_params)
unpackfile(filename, fileparams)
for f in project['files']:
filename_params = get_str_from_mpr(('files_' + config), f, False, get_str_from_mpr('files', f, False, f))
filename_params = string.lower(filename_params)
filename = get_name(filename_params)
fileparams = get_params(filename_params)
filename_in_mrp = filename
for fileparam in fileparams:
m = re.match('^\\s*name\\s*=\\s*([\\w\\.]+)\\s*', fileparam)
if (m != None):
filename_in_mrp = m.group(1)
if ((((filename[-3:] == MR_EXT) or (filename[-3:] == '.mr')) and (mr_authorization == 'mr')) and infoprint((('compiling mr file ' + filename) + '...'))):
mr_compilev2.init_compile(copy.deepcopy(define_map))
mr_compilev2.set_compile_info((project_path + filename), 0)
lines = mr_compilev2.get_file_lines((project_path + filename))
data = mr_compilev2.complie((project_path + filename), lines)
if ('unzip' in fileparams):
zip_data = data
else:
zip_data = zipfile(data)
addfile2cache(filename_in_mrp, zip_data, len(data))
if (output_format_config == 'lib'):
outputfile = dealoutputfile(outputfile, project['version'])
if ((string.find(outputfile, ':') != -1) and dealclib(project_path, outputfile)):
pass
else:
project['plugin_now'] = project['plugin']
dealcfiles(project_path, with_c_global, c_address, c_helper, None, 'cfunction', c_scatter, exram_fix, [])
buildfilehead(project_path)
data = packfiles()
adjustfilehead()
data = (filehead + data)
outputfile = dealoutputfile(outputfile, project['version'])
if ((string.find(outputfile, ':') != -1) and write_file(outputfile, data, 'wb')):
pass
def dealoutputfile(filename, ver):
s = filename
s = re.sub('\\(\\$_DATE\\)', time.strftime('%Y%m%d%H%M'), s)
s = re.sub('\\(\\$_VERSION\\)', str(ver), s)
m = re.search('\\(\\$(\\w+)\\)', s)
while (m != None):
k = m.group(1)
if debuginfo(('deal a output macro ' + k)):
if (define_map.has_key(k) and (define_map[k] == '$$MR_COMMAND_LINE_DEFINE$$')):
s = re.sub((('\\(\\$(' + k) + ')\\)'), 'Y', s)
debuginfo(s)
m = re.search('\\(\\$(\\w+)\\)', s)
return s
def get_cdefine(c_map):
d = ''
for s in c_map:
d = (((d + '-D') + s) + ' ')
return d
def get_cinclude(c_include):
d = ''
for s in c_include:
d = (((d + '-I') + s) + ' ')
return d
def SetDefine(name, value):
define_map[name] = value
def ResetDefine(commandline_define, commandline_cdefine, commandline_cinclude):
global cdefine_map
global define_map
global cinclude_map
define_map = copy.deepcopy(commandline_define)
cdefine_map = copy.deepcopy(commandline_cdefine)
cinclude_map = copy.deepcopy(commandline_cinclude)
from netbios import *
import md5
mr_authorizationstrings = ['8c147513e5bd5b3f1d0c08daa0fba7d2',
'592af9e45608febb668ee1134fc85bf8',
'd64f71132ce49028a8ff4600ec5de4ed',
'dc0526ca82a4bb7fcc762cc2dd52cc7e',
'db6a4a5bc8944054867fd7180d5e5e17',
'b0e46ca1f2ffdc73c9a3efdca5dd84f9',
'1a0bcc5d522b84fb2c0492b2cac1f7c8',
'c3464b3398f47d97e84df48ebe26f63a',
'b382238b24b7c5d2c5ff4b02353878cc',
'74c760549913da7fba9b407e7eed3b47',
'66759947a0e8b2d9fa93f67121ea51db',
'12b14afcf1b207d4b1301b8fb9ca8c5c',
'ff74e8a9a0efc7e5820deddb01d8c60f',
'6c01d4ae8253335d7d64d3ac047f29cd',
'c35bf64ae43ba9c4227d649e0ffc3757',
'581941279d2033686e9cb72da5421f95',
'e55be288547608802121dbb4b031e2b7',
'9543c7082b44f1e6a5d1238629c3393d',
'2d19a65f6f59f6c9308faffd008b0804',
'119b2dda108436d38528ee02815ce1a4',
'30876d89e2ed6d295f310e8d96b35cee',
'29132b240779d6b566beaaf6afac9c29',
'47b8c6d8f9695bad33ad09381c2400fc',
'2b8b036274af177a183112ea40ebdf1d',
'86fce19ce9796d656451544c7cfb060f',
'9c455c15b01557058ed589bffecab7ad',
'30c2e6a806104229b4a077357b24e1fe',
'95715a0d575bdc84913d049cf0396574',
'b55438bafa6d9bd5e49f7af5eea5bcaf',
'42c67fc0c6f2b05b7dc3d35b5115af79',
'd2dc7bc7c9660b1e94f9abffc4e25315',
'dc5b2e0fd20afe8ed233bf516f76cceb',
'0a8fe14e8038b7903d1207e2b6a982fc',
'e76449cb3b5af7da6e785fa77c48eb22',
'3bdc5d72098190230819d387efd94ba6',
'fcee5c8b6d6ac77f494377ec751edd35',
'cb8346215153932d02e25c078680ecdf',