NOTICE OF RELOCATION
[keystone-rtos/pcie-lld.git] / common.bld
1 \r
2 utils.importFile("printusage.bld");\r
3 \r
4 \r
5 var print_buffer = new Array();\r
6 print_buffer.help="";\r
7 print_buffer.header="";\r
8 print_buffer.body="";\r
9 print_buffer.other="";\r
10 \r
11  var source = new Array();\r
12 \r
13  source.files = new Array();\r
14 \r
15  source.hfiles = new Array();\r
16 \r
17  source.PackageArtifacts = new Array();\r
18 \r
19  source.Executables = new Array();\r
20 \r
21   var libParams_speed = {copts:"", aopts:"", defs:""};  /* compiler options for speed optimization */\r
22   var libParams_size  = {copts:"", aopts:"", defs:""};  /* compiler options for size optimization */\r
23 \r
24    /* Executable options for speed optimization */\r
25   var exeParams_speed = {\r
26                           copts:"", \r
27                           aopts:"",\r
28                           linkTemplate:"",\r
29                           cfgScript: "test.cfg",\r
30                           lopts:"",  \r
31                           exportExe: false,\r
32                           exportCfg: false\r
33                         }; \r
34 \r
35   var exeParams_size = {\r
36                           copts:"", \r
37                           aopts:"",\r
38                           linkTemplate:"",\r
39                           cfgScript: "test.cfg",\r
40                           lopts:"",\r
41                           exportExe: false,\r
42                           exportCfg: false   \r
43                         };\r
44 \r
45   var commonC54xCopts = " -pds815 -pds817 -ss -k -ms -g -as -dC548 -mf -v548";\r
46   var commonC54xAopts = " -s -dC548 -mf -v548";\r
47 \r
48   var c54_libParams = \r
49          {\r
50             copts: commonC54xCopts,\r
51             aopts: commonC54xAopts\r
52          };  /* compiler options for speed optimization */\r
53 \r
54   \r
55   var commonC55xCopts = " -c -pds1112 -pds825 -pds838 -pds828 -pds827 -pds77 -pds837 -pds824 -vcpu:2.1 -mg -ss -k";\r
56       commonC55xCopts += " -dC5510 -as -g --ptrdiff_size=16";\r
57   var commonC55xAopts = " -vcpu:2.1 -as -al -g";\r
58   var C55xSpeedOpts = " -o2 -mn";\r
59   var C55xSizeOpts = " -ms";\r
60 \r
61   var c55_libParams_speed = \r
62          {\r
63             copts: commonC55xCopts+C55xSpeedOpts,\r
64             aopts: commonC55xAopts\r
65          };  /* compiler options for speed optimization */\r
66 \r
67   var c55_libParams_size  = \r
68          {\r
69             copts: commonC55xCopts+C55xSpeedOpts+C55xSizeOpts,\r
70             aopts: commonC55xAopts\r
71          };  /* compiler options for size optimization */\r
72 \r
73 \r
74   var commonC64xCopts = " -c -k -q --mem_model:data=far -al -pds1111 -pds827 -pds824 -pds837 -pds1037 -pds195 -pdsw225";\r
75       commonC64xCopts += " -pdsw994 -pdsw262 -pds77 -pden -pds232 --consultant -mw -os -g -mi10000 -as -ss";\r
76   var commonC64xAopts = " -ea.s -c -k -mi1000";\r
77   var C64xSpeedOpts = " -o3 --optimize_with_debug";\r
78   var C64xSizeOpts = " -ms3";\r
79 \r
80 \r
81   var c64_libParams_speed = \r
82        {\r
83           copts: commonC64xCopts + C64xSpeedOpts,\r
84           aopts: commonC64xAopts\r
85        };  /* compiler options for speed optimization */\r
86 \r
87   var c64_libParams_size  = \r
88        {\r
89           copts: commonC64xCopts + C64xSpeedOpts + C64xSizeOpts,\r
90           aopts: commonC64xAopts\r
91        };  /* compiler options for size optimization */\r
92 \r
93 \r
94 \r
95   var ext;\r
96   var fileArray = new Array();\r
97   var count = 0;\r
98   var delivery_type = "obj";\r
99 \r
100 \r
101 /* parse input arguments */\r
102 function parseArgs(arguments,targs)\r
103 {\r
104   var temp_targs=targs;\r
105   var target_supported = "no";\r
106 \r
107   for (var k = 0; k < arguments.length; k++) {\r
108   switch (arguments[k]) {\r
109     case "all":\r
110           break;\r
111     case "c64Ple":\r
112       temp_targs = [C64P];\r
113       break;\r
114     case "c64Pbe":\r
115       temp_targs = [C64P_big_endian];\r
116       break;\r
117     case "c64le":\r
118       temp_targs = [C64];\r
119       break;\r
120     case "c64Pe":\r
121       temp_targs = [C64_big_endian];\r
122       break;\r
123     case "c55l":\r
124       temp_targs = [C55_large];\r
125       break;\r
126     case "c55s":\r
127       temp_targs = [C55];\r
128       break;\r
129     case "c54f":\r
130       temp_targs = [C54_far];\r
131       break;\r
132     case "c54n":\r
133       temp_targs = [C54];\r
134       break;\r
135     case "obj":\r
136       delivery_type = "obj";\r
137       break;\r
138     case "src":\r
139       delivery_type = "src";\r
140       break;\r
141     case "help":\r
142       print_buffer.help = "general";\r
143       break;\r
144     case "covrun": /* don't default this one, see config.bld */\r
145       break;\r
146     case "default": /* this is not an error */\r
147       break;\r
148      }\r
149   }\r
150   if( targs != temp_targs)\r
151   {\r
152     for( var i=0; i < targs.length; i++)\r
153         {\r
154            if(temp_targs[0] == targs[i])\r
155            {\r
156              target_supported = "yes";\r
157            }\r
158      \r
159     }\r
160         if(target_supported == "no")\r
161         {\r
162       print_buffer.other+="Target "+temp_targs[0]+" is not supported\n";\r
163           print_buffer.help = "general";\r
164         }\r
165   }\r
166   if(print_buffer.help == "general")\r
167   {\r
168     print_buffer = printUsage(print_buffer);\r
169 \r
170   }\r
171 \r
172   return[temp_targs,print_buffer];\r
173 }\r
174 \r
175 function createLib(pkgname, targArray, source)\r
176 {\r
177        \r
178   var target;\r
179 \r
180   for(var k=0;k<targArray.length;k++)\r
181   {\r
182   targ=targArray[k];    \r
183   \r
184   var dstDir = "c" + targ.suffix;\r
185 \r
186     switch(targ)\r
187     {\r
188 \r
189 \r
190     case C54: \r
191       libParams_speed=c54_libParams;\r
192       libParams_size=c54_libParams;\r
193       target="c54";\r
194       ext = "c54n";\r
195       break;\r
196 \r
197     case C55: \r
198       libParams_speed=c55_libParams_speed;\r
199       libParams_size=c55_libParams_size;\r
200       target="c55";\r
201       ext = "c55s";\r
202       break;\r
203       break;\r
204 \r
205     case C55_large: \r
206       libParams_speed=c55_libParams_speed;\r
207       libParams_size=c55_libParams_size;\r
208       target="c55";\r
209       ext = "c55l";\r
210       break;\r
211 \r
212     case C64:\r
213       libParams_speed=c64_libParams_speed;\r
214       libParams_size=c64_libParams_size;\r
215       target="c64";\r
216       ext = "c64le";\r
217       break;\r
218 \r
219 \r
220 \r
221     case C64_big_endian:       \r
222       libParams_speed=c64_libParams_speed;\r
223       libParams_size=c64_libParams_size;\r
224       target="c64";\r
225       ext = "c64be";\r
226       break;\r
227 \r
228 \r
229     case C64P:\r
230       libParams_speed=c64_libParams_speed;\r
231       libParams_size=c64_libParams_size;\r
232       target="c64";\r
233       ext = "c64Ple";\r
234       break;\r
235 \r
236 \r
237 \r
238     case C64P_big_endian:       \r
239       libParams_speed=c64_libParams_speed;\r
240       libParams_size=c64_libParams_size;\r
241       target="c64";\r
242       ext = "c64Pbe";\r
243       break;\r
244 \r
245       }\r
246   \r
247 \r
248     var clib=""; \r
249     var alib=""; \r
250     var cmlib="";\r
251 \r
252     for(var i=0;i < source.files.length;i++)\r
253     {\r
254          /* set the defaults if not defined */\r
255 \r
256          if(source.files[i].compile == undefined)\r
257             source.files[i].compile="true";\r
258          \r
259          if(source.files[i].target == undefined)\r
260             source.files[i].target="common";\r
261          \r
262          if(source.files[i].compiler_flags == undefined)\r
263             source.files[i].compiler_flags="default-speed";\r
264          \r
265          if(source.files[i].cmodel == undefined)\r
266             source.files[i].cmodel="no";\r
267          \r
268          if(source.files[i].base_directory == undefined)\r
269             source.files[i].base_directory=".";\r
270          \r
271          if(source.files[i].def_flags == undefined)\r
272             source.files[i].def_flags="";\r
273 \r
274 \r
275 \r
276          /* Check if the following list needs to be compiled */\r
277          if(source.files[i].compile=="true")\r
278          {\r
279              var flags;\r
280              /* Compile for default speed options */             \r
281              if(source.files[i].compiler_flags=="default-speed")\r
282              {\r
283                 flags=libParams_speed;\r
284              }\r
285              /* Compile for default size options */             \r
286              else if(source.files[i].compiler_flags=="default-size")\r
287              {\r
288                 flags=libParams_size;\r
289              }\r
290              /* Compile for with user defined options */             \r
291              else\r
292              {\r
293                 flags=libParams_speed;\r
294                 flags.copts=source.files[i].compiler_flags;\r
295                 flags.aopts=source.files[i].compiler_flags;\r
296              }\r
297 \r
298             /*User Pre-defines for C files*/\r
299             flags.copts += source.files[i].def_flags;   \r
300 \r
301             /*User Pre-defines for asm files*/\r
302             flags.aopts += source.files[i].def_flags;\r
303 \r
304             /* Construct the source file with complete address and differentiate c and assembly files */\r
305             cfiles=[];\r
306             afiles=[];\r
307             countc=0;\r
308             counta=0;\r
309             for(var l=0;l < source.files[i].files.length; l++)\r
310             { \r
311                var temp = source.files[i].files[l].split(".");\r
312                if(temp[1]=="c")\r
313                {\r
314                  cfiles[countc++]= source.files[i].base_directory+"/"+source.files[i].files[l];\r
315                }\r
316                else if(temp[1]=="s" || temp[1]=="sa")\r
317                {\r
318                  afiles[counta++]= source.files[i].base_directory+"/"+source.files[i].files[l];\r
319                }\r
320                else\r
321                 print("invalid file extension  "+ source.files[i].files[l]);\r
322               \r
323             }\r
324 \r
325            if((source.files[i].target==target) || (source.files[i].target=="common"))\r
326            {\r
327              if(source.files[i].cmodel=="yes")\r
328              {\r
329               if(cmlib=="")\r
330               {\r
331                 cmlib = Pkg.addLibrary(dstDir + "/"+pkgname+"_cm", targ);\r
332               }\r
333                 cmlib.addObjects(cfiles,flags); \r
334              }\r
335              else\r
336              {\r
337                 if(cfiles.length > 0)\r
338                 {\r
339                   if(clib=="")\r
340                   {\r
341                       clib = Pkg.addLibrary(dstDir + "/"+pkgname+"_c", targ);\r
342                   }\r
343                   clib.addObjects(cfiles,flags); \r
344                 }\r
345                 if(afiles.length > 0)\r
346                {\r
347                  if(alib=="")\r
348                  {\r
349                     alib = Pkg.addLibrary(dstDir + "/"+pkgname+"_a", targ);\r
350                  }\r
351                     alib.addObjects(afiles,flags); \r
352 \r
353                }\r
354              }\r
355 \r
356            }\r
357            \r
358            \r
359          }\r
360           \r
361     }\r
362 \r
363        \r
364       if(cmlib != "")\r
365          fileArray[count++] = dstDir + "/"+pkgname+"_cm.a" + targ.suffix;\r
366       else if(clib != "")\r
367          fileArray[count++] = dstDir + "/"+pkgname+"_c.a" + targ.suffix;\r
368       else if(alib != "")\r
369          fileArray[count++] = dstDir + "/"+pkgname+"_a.a" + targ.suffix;\r
370       \r
371 \r
372  \r
373 \r
374     for(var i=0; i < source.hfiles.length; i++)\r
375     {   \r
376 \r
377       if(source.hfiles[i].delivery_type == undefined)\r
378          source.hfiles[i].delivery_type="obj";\r
379          \r
380       if(source.hfiles[i].base_directory == undefined)\r
381          source.hfiles[i].base_directory=".";\r
382 \r
383       if(source.hfiles[i].target == undefined)\r
384          source.hfiles[i].target="common";\r
385 \r
386        if(source.hfiles[i].delivery_type=="obj")\r
387        {\r
388          if(source.hfiles[i].target=="common" || source.hfiles[i].target==target)\r
389          {  \r
390           for(var j=0;j< source.hfiles[i].files.length; j++)\r
391           {\r
392             fileArray[count++]=source.hfiles[i].base_directory+"/"+source.hfiles[i].files[j];\r
393           } \r
394          } \r
395        }\r
396        if(source.hfiles[i].delivery_type==delivery_type)\r
397        {\r
398          if(source.hfiles[i].target=="common" || source.hfiles[i].target==target)\r
399          {\r
400           for(var j=0;j< source.hfiles[i].files.length; j++)\r
401           {\r
402             fileArray[count++]=source.hfiles[i].base_directory+"/"+source.hfiles[i].files[j];\r
403           } \r
404 \r
405          }\r
406 \r
407        }\r
408     }\r
409 \r
410 \r
411    for(var i=0; i < source.PackageArtifacts.length; i++)\r
412    { \r
413      if((source.PackageArtifacts[i].delivery_type==delivery_type)\r
414           || (source.PackageArtifacts[i].delivery_type == "obj"))\r
415      {\r
416           for(var j=0;j< source.PackageArtifacts[i].files.length; j++)\r
417           {\r
418             fileArray[count++]=source.PackageArtifacts[i].files[j];\r
419           } \r
420      }\r
421 \r
422    }\r
423    }\r
424  return [Pkg];\r
425 }                      \r
426 \r
427 function createExe(library_name,targArray, source)\r
428 {\r
429        \r
430   var target;\r
431 \r
432   for(var k=0;k<targArray.length;k++)\r
433   {\r
434     targ=targArray[k]; \r
435      \r
436     for(var n=0;n<source.Executables.length;n++)\r
437     {\r
438   \r
439         var dstDir = "c" + targ.suffix;\r
440 \r
441         switch(targ)\r
442         {\r
443 \r
444     case C54: \r
445         exeParams_speed.copts = c54_libParams.copts;\r
446         exeParams_speed.aopts = c54_libParams.aopts;\r
447         ext = "c54n";\r
448         break;\r
449 \r
450     case C55: \r
451        exeParams_speed.copts = c55_libParams_speed.copts;\r
452        exeParams_speed.aopts = c55_libParams_speed.aopts;\r
453        target="c55";\r
454        ext = "c55s";\r
455       break;\r
456 \r
457     case C55_large: \r
458       exeParams_speed.copts = c55_libParams_speed.copts;\r
459       exeParams_speed.aopts = c55_libParams_speed.aopts;\r
460       target="c55";\r
461       ext = "c55l";\r
462       break;\r
463 \r
464     case C64:\r
465       exeParams_speed.copts = c64_libParams_speed.copts;\r
466       exeParams_speed.aopts = c64_libParams_speed.aopts;\r
467       target="c64";\r
468       ext = "c64le";\r
469       break;\r
470 \r
471     case C64_big_endian:       \r
472       exeParams_speed.copts = c64_libParams_speed.copts;\r
473       exeParams_speed.aopts = c64_libParams_speed.aopts;\r
474       target="c64";\r
475       ext = "c64be";\r
476       break;\r
477 \r
478 \r
479     case C64P:\r
480       exeParams_speed.copts = c64_libParams_speed.copts;\r
481       exeParams_speed.aopts = c64_libParams_speed.aopts;\r
482       target="c64";\r
483       ext = "c64Ple";\r
484       break;\r
485 \r
486 \r
487 \r
488     case C64P_big_endian:  \r
489       exeParams_speed.copts = c64_libParams_speed.copts;\r
490       exeParams_speed.aopts = c64_libParams_speed.aopts;     \r
491       target="c64";\r
492       ext = "c64Pbe";\r
493       break;\r
494 \r
495      }\r
496 \r
497      if(source.Executables[n].target==ext)\r
498        {   \r
499          createLib(library_name,targs, source);\r
500          \r
501         /* Common Executable configuration */\r
502          if(source.Executables[n].linkTemplate == undefined)\r
503          {\r
504            exeParams_speed.linkTemplate = source.Executables[n].base_directory+"/"+ source.Executables[n].exe_name+".xdt";\r
505          }\r
506          else\r
507          {\r
508            exeParams_speed.linkTemplate = source.Executables[n].base_directory+"/"+source.Executables[n].linkTemplate;\r
509          }\r
510 \r
511          if (delivery_type == "src")\r
512          { \r
513              exeParams_speed.exportExe = true;\r
514              exeParams_speed.exportCfg = true;  \r
515              fileArray[count++]=exeParams_speed.linkTemplate;\r
516              fileArray[count++]=source.Executables[n].base_directory+"/"+source.Executables[n].exe_name+".cmd";\r
517 \r
518          }  \r
519       \r
520          Pkg.addExecutable (source.Executables[n].exe_name, targ, source.Executables[n].platform,\r
521                                               exeParams_speed).addObjects(source.Executables[n].test_file);\r
522 \r
523     \r
524    }\r
525   }  \r
526   }\r
527  return [Pkg];\r
528 }                      \r
529 \r
530 \r
531 \r
532 function createTar(pkgName,targArray)\r
533  {\r
534   var xmltree;\r
535   var pkgName;\r
536   if(targArray.length > 1)\r
537     ext="all"; \r
538 \r
539    rel_name = "ti_mas_"+pkgName+"_" + delivery_type + "_" + ext;\r
540    for (var i = 0; i < version.length; i++) {\r
541          rel_name = rel_name + "_" + version[i];\r
542       }\r
543 \r
544   \r
545      if (delivery_type == "obj") {\r
546        var obj = Pkg.addRelease(rel_name);\r
547        obj.otherFiles = fileArray;\r
548        Pkg.defaultRelease = obj;\r
549      }\r
550      else if (delivery_type == "src") {\r
551        var src = Pkg.addRelease (rel_name, {exportSrc: true});\r
552        src.otherFiles = fileArray;\r
553        Pkg.defaultRelease = src;\r
554      } \r
555              \r
556 }                   \r
557 \r
558 \r
559 \r