DSPLIB: optimized signal processing functions for TI DSPs
[ep-processor-libraries/dsplib.git] / ti / dsplib / package.bld
1 /******************************************************************************
2  * FILE PURPOSE: Build description for package ti.dsplib
3  ******************************************************************************
4  * FILE NAME: package.bld  
5  *
6  * DESCRIPTION: This file contains attributes to build and create releases for 
7  *              package ti.dsplib
8  * 
9  * TABS: NONE
10  *
11  * Copyright (C) 2010 Texas Instruments, Inc.
12  ******************************************************************************/
14   var Package=xdc.loadCapsule('ti/mas/swtools/CommonBld.xs');
15   
16   /* Global Variables */
17   Package.bundlename="dsplib";
19   Package.bundletype="kernel";
21   var doxygenstring= " docs/doxygen ";
23   /* Local Variables */
24   
25   var IncludeList=new Array();
26  
27   /* List names of directories */
28  //IncludeList=["DSP_fft16x16","DSP_fft16x32","DSP_fft32x32","DSPF_sp_fftSPxSP"];
29  //IncludeList=["DSP_fft16x16","DSP_fft16x32","DSP_fft32x32","DSPF_sp_fftSPxSP","DSP_fft16x16_imre","DSP_fft16x16r","DSP_fft32x32s","DSP_ifft16x16","DSP_ifft16x16_imre", "DSP_ifft16x32","DSP_ifft32x32"];
30  //IncludeList=["DSP_fft16x16","DSP_fft16x32","DSP_fft32x32","DSPF_sp_fftSPxSP", "DSPF_sp_cholesky", "DSPF_dp_cholesky"];
31  //IncludeList=["DSP_urand32","DSP_urand16","DSPF_sp_urand","DSPF_sp_erand", "DSPF_sp_nrand"]; 
32  //IncludeList=["DSP_fft16x16","DSP_fft16x32","DSP_fft32x32","DSPF_sp_fftSPxSP", "DSPF_sp_lud","DSPF_dp_lud","DSPF_sp_evd","DSPF_dp_evd","DSPF_sp_qrd","DSPF_dp_qrd","DSPF_sp_svd","DSPF_dp_svd"];
33  
34   /* Command line handling */
35   Package.args["knl"] = {
36     value:"knl",
37       action: function(value) {
38         IncludeList = new Array(value);
39       },
40     usageComment: "       Select a kernel to compile"
41   }
44  var ExcludeList=[
45                   {name:"DSPF_sp_cholesky_cmplx",srcDir:"c64P"},
46                   {name:"DSPF_dp_cholesky_cmplx",srcDir:"c64P"},
47                   {name:"DSPF_sp_lud_cmplx",srcDir:"c64P"},
48                   {name:"DSPF_dp_lud_cmplx",srcDir:"c64P"},
49                   {name:"DSPF_sp_lud_inv_cmplx",srcDir:"c64P"},
50                   {name:"DSPF_dp_lud_inv_cmplx",srcDir:"c64P"},
51                   {name:"DSPF_sp_lud_sol_cmplx",srcDir:"c64P"},
52                   {name:"DSPF_dp_lud_sol_cmplx",srcDir:"c64P"},
53                   {name:"DSPF_sp_qrd_cmplx",srcDir:"c64P"},
54                   {name:"DSPF_dp_qrd_cmplx",srcDir:"c64P"},
55                   {name:"DSPF_sp_svd_cmplx",srcDir:"c64P"},
56                   {name:"DSPF_dp_svd_cmplx",srcDir:"c64P"},                               
57                   {name:"DSPF_sp_lud",srcDir:"c64P"},
58                   {name:"DSPF_dp_lud",srcDir:"c64P"},
59                   {name:"DSPF_sp_lud_inv",srcDir:"c64P"},
60                   {name:"DSPF_dp_lud_inv",srcDir:"c64P"},
61                   {name:"DSPF_sp_lud_sol",srcDir:"c64P"},
62                   {name:"DSPF_dp_lud_sol",srcDir:"c64P"},
63                   {name:"DSPF_sp_qrd",srcDir:"c64P"},
64                   {name:"DSPF_dp_qrd",srcDir:"c64P"},
65                   {name:"DSPF_sp_svd",srcDir:"c64P"},
66                   {name:"DSPF_dp_svd",srcDir:"c64P"},
67                   {name:"DSP_urand32",srcDir:"c64P"},
68                   {name:"DSP_urand16",srcDir:"c64P"},
69                   {name:"DSPF_sp_urand",srcDir:"c64P"},
70                   {name:"DSPF_sp_nrand",srcDir:"c64P"},
71                   {name:"DSPF_sp_erand",srcDir:"c64P"},
72                   {name:"DSPF_sp_cholesky",srcDir:"c64P"},
73                   {name:"DSPF_dp_cholesky",srcDir:"c64P"},
74                   {name:"DSPF_sp_fftSPxSP",srcDir:"c64P"},
75                   {name:"DSPF_sp_ifftSPxSP",srcDir:"c64P"},
76                   {name:"DSPF_sp_fftSPxSP_r2c",srcDir:"c64P"},
77                   {name:"DSPF_sp_ifftSPxSP_c2r",srcDir:"c64P"},
78                   {name:"DSPF_sp_fir_cplx",srcDir:"c64P"},
79                   {name:"DSPF_sp_fir_gen",srcDir:"c64P"},
80                   {name:"DSPF_sp_fir_r2",srcDir:"c64P"},
81                   {name:"DSPF_sp_fircirc",srcDir:"c64P"},
82                   {name:"DSPF_sp_autocor",srcDir:"c64P"},
83                   {name:"DSPF_sp_biquad",srcDir:"c64P"},
84                   {name:"DSPF_sp_convol",srcDir:"c64P"},
85                   {name:"DSPF_sp_bitrev_cplx",srcDir:"c64P"},
86                   {name:"DSPF_sp_dotp_cplx",srcDir:"c64P"},
87                   {name:"DSPF_sp_dotprod",srcDir:"c64P"},
88                   {name:"DSPF_sp_lms",srcDir:"c64P"},
89                   {name:"DSPF_sp_iir",srcDir:"c64P"},
90                   {name:"DSPF_sp_mat_trans",srcDir:"c64P"},
91                   {name:"DSPF_sp_iirlat",srcDir:"c64P"},
92                   {name:"DSPF_sp_maxidx",srcDir:"c64P"},
93                   {name:"DSPF_sp_mat_mul",srcDir:"c64P"},
94                   {name:"DSPF_sp_maxval",srcDir:"c64P"},
95                   {name:"DSPF_sp_mat_mul_cplx",srcDir:"c64P"},
96                   {name:"DSPF_sp_minerr",srcDir:"c64P"},
97                   {name:"DSPF_sp_minval",srcDir:"c64P"},
98                   {name:"DSPF_sp_vecadd",srcDir:"c64P"},
99                   {name:"DSPF_sp_vecmul",srcDir:"c64P"},
100                   {name:"DSPF_sp_vecrecip",srcDir:"c64P"},
101                   {name:"DSPF_sp_vecsum_sq",srcDir:"c64P"},
102                   {name:"DSPF_sp_w_vec",srcDir:"c64P"},
103                   {name:"DSPF_blk_eswap16",srcDir:"c64P"},
104                   {name:"DSPF_blk_eswap32",srcDir:"c64P"},
105                   {name:"DSPF_blk_eswap64",srcDir:"c64P"},
106                   {name:"DSPF_fltoq15",srcDir:"c64P"},
107                   {name:"DSPF_q15tofl",srcDir:"c64P"},
108                   {name:"DSPF_sp_blk_move",srcDir:"c64P"},
109                   {name:"DSPF_sp_cfftr2_dit",srcDir:"c64P"},
110                   {name:"DSPF_sp_cfftr4_dif",srcDir:"c64P"},
111                   {name:"DSPF_sp_icfftr2_dif",srcDir:"c64P"},
112                   {name:"DSP_fir_r8_h8",srcDir:"c64P"},
113                   {name:"DSP_fir_r8_h16",srcDir:"c64P"},
114                   {name:"DSP_fir_r8_h24",srcDir:"c64P"},
115                   {name:"DSPF_dp_fftDPxDP",srcDir:"c64P"},
116                   {name:"DSPF_sp_mat_mul_gemm_cplx",srcDir:"c64P"},
117                   {name:"DSPF_sp_mat_trans_cplx",srcDir:"c64P"},
118                   {name:"DSPF_sp_mat_submat_copy_cplx",srcDir:"c64P"},
119                   {name:"DSPF_dp_ifftDPxDP",srcDir:"c64P"},
120                   {name:"DSPF_dp_mat_mul_gemm",srcDir:"c64P"},
121                   {name:"DSPF_sp_mat_submat_copy",srcDir:"c64P"},
122                   {name:"DSPF_sp_mat_mul_gemm",srcDir:"c64P"},
123                   {name:"DSPF_dp_mat_trans",srcDir:"c64P"},
124                   {name:"DSPF_dp_mat_submat_copy",srcDir:"c64P"},
126                   {name:"DSPF_blk_eswap16",srcDir:"c66"},
127                   {name:"DSPF_blk_eswap32",srcDir:"c66"},
128                   {name:"DSPF_blk_eswap64",srcDir:"c66"},
129                   {name:"DSPF_fltoq15",srcDir:"c66"},
130                   {name:"DSPF_q15tofl",srcDir:"c66"},
131                   {name:"DSPF_sp_blk_move",srcDir:"c66"},
132                   {name:"DSPF_sp_cfftr2_dit",srcDir:"c66"},
133                   {name:"DSPF_sp_cfftr4_dif",srcDir:"c66"},
134                   {name:"DSPF_sp_icfftr2_dif",srcDir:"c66"},
136                   {name:"DSPF_sp_cholesky_cmplx",srcDir:"c674"},
137                   {name:"DSPF_dp_cholesky_cmplx",srcDir:"c674"},
138                   {name:"DSPF_sp_lud_cmplx",srcDir:"c674"},
139                   {name:"DSPF_dp_lud_cmplx",srcDir:"c674"},
140                   {name:"DSPF_sp_lud_inv_cmplx",srcDir:"c674"},
141                   {name:"DSPF_dp_lud_inv_cmplx",srcDir:"c674"},
142                   {name:"DSPF_sp_lud_sol_cmplx",srcDir:"c674"},
143                   {name:"DSPF_dp_lud_sol_cmplx",srcDir:"c674"},
144                   {name:"DSPF_sp_qrd_cmplx",srcDir:"c674"},
145                   {name:"DSPF_dp_qrd_cmplx",srcDir:"c674"},
146                   {name:"DSPF_sp_svd_cmplx",srcDir:"c674"},
147                   {name:"DSPF_dp_svd_cmplx",srcDir:"c674"},
148                   {name:"DSPF_dp_lud",srcDir:"c674"}, 
149                   {name:"DSPF_sp_lud",srcDir:"c674"}, 
150                   {name:"DSPF_sp_lud_inv",srcDir:"c674"},
151                   {name:"DSPF_dp_lud_inv",srcDir:"c674"},
152                   {name:"DSPF_sp_lud_sol",srcDir:"c674"},
153                   {name:"DSPF_dp_lud_sol",srcDir:"c674"},
154                   {name:"DSPF_dp_qrd",srcDir:"c674"}, 
155                   {name:"DSPF_sp_qrd",srcDir:"c674"}, 
156                   {name:"DSPF_dp_svd",srcDir:"c674"}, 
157                   {name:"DSPF_sp_svd",srcDir:"c674"}, 
158                   {name:"DSP_urand32",srcDir:"c674"},
159                   {name:"DSP_urand16",srcDir:"c674"},
160                   {name:"DSPF_sp_urand",srcDir:"c674"},
161                   {name:"DSPF_sp_nrand",srcDir:"c674"},
162                   {name:"DSPF_sp_erand",srcDir:"c674"},
163                   {name:"DSPF_sp_cholesky",srcDir:"c674"},
164                   {name:"DSPF_dp_cholesky",srcDir:"c674"},
165                   {name:"DSPF_dp_fftDPxDP",srcDir:"c674"},
166                   {name:"DSPF_sp_fftSPxSP_r2c",srcDir:"c674"},
167                   {name:"DSPF_sp_ifftSPxSP_c2r",srcDir:"c674"},
168                   {name:"DSPF_sp_mat_trans_cplx",srcDir:"c674"},
169                   {name:"DSPF_sp_mat_submat_copy_cplx",srcDir:"c674"},
170                   {name:"DSPF_dp_ifftDPxDP",srcDir:"c674"},
171                   {name:"DSPF_dp_mat_mul_gemm",srcDir:"c674"},
172                   {name:"DSPF_sp_mat_submat_copy",srcDir:"c674"},
173                   {name:"DSPF_dp_mat_trans",srcDir:"c674"},
174                   {name:"DSPF_dp_mat_submat_copy",srcDir:"c674"},
175                   {name:"DSPF_sp_vecadd",srcDir:"c674"},
176                   {name:"DSP_add16",srcDir:"c674"},
177                   {name:"DSP_add32",srcDir:"c674"},
178                   {name:"DSP_autocor",srcDir:"c674"},
179                   {name:"DSP_bexp",srcDir:"c674"},
180                   {name:"DSP_blk_eswap16",srcDir:"c674"},
181                   {name:"DSP_blk_eswap32",srcDir:"c674"},
182                   {name:"DSP_blk_eswap64",srcDir:"c674"},
183                   {name:"DSP_blk_move",srcDir:"c674"},
184                   {name:"DSP_dotprod",srcDir:"c674"},
185                   {name:"DSP_dotp_sqr",srcDir:"c674"},
186                   {name:"DSP_fft16x16",srcDir:"c674"},
187                   {name:"DSP_fft16x16r",srcDir:"c674"},
188                   {name:"DSP_fft16x16_imre",srcDir:"c674"},
189                   {name:"DSP_fft16x32",srcDir:"c674"},
190                   {name:"DSP_fft32x32",srcDir:"c674"},
191                   {name:"DSP_fft32x32s",srcDir:"c674"},
192                   {name:"DSP_firlms2",srcDir:"c674"},
193                   {name:"DSP_fir_cplx",srcDir:"c674"},
194                   {name:"DSP_fir_cplx_hM4X4",srcDir:"c674"},
195                   {name:"DSP_fir_gen",srcDir:"c674"},
196                   {name:"DSP_fir_gen_hM17_rA8X8",srcDir:"c674"},
197                   {name:"DSP_fir_r4",srcDir:"c674"},
198                   {name:"DSP_fir_r8",srcDir:"c674"},
199                   {name:"DSP_fir_r8_hM16_rM8A8X8",srcDir:"c674"},
200                   {name:"DSP_fir_sym",srcDir:"c674"},
201                   {name:"DSP_fltoq15",srcDir:"c674"},
202                   {name:"DSP_ifft16x16",srcDir:"c674"},
203                   {name:"DSP_ifft16x16_imre",srcDir:"c674"},
204                   {name:"DSP_ifft16x32",srcDir:"c674"},
205                   {name:"DSP_ifft32x32",srcDir:"c674"},
206                   {name:"DSP_iir",srcDir:"c674"},
207                   {name:"DSP_iir_lat",srcDir:"c674"},
208                   {name:"DSP_iir_ss",srcDir:"c674"},
209                   {name:"DSP_mat_mul",srcDir:"c674"},
210                   {name:"DSP_mat_mul_cplx",srcDir:"c674"},
211                   {name:"DSP_mat_trans",srcDir:"c674"},
212                   {name:"DSP_maxidx",srcDir:"c674"},
213                   {name:"DSP_maxval",srcDir:"c674"},
214                   {name:"DSP_minerror",srcDir:"c674"},
215                   {name:"DSP_minval",srcDir:"c674"},
216                   {name:"DSP_mul32",srcDir:"c674"},
217                   {name:"DSP_neg32",srcDir:"c674"},
218                   {name:"DSP_q15tofl",srcDir:"c674"},
219                   {name:"DSP_recip16",srcDir:"c674"},
220                   {name:"DSP_vecsumsq",srcDir:"c674"},
221                   {name:"DSP_w_vec",srcDir:"c674"}]
224 var TIREX_TARGET;
226   for (var k = 0; k < arguments.length; k++)
227   {
228    switch (arguments[k])
229    {
230     case "c66x":
231       TIREX_TARGET  = "C66X";
232       break;
233     case "c674x":
234       TIREX_TARGET  = "C674X";
235       break;
236     case "c64Px":
237       TIREX_TARGET  = "C64PX";
238       break;
239    }
240   }
241   
242 var SpecialList=[]
244 Package.archiveFiles["CommonArchiveFiles"] = {
245     files: [
246             "docs/manifest/Software_Manifest.html",
247             "docs/bundle/manifest/doxyfile.xdt",
248             "docs/bundle/doxygen/doxyfile.xdt",
249             "docs/manifest/manifest.xml.xdt",
250             "setenv.bat",
251             "setxdcpath.js",
252              
253           ]
254   };
256   Package.archiveFiles["bundle"] = {
257     base_directory: ".",
258     delivery_type: "bundle",
259     files: ["docs/DSPLIB_Software_Manifest.html", 
260             "docs/DSPLIB_Users_Manual.html",
261             "docs/doxygen/html",
262             "docs/manifest/html",
263             "examples",
264             ".metadata",
265             "README.txt"]
266   };
268   Package.archiveFiles["bundle-c64x"] = {
269     base_directory: "./docs",
270     delivery_type: "bundle",
271     files: ["DSPLIB_C64Px_TestReport.html"],
272     target:["c64Ple","c64Pbe","ce64Ple","ce64Pbe"]
273   };
274   Package.archiveFiles["bundle-c66x"] = {
275     base_directory: "./docs",
276     delivery_type: "bundle",
277     files: ["DSPLIB_C66x_TestReport.html"],
278     target:["c66le","c66be","ce66le","ce66be"]
279   };    
280   Package.archiveFiles["bundle-c674x"] = {
281     base_directory: "./docs",
282     delivery_type: "bundle",
283     files: ["DSPLIB_C674x_TestReport.html"],
284     target:["c674le","ce674le"]
285   };    
287   
288 /**********************************************************************************************
289   The main package.bld routine starts here 
290 ***********************************************************************************************/
292   /* Set up the targets array. Current implementation support c674x, c66x and c64x*/
293   Package.targets = [C64P, C64P_big_endian, C64P_elf, C64P_big_endian_elf, C66, C66_big_endian, C66_elf, C66_big_endian_elf, C674, C674_elf, VC98];
295     /* Set up version number for the package */
296   Package.pkgStdVer = "2.0";
297   Package.version = [3, 4, 0, 1, 3, 0];
298   
299   Package.createVersion();
301   /* Parse XDC Arguments */
302   Package.parseArgs(arguments);
303   
304   /* Default delivery type is "source" for this release */ 
305   Package.delivery_type = "src";  
306   
307   
308   /* Call Local function to set up parameters for ccs projects */
309   if(!String(Package.targs[0]).match("VC98"))
310   {
311     addArtifacts();
312   }
313   else
314   {
315     createExe();
316  }
317    
318   /* generate Doxyfile based on the version array above */
319   var tplt = xdc.loadTemplate("./docs/doxygen/doxyfile.xdt");
320   tplt.genFile("./docs/doxygen/Doxyfile",null, [Package.version,doxygenstring]);  
322   /* Generate Software Manifest XML file */
323   var tplt = xdc.loadTemplate("./docs/manifest/manifest.xml.xdt");
324   tplt.genFile("./docs/manifest/manifest.xml",Package);  
326   /* Generate DSPLIB bundle users manual Doxyfile */
327   tplt = xdc.loadTemplate("./docs/bundle/doxygen/doxyfile.xdt");
328   tplt.genFile("./docs/bundle/doxygen/Doxyfile",Package);      
330   /* Generate DSPLIB bundle manifest Doxyfile */
331   tplt = xdc.loadTemplate("./docs/bundle/manifest/doxyfile.xdt");
332   tplt.genFile("./docs/bundle/manifest/Doxyfile",Package);      
334   /* Generate TI REX meta data */
335   print( "Generating TI REX"); 
336   var tirex_tplt = xdc.loadTemplate("./package.ccs.json.xdt");
337   tirex_tplt.genFile("./.metadata/.tirex/package.ccs.json",null,[TIREX_TARGET]);
339   tirex_tplt = xdc.loadTemplate("./package.tirex.json.xdt");
340   tirex_tplt.genFile("./.metadata/.tirex/package.tirex.json",null,[Package.version,TIREX_TARGET]);
342   /* Include custom makefile to generate doxygen documents */
343   Package.includeMake("Makedocs.mk");
344   Package.bundleMakeDoc = "MakedocsBundle.mk";   
346   if(!String(Package.targs[0]).match("VC98"))
347   {
348     Package.createProjects();
349   }
350  
351   createknlhdr();
353    
354   /* Create Archive */ 
355   Package.createArchive();
356   
357   /* Clean Package */
358   Package.packageClean();
360 /**********************************************************************************************
361   The main package.bld routine ends here 
362 ***********************************************************************************************/
363   
364   
365   /** Local function to add projects **/
366   function addArtifacts() {
367     
368     if (IncludeList == "") {
369       var file = new java.io.File("src");
370       IncludeList = file.list();
371     }
372     
373     var libc_c674 = new Array();
374     var libc_c64p = new Array();
375     var libc_c66 = new Array();
376     var libcn_c674 = new Array();
377     var libcn_c64p = new Array();
378     var libcn_c66 = new Array();
379     
380     
381     for each (var dir in IncludeList) {
382     
383       if( dir == "common")
384          continue;
385       var special   = false; 
386       var exclude64p   = false;
387       var exclude66   = false;
388       var exclude674   = false;
389       var exclude64ple   = false;
390       var exclude66le   = false;
391       var exclude64pbe   = false;
392       var exclude66be   = false;
393       var exclude674le   = false;
394       
395       /* Check if dir is in exclude list */
396       for each (var excludedir in ExcludeList) {
397         if (excludedir.name == dir){
398            if(excludedir.srcDir.toString().match("c64Ple")) {
399              exclude64ple = true;
400            }
401            else if(excludedir.srcDir.toString().match("c64Pbe")) {
402              exclude64pbe = true;
403            }
404            else if(excludedir.srcDir.toString().match("c64P")) {
405              exclude64p = true;
406            }
407            
408            if(excludedir.srcDir.toString().match("c674le")) {
409              exclude674le = true;
410            }
411            else if(excludedir.srcDir.toString().match("c674")) {
412              exclude674 = true;
413            }
414            
415            if(excludedir.srcDir.toString().match("c66le")) {
416              exclude66le = true;
417            }
418            else if(excludedir.srcDir.toString().match("c66be")) {
419              exclude66be = true;
420            }
421            else if(excludedir.srcDir.toString().match("c66")) {
422              exclude66 = true;
423            }
424          }
425        }
426       
427       /* Check if dir is in special list */
428       for each (var specialdir in SpecialList) {
429         if (specialdir.name == dir && specialdir.srcDir == srcDir) {
430           special = true;
431           break;
432         }
433       }
434       if (special == true) { cflags = specialdir.cflags; }
436      
437       /*****************************************************************************
438         Local Variables 
439        *****************************************************************************/
440       var projectname = dir;
441       var projectroot = "src/" + projectname + "/";
442       var commonroot  = "src/common/";
443       var prjtargroot;
444       var prjtarget; 
445       var linkfile;
446       
448       /*****************************************************************************
449         Kernel C66x project
450        *****************************************************************************/
451       if(exclude66 == false)
452       {
453           if(exclude66le == true)
454             prjtarget="66be";
455           else if(exclude66be == true)
456             prjtarget="66le";
457           else
458             prjtarget = "66"
459           prjtargroot = projectroot + "/c66/";
460           cmntargroot = commonroot  + "/c66/";
462           linkfile = new Array();
463           if (xdc.findFile(prjtargroot+"lnk.cmd")) 
464           {
465             linkfile.push(prjtargroot+"lnk.cmd");
466           }
467           else
468           {
469             linkfile.push(cmntargroot + "lnk.cmd");
470           }
471           
472           findProjectFiles (projectroot,linkfile,dir,"66");
473           findProjectFiles (prjtargroot,linkfile,dir,"66");
474           
475           /* Add library files */
476           findLibFiles(prjtargroot, libc_c66, libcn_c66, dir);
477         
478           Package.ccsProjects.push({ pjtName:        projectname,
479                                        location:       prjtargroot,
480                                        buildArtifact:  "executable",
481                                        srcFiles:       linkfile,
482                                        cFlags:         " --mem_model:data=far",
483                                        targets:        [prjtarget]   
484                                    });
485       }
486       
487       /*****************************************************************************
488         Kernel C674x project
489        *****************************************************************************/
490       if(exclude674 == false)
491       {
492           prjtarget = "674"
493           prjtargroot = projectroot + "/c674/";
494           cmntargroot = commonroot  + "/c674/";
495           linkfile = new Array();
496           if (xdc.findFile(prjtargroot+"lnk.cmd")) 
497           {
498             linkfile.push(prjtargroot+"lnk.cmd");
499           }
500           else
501           {
502             linkfile.push(cmntargroot + "lnk.cmd");
503           }
504          findProjectFiles (projectroot,linkfile,dir,"674");
505           findProjectFiles (prjtargroot,linkfile,dir,"674");
506          
507          /* Add library files */
508           findLibFiles(prjtargroot, libc_c674, libcn_c674, dir);
509          
510          Package.ccsProjects.push({ pjtName:        projectname,
511                                       location:       prjtargroot,
512                                       buildArtifact:  "executable",
513                                       srcFiles:       linkfile,
514                                       cFlags:         " --mem_model:data=far",
515                                       targets:        [prjtarget]   
516                                   });
517                                   
518       }
519       
521       /*****************************************************************************
522         Kernel C64x+ project
523        *****************************************************************************/
524      if(exclude64p == false)
525        {
526           if(exclude64ple == true)
527             prjtarget="64Pbe";
528           else if(exclude64pbe == true)
529             prjtarget="64Ple";
530           else
531             prjtarget = "64P"
532           
533           prjtargroot = projectroot + "/c64P/";
534           cmntargroot = commonroot  + "/c64P/";
535           linkfile = new Array();
536           if (xdc.findFile(prjtargroot+"lnk.cmd")) 
537           {
538             linkfile.push(prjtargroot+"lnk.cmd");
539           }
540           else
541           {
542             linkfile.push(cmntargroot + "lnk.cmd");
543           }
544           findProjectFiles (projectroot,linkfile,dir,"64P");
545           findProjectFiles (prjtargroot,linkfile,dir,"64P");
546           
547           /* Add library files */
548           findLibFiles(prjtargroot, libc_c64p, libcn_c64p, dir);
549           Package.ccsProjects.push({ pjtName:        projectname,
550                                        location:       prjtargroot,
551                                        buildArtifact:  "executable",
552                                        srcFiles:       linkfile,
553                                        cFlags:         " --mem_model:data=far",
554                                        targets:        [prjtarget]   
555                                    });
556       }
557     }
558         /* create rules for creating library for optimized and the natural C code */
559    Package.files=new Array();
561    /* C66x DSPLIB Intrinsic Library */
562    Package.files["kernelc66"] =
563    {
564       files: libc_c66,
565       def_flags: " --mem_model:data=far",
566       target: ["ce66le","c66le","ce66be","c66be"]
567    };
569    /* C674x DSPLIB Intrinsic Library */
570    Package.files["kernelc674"] =
571    {
572       files: libc_c674,
573       def_flags: " --mem_model:data=far",
574       target: ["c674le","ce674le"]
575    };
577    /* C64x+ DSPLIB Intrinsic Library */
578    Package.files["kernelc64p"] =
579    {
580       files: libc_c64p,
581       def_flags: " --mem_model:data=far",
582       target: ["ce64Ple","c64Ple", "ce64Pbe","c64Pbe"]
583    };
585    /* Create DSPLIB library */
586    Package.createLib("dsplib");
587    
588    /* C66x DSPLIB Natural C Library */
589    Package.files["kernelc66"] =
590    {
591     files: libcn_c66,
592     def_flags: " --mem_model:data=far",
593         target: ["ce66le","c66le","ce66be","c66be"]
594    };
596    /* C674x DSPLIB Natural C Library */
597    Package.files["kernelc674"] =
598    {
599     files: libcn_c674,
600     def_flags: " --mem_model:data=far",
601         target: ["ce674le","c674le"]
602    };
604    /* C64x+ DSPLIB Natural C Library */
605    Package.files["kernelc64p"] =
606    {
607     files: libcn_c64p,
608     def_flags: " --mem_model:data=far",
609         target: ["ce64Ple","c64Ple", "ce64Pbe","c64Pbe"]
610    };
612    /* Rule to create Natural C library */
613    Package.createLib("dsplib_cn");
615     
616   }
618   /** Local function to add files for projects **/
619   function findProjectFiles(path,lnkfile,knl,target) {
620     var Files = new java.io.File(path);
621     for each (var srcFile in Files.list()) {
622       srcFile = String(srcFile);
623       var srcPath = path + srcFile;
624       var dot = srcFile.lastIndexOf(".");
625       var extension = srcFile.substr(dot,srcFile.length);    
626       if (extension == ".c") {
627         if(srcFile.substr(0,dot) == knl)
628        {
629            continue;      
630        }
631        var underscore=srcFile.lastIndexOf("_");
632        var fileType=srcFile.substr(underscore,dot-underscore);
633        if (fileType=="_cn" || fileType=="_i")
634        {
635            continue;
636        }
637             
638         if (xdc.findFile(srcPath)) {
639             lnkfile.push(srcPath);
640         }
641       }
642       /* Create Doxygen string */
643       if(extension == ".h")
644       {
645           if (extension == ".h" && srcFile.toString().match(knl+".h") && String(Package.targs[0]).match(target)) 
646           {
647              doxygenstring += " " + srcPath;
648           }
649           if (xdc.findFile(srcPath)) 
650          {
651            lnkfile.push(srcPath);
652          }
653       }
654     }
655   } 
657 /** Local function to add files for libraries **/
658   function findLibFiles(path,libc, libcn, knl) {
659     var Files = new java.io.File(path);
660     for each (var srcFile in Files.list()) {
661       srcFile = String(srcFile);
662       var srcPath = path + srcFile;
663       var dot = srcFile.lastIndexOf(".");
664       var extension = srcFile.substr(dot,srcFile.length-dot);
665           /* Add source C file to project */
666           if (extension == ".s")
667           {
668             libc.push(srcPath);
669             continue;
670           }
671           if (extension == ".sa")
672           {
673             libc.push(srcPath);
674             continue;
675           }
676           if (srcFile == (knl + ".c") )
677           {
678             libc.push(srcPath);
679             continue;
680           }
681       var underscore=srcFile.lastIndexOf("_");
682       var fileType=srcFile.substr(underscore,dot-underscore);
683           if (extension== ".c" && fileType=="_i")
684           {
685             libc.push(srcPath);
686             continue;
687           }
688           if (extension== ".c" && fileType=="_cn")
689           {
690             libcn.push(srcPath);
691             continue;
692           }
693     }
694   }  
695      
696 function createExe()
698    if (IncludeList == "") {
699       var file = new java.io.File("src");
700       IncludeList = file.list();
701     }
702     
703     for each (var dir in IncludeList) {
704       var special   = false; 
705       var exclude66   = false;
706      
708       /* Check if dir is in exclude list */
709       for each (var excludedir in ExcludeList) {
710         if (excludedir.name == dir){
711         
712            if(excludedir.srcDir.toString().match("c66le")) {
713              exclude66 = true;
714            }
715            else if(excludedir.srcDir.toString().match("c66")) {
716              exclude66 = true;
717            }
718          }
719       }
720       
721       /* Check if dir is in special list */
722       for each (var specialdir in SpecialList) {
723         if (specialdir.name == dir && specialdir.srcDir == srcDir) {
724           special = true;
725           break;
726         }
727       }
728       if (special == true) { cflags = specialdir.cflags; }
730        /*****************************************************************************
731         Local Variables 
732        *****************************************************************************/
733       var projectname = dir;
734       var projectroot = "./src/" + projectname + "/";
735       var prjtargroot;
736       var prjtarget; 
737       var linkfile;
739       if(exclude66 == false)
740       {
741           
742           prjtargetsrc = projectroot+"/c66/"
743           prjtargroot = projectroot + "/vc98/";
744           linkfile = new Array();
745           findVC98Files (projectroot,linkfile);
746           findVC98Files (prjtargetsrc,linkfile);
747           
748           Package.files["CSRC"]=
749           {
750              base_directory: ".",
751  
752              files: linkfile.concat([
753               "mex/c6xsim/C6xSimulator.c",
754               "mex/c6xsim/C66_ag_intrins.c",
755               "mex/c6xsim/C66_data_sim.c"]),
756               
757              def_flags: " -DTMS320C66X -D_TMS320C6600 -DLITTLE_ENDIAN_HOST -D_LITTLE_ENDIAN  -Imex/c6xsim",
759          } 
762         Package.exeTarget[0] = 
763        {
764      
765           base_directory: prjtargroot,
767           target:  "vc98",
769           name:  projectname,
770   
771        };  
773        Package.createExe();
775       }
777     }
779 }    
781  function findVC98Files(path,lnkfile) {
782     var Files = new java.io.File(path);
783     for each (var srcFile in Files.list()) {
784       srcFile = String(srcFile);
785       var srcPath = path + srcFile;
786       var dot = srcFile.lastIndexOf(".");
787       var extension = srcFile.substr(dot,srcFile.length);    
788       if (extension == ".c") {
789         if (xdc.findFile(srcPath)) {
790             lnkfile.push(srcPath);
791         }
792       }
793     }
794     return lnkfile;
795   }  
796   
797 function createknlhdr()
799      /* Create Kernel API header file */
800     var api = Package.bundlename+".h";
801     var fileModule = xdc.module('xdc.services.io.File');
802     try{
803         var apiHeader = fileModule.open(api, "w");
804      } catch (ex)
805      {
806       print( api + " cannot be written to. Please check Writing Permissions.");
807       java.lang.System.exit(1);
808      }
809   Package.generatedFiles.push(api);
810   Package.archiveFiles["CommonArchiveFiles"].files.push(api);
811    /* Header Information */
812   apiHeader.writeLine("/* ======================================================================= */");
813   apiHeader.writeLine("/* "+ api +" --  Interface header file                 */");
814   apiHeader.writeLine("/*                                                                         */");
815   apiHeader.writeLine("/* Rev 0.0.1                                                               */");
816   apiHeader.writeLine("/*                                                                         */");
817   apiHeader.writeLine("/* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/  */"); 
818   apiHeader.writeLine("/*                                                                         */");
819   apiHeader.writeLine("/*                                                                         */");
820   apiHeader.writeLine("/*  Redistribution and use in source and binary forms, with or without     */");
821   apiHeader.writeLine("/*  modification, are permitted provided that the following conditions     */");
822   apiHeader.writeLine("/*  are met:                                                               */");
823   apiHeader.writeLine("/*                                                                         */");
824   apiHeader.writeLine("/*    Redistributions of source code must retain the above copyright       */");
825   apiHeader.writeLine("/*    notice, this list of conditions and the following disclaimer.        */");
826   apiHeader.writeLine("/*                                                                         */");
827   apiHeader.writeLine("/*    Redistributions in binary form must reproduce the above copyright    */");
828   apiHeader.writeLine("/*    notice, this list of conditions and the following disclaimer in the  */");
829   apiHeader.writeLine("/*    documentation and/or other materials provided with the               */");
830   apiHeader.writeLine("/*    distribution.                                                        */");
831   apiHeader.writeLine("/*                                                                         */");
832   apiHeader.writeLine("/*    Neither the name of Texas Instruments Incorporated nor the names of  */");
833   apiHeader.writeLine("/*    its contributors may be used to endorse or promote products derived  */");
834   apiHeader.writeLine("/*    from this software without specific prior written permission.        */");
835   apiHeader.writeLine("/*                                                                         */");
836   apiHeader.writeLine("/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS    */");
837   apiHeader.writeLine("/*  \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT      */");
838   apiHeader.writeLine("/*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR  */");
839   apiHeader.writeLine("/*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT   */");
840   apiHeader.writeLine("/*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  */");
841   apiHeader.writeLine("/*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT       */");
842   apiHeader.writeLine("/*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  */");
843   apiHeader.writeLine("/*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  */");
844   apiHeader.writeLine("/*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT    */");
845   apiHeader.writeLine("/*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  */");
846   apiHeader.writeLine("/*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.   */");
847   apiHeader.writeLine("/*                                                                         */");
848   apiHeader.writeLine("/* ======================================================================= */");
850      var projectDir = new java.io.File("./package/projects");
851      var projectXml = projectDir.list();
853      for each(var xml in projectXml)
854      {
855        xml=String(xml);
856        var dot = xml.lastIndexOf(".");
857        var extension = xml.substr(dot,xml.length);
858        if(extension == ".xml")
859        {
860           var project=xdc.loadXML("./package/projects/"+xml);
861           var headerfile = project["params"].name+".h";
862           if(xdc.findFile("src/"+project["params"].name+"/"+headerfile))
863           {
864             apiHeader.writeLine("#include <"+Pkg.name.replace(/\./g,"/")+"/src/"+project["params"].name+"/"+headerfile+">");
865           }
866        }
867      }
869         
870  /* nothing past this point */