]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ivimm/ipumm.git/blob - build/common.bld
[H264D] Codec Update 02.00.18.01
[ivimm/ipumm.git] / build / common.bld
1 /*
2  * Copyright (c) 2011-2015, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  *  ======== common.bld ========
34  *
35  */
38 /*
39  *  ======== getCores ========
40  *  Determines which cores to build for.
41  *
42  *  Any argument in XDCARGS which does not contain core= is treated
43  *  as a core name. This way build for multiple cores can be specified by
44  *  separating them with a space.
45  */
46 function getCores(xdcArgs)
47 {
48     var coreNames = new Array();
50     /* Check for any XDCARGS with core=; these are the corenames */
51     for (var i = 0; i < xdcArgs.length; i++) {
52         if (xdcArgs[i].match(/core=/)) {
53             coreNames.push(xdcArgs[i].substr(5));
54         }
55     }
57     return coreNames;
58 }
61 /*
62  *  ======== getProfiles ========
63  *  Determines which profiles to build for.
64  *
65  *  Any argument in XDCARGS which does not contain platform= is treated
66  *  as a profile. This way multiple build profiles can be specified by
67  *  separating them with a space.
68  */
69 function getProfiles(xdcArgs)
70 {
71     var profiles = new Array();
73     /* Check for any XDCARGS with profile=; these are profiles. */
74     for (var i = 0; i < xdcArgs.length; i++) {
75         if (xdcArgs[i].match(/profile=/)) {
76             profiles.push(xdcArgs[i].substr(8));
77         }
78     }
80     return profiles;
81 }
83 function getBuildModes(xdcArgs)
84 {
85     var buildModes = new Array();
87     /* Check for any XDCARGS with buildMode=; these are specific
88        build configuration */
89     for (var i = 0; i < xdcArgs.length; i++) {
90         if (xdcArgs[i].match(/buildMode=/)) {
91             buildModes.push(xdcArgs[i].substr(10));
92         }
93     }
94     return buildModes;
95 }
98 /*
99  *  ======== getTraceType ========
100  *  Determines which trace type to build for.
101  *
102  *  Any argument in XDCARGS which does not contain trace_type= is treated
103  *  as a trace type name. This way build for different trace type can be specified by
104  *  separating them with a space.
105  * XDCARGS="profile=debug core=app_m3 target_build=BUILD_OMAP4 trace_type=UIA_SW_ON"
106  */
107 function getTraceType(xdcArgs)
109     var trace_type = new Array();
111     /* Check for any XDCARGS with trace_type=; these are the corenames */
112     for (var i = 0; i < xdcArgs.length; i++) {
113         if (xdcArgs[i].match(/trace_type=/)) {
114             trace_type.push(xdcArgs[i].substr(11));
115         }
116     }
118     return trace_type;
122 /*
123  *  ======== getLoadType ========
124  *  Determines whether ducati load is enabled or not .
125  *
126  *  XDCARGS="profile=debug core=app_m3 target_build=BUILD_OMAP4 load_type=LOAD_ON
127  */
128 function getLoadType(xdcArgs)
130     var load_type = new Array();
132     /* Check for any XDCARGS with load_type=; these are the corenames */
133     for (var i = 0; i < xdcArgs.length; i++) {
134         if (xdcArgs[i].match(/load_type=/)) {
135             load_type.push(xdcArgs[i].substr(10));
136         }
137     }
139     return load_type;
143 /*
144  *  ======== getTimerType ========
145  *  Determines which trace type to build for.
146  *
147  *  XDCARGS="profile=debug core=app_m3 target_build=BUILD_OMAP4 timer_type=CTM_ON
148  */
149 function getTimerType(xdcArgs)
151     var timer_type = new Array();
153     /* Check for any XDCARGS with timer_type=;  */
154     for (var i = 0; i < xdcArgs.length; i++) {
155         if (xdcArgs[i].match(/timer_type=/)) {
156             timer_type.push(xdcArgs[i].substr(11));
157         }
158     }
160     return timer_type;
164 /*
165  *  ======== getVidPerfMsmtMode ========
166  *  Determines whether ducati video performance measurement is turned ON.
167  *
168  *  XDCARGS="profile=debug core=app_m3 target_build=BUILD_OMAP4 video_perf_mode=MSMT_ON
169  */
170 function getVidPerfMsmtMode(xdcArgs)
172     var video_perf_mode = new Array();
174     /* Check for any XDCARGS with video_perf_mode=; these are the corenames */
175     for (var i = 0; i < xdcArgs.length; i++) {
176         if (xdcArgs[i].match(/video_perf_mode=/)) {
177             video_perf_mode.push(xdcArgs[i].substr(16));
178         }
179     }
181     return video_perf_mode;
186 /*
187  *  ======== getTraceMode ========
188  *  Determines which trace mode to use.
189  *
190  */
191 function getTraceMode(xdcArgs)
193     var trace = new Array();
195     /* Check for any XDCARGS with profile=; these are profiles. */
196     for (var i = 0; i < xdcArgs.length; i++) {
197         if (xdcArgs[i].match(/trace=/)) {
198             trace.push(xdcArgs[i].substr(6));
199         }
200     }
202     return trace;
205 /*
206  *  ======== getCacheMode ========
207  *  Determines which Cache mode to use.
208  *
209  */
210 function getCacheMode(xdcArgs)
212     var cache_wa = new Array();
214     /* Check for any XDCARGS with profile=; these are profiles. */
215     for (var i = 0; i < xdcArgs.length; i++) {
216         if (xdcArgs[i].match(/cache_wa=/)) {
217             cache_wa.push(xdcArgs[i].substr(9));
218         }
219     }
221     return cache_wa;
224 /*
225  *  ======== getSenPositions ========
226  *  Determines which Cache mode to use.
227  *
228  */
229 function getSenPositions(xdcArgs)
231     var SenPosition = new Array();
233     /* Check for any XDCARGS with profile=; these are profiles. */
234     for (var i = 0; i < xdcArgs.length; i++) {
235         if (xdcArgs[i].match(/SenPosition=/)) {
236             SenPosition.push(xdcArgs[i].substr(12));
237         }
238     }
240     return SenPosition;
243 // Possible options - none Virtio
244 // ISS_SIMULATOR
245 // VIRTIO
246 // ...
247 function getTargetEnvironment(xdcArgs)
249     var target_env = new Array();
251     /* Check for any XDCARGS with profile=; these are profiles. */
252     for (var i = 0; i < xdcArgs.length; i++) {
253         if (xdcArgs[i].match(/target_env=/)) {
254             target_env.push(xdcArgs[i].substr(11));
255         }
256     }
257     return target_env;
260 /*
261  *  ======== getTargetBuild ========
262  *  Determines which build to use.
263  *
264  */
265 function getTargetBuild(xdcArgs)
267     var build = "";
269     /* Check for any XDCARGS with target_build= */
270     for (var i = 0; i < xdcArgs.length; i++) {
271         if (xdcArgs[i].match(/target_build=/)) {
272             build = xdcArgs[i].substr(13);
273         }
274     }
276     return build;
279 /*
280  *  ======== getHwType ========
281  *  Determines which OMAP version to use.
282  *
283  */
284 function getHwType(xdcArgs)
286     var omap_version="OMAP4"; //Setting default values
288     /* Check for any XDCARGS with hw_type=; these are the corenames */
289     for (var i = 0; i < xdcArgs.length; i++) {
290         if (xdcArgs[i].match(/hw_type=/)) {
291             // [1] operation is used on the return value of split(), which
292             // is an array.
293             var omap_version = xdcArgs[i].split("=")[1];
294         }
295     }
297     return omap_version;
301 /*
302  *  ======== isSmpBios ========
303  *  Determines which type of BIOS is used - SMP or non-SMP.
304  *
305  */
306 function isSmpBios(xdcArgs)
308     var SMPmode = false; //Setting default value to non-SMP
309     var bios_type = "";
311     /* Check for any XDCARGS with BIOS_type=; this tells us if BIOS is SMP or not  */
312     for (var i = 0; i < xdcArgs.length; i++) {
313         if (xdcArgs[i].match(/BIOS_type=/)) {
314             // [1] operation is used on the return value of split(), which
315             // is an array.
316             var bios_type = xdcArgs[i].split("=")[1];
317         }
318     }
320     if (bios_type == "SMP")
321     {
322         SMPmode = true;
323     }
325     return SMPmode;
329 /*
330  *  ======== getGitTag ========
331  *  Determines TAG.
332  *
333  */
334 function getGitTag(xdcArgs)
336     var git_tag = "";
337     /* Check for any XDCARGS with git_tag= */
338     for (var i = 0; i < xdcArgs.length; i++) {
340         if (xdcArgs[i].match(/git_tag=/)) {
341            git_tag = xdcArgs[i].substr(8);
342            print("i " + i + "\n");
343         }
344     }
345     return git_tag;
348 /*
349  *  ======== getBoardConfig ========
350  *  Determines which board config to use.
351  *
352  */
353 function getBoardConfig(xdcArgs)
355     var board = "";
357     /* Check for any XDCARGS with board_config= */
358     for (var i = 0; i < xdcArgs.length; i++) {
359         if (xdcArgs[i].match(/board_config=/)) {
360             board = xdcArgs[i].substr(13);
361         }
362     }
364     if(board.length ==0)
365      board = 'BOARD_CONFIG_TI_BLAZE'
367     print("!!!!Configuring for board " + board);
369     return board;
372 /*
373  *  ======== getGitCommitID ========
374  *  Determines commit ID.
375  *
376  */
377 function getGitCommitID(xdcArgs)
379     var commit_id = "";
381     /* Check for any XDCARGS with git_commit_id= */
382     for (var i = 0; i < xdcArgs.length; i++) {
383         if (xdcArgs[i].match(/git_commit_id=/)) {
384             commit_id = xdcArgs[i].substr(14);
385         }
386     }
387     print ("commit_id::: " + commit_id +"\n");
388     return commit_id;
391 /*
392  *  ======== getGitBranch ========
393  *  Determines commit ID.
394  *
395  */
396 function getGitBranch(xdcArgs)
398     var branch = "";
399     /* Check for any XDCARGS with git_branch= */
400     for (var i = 0; i < xdcArgs.length; i++) {
401         if (xdcArgs[i].match(/git_branch=/)) {
402             branch = xdcArgs[i].substr(11);
403         }
404     }
405     return branch;
409 /*
410  *  ======== commonGetVersion ========
411  *  Common commonGetVersion function
412  */
413 function GetVersionTag()
415   var exitCode = 1;
416   var verFlags = "";
417   status = {};
418   var verInfo;
419   var git_cmd = "git ";
420   var ipc_ver = " IPC 3_40_01_08 ";
421   var ipumm_ver = " MMIP 3_00_09_01 ";
423   var type_cmd = "type ";
424   var flush_cmd = "echo ";
426   Program.global.ducati_ver_commit_id = "";
427   Program.global.ducati_ver_branch = "local";
428   ipumm_ver += ipc_ver;
429   Program.global.ducati_ver_tag = ipumm_ver;
430   Program.global.ducati_ver_h264d = "H264D-02.00.18.01";
431   Program.global.ducati_ver_mpeg4d = "MPEG4D-01.00.15.01";
432   Program.global.ducati_ver_mpeg2d = "MPEG2D-01.00.14.01";
433   Program.global.ducati_ver_vc1d = "VC1D-01.00.02.01";
434   Program.global.ducati_ver_mjpegd = "MJPEGD-01.00.13.01";
435   Program.global.ducati_ver_h264e = "H264E-02.00.09.01";
436   Program.global.ducati_ver_mpeg4e = "MPEG4E-01.00.02.01";
439   /*Check the target environment */
440   var host_env =environment["user.dir"];
441   if(host_env[1] == ':')
442   {
443     git_cmd = "git.exe "
444     echo_cmd = "c:/windows/system32/cmd /c echo "
445   }
447   //exitCode = xdc.exec(echo_cmd + "dummy write  " + " >> ducati_version.h", {},  status);
450   //branch
452   exitCode = xdc.exec(git_cmd + "branch -a", {},  status)
453   if (exitCode == -1)
454   {
455     print("Version Information not Generated \n");
456     return;
457   }
458   var lines = status.output.split('\n')
459   for (var i = 0; i < lines.length - 1; i++) {
460     var line = lines[i];
462     if(line.indexOf('*')!=-1){
463       var GitBranch = line.substr(2)
464       if (GitBranch.length) {
465             Program.global.ducati_ver_branch = GitBranch;
466             //exitCode = xdc.exec(echo_cmd + "#define GIT_BRANCH_VER  " + "\""+ GitBranch + "\"" + " > ducati_version.h", {},  status);
467             //verFlags += " -DGIT_BRANCH=\\\""+GitBranch+"\\\" "
469           }
470       }
471   }
473   //commit-id
474   exitCode = xdc.exec(git_cmd + "log --oneline", {},  status)
475   if (exitCode == -1) return verFlags;
476   var lines = status.output.split('\n')
477   var GitCommitId  = lines[0].substr(0,7)
478   if (GitCommitId.length)
479   {
480     Program.global.ducati_ver_commit_id = GitCommitId;
481      //exitCode = xdc.exec(echo_cmd + "#define GIT_COMMIT_ID_VER  " + "\""+ GitCommitId + "\""+ " >> ducati_version.h", {},  status);
484     //verFlags += " -DGIT_COMMIT_ID=\\\""+GitCommitId+"\\\" "
485     //print (verFlags)
486   }
488   //tag
489   exitcode = xdc.exec(git_cmd + "describe", {},  status)
490   if (exitCode == -1) return verFlags;
491   var lines = status.output.split('\n')
492   var tail_pos = lines.length
493   var GitTag = lines[0]
494   var MMIPtag = "MMIP " + GitTag + ipc_ver;
495   if (GitTag.length) {
497      //exitCode = xdc.exec(echo_cmd + "#define GIT_TAG_VER " + "\""+ GitTag + "\""+ " >> ducati_version.h", {},  status);
498     Program.global.ducati_ver_tag=MMIPtag;
499     //verFlags += " -DGIT_TAG=\\\""+GitTag+"\\\" "
500     print ("gittag" + GitTag + Program.global.ducati_ver_tag);
502   }
504   
505   //codec
506     var h264d="", mpeg4d="", vc1d="", mpeg2d="", mpeg4e="", h264e="";
507     var codecFlags="";
509   for (var i = 0; i < lines.length - 1; i++) {
510     var line = lines[i];
511     var tail_pos = line.length
512     var CodecVersion = line.substr(tail_pos -11, 11);
513     //print(line + "\n");
515     /* First Occurance only */
516     if(h264d.length==0){
517         if(line.indexOf('codec-library H264D')!=-1){
518              if (CodecVersion.length) {
519                  //print(CodecVersion );
520               h264d += "H264D-"+CodecVersion
521               //exitCode = xdc.exec(echo_cmd + "#define VER_H264D " + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {},  status);
522               Program.global.ducati_ver_h264d = h264d;
523            }
524            //codecFlags+= h264d
525            //print("\n  " + codecFlags);
526         }
527     }
529     if(mpeg4d.length==0){
530         if(line.indexOf('codec-library MPEG4D')!=-1){
531              if (CodecVersion.length) {
532               mpeg4d += "MPEG4D-"+CodecVersion
533                   //          exitCode = xdc.exec(echo_cmd + "#define VER_MPEG4D " + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {},  status);
534                   Program.global.ducati_ver_mpeg4d = mpeg4d;
535            }
536            //print("\n  " + mpeg4d);
537         }
538     }
540     if(mpeg2d.length==0){
541         if(line.indexOf('codec-library MPEG2D')!=-1){
542              if (CodecVersion.length) {
543               mpeg2d += "MPEG2D-"+CodecVersion
544               //print("MPEG2 Codec ver  \n" + CodecVersion + "line " + line + "line2" + lines[i+1]);
545               //exitCode = xdc.exec(echo_cmd + "#define VER_MPEG2D "  + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {},  status);
546               Program.global.ducati_ver_mpeg2d = mpeg2d;
547            }
548            //print("\n  " + mpeg2d);
549         }
550     }
553     if(vc1d.length==0){
554         if(line.indexOf('codec-library VC1D')!=-1){
555              if (CodecVersion.length) {
556               vc1d += "VC1D-"+CodecVersion
557               //exitCode = xdc.exec(echo_cmd + "#define VER_VC1D "  + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {},  status);
558               Program.global.ducati_ver_vc1d = vc1d;
559            }
560            //print("\n  " + vc1d);
561         }
562     }
565     if(h264e.length==0){
566         if(line.indexOf('codec-library H264E')!=-1){
567              if (CodecVersion.length) {
568               h264e += "H264E-"+CodecVersion
569              //exitCode = xdc.exec(echo_cmd + "#define VER_H264E "  + "\""+ CodecVersion+ "\"" + " >> ducati_version.h", {},  status);
570              Program.global.ducati_ver_h264e = h264e;
571            }
572            //print("\n  " + h264e);
573         }
574     }
577     if(mpeg4e.length==0){
578         if(line.indexOf('codec-library MPEG4E')!=-1){
579              if (CodecVersion.length) {
580               mpeg4e += "MPEG4E-"+CodecVersion
581               //exitCode = xdc.exec(echo_cmd + "#define VER_MPEG4E " + "\""+ CodecVersion+ "\"" + " >> ducati_version.h", {},  status);
582               Program.global.ducati_ver_mpeg4e= mpeg4e;
583            }
584            //print("\n  " + mpeg4e);
585         }
586     }
588   }
589   //codecFlags= h264d+mpeg4d+vc1d+mpeg2d+mpeg4e+h264e;
590   //print("\n Codec Flags" + codecFlags);
591   //if(codecFlags.length){
592     //exitCode = xdc.exec(echo_cmd + "CODEC FLAGS " + codecFlags + " >> ducati_version.h", {},  status);
593     //verFlags += " -DCODEC_LIB_VERSION=\\\""+codecFlags+"\\\" "
595   //}
598     //return verFlags;
602 /*
603  *  ======== getI2cAllowChan0========
604  *  Determines whether usage of i2c
605  *  channel 0 will be permitted
606  *
607  */
608 function getI2cAllowChan0(xdcArgs)
610     var chan0_allow = "";
612     /* Check for any XDCARGS with target_build= */
613     for (var i = 0; i < xdcArgs.length; i++) {
614         if (xdcArgs[i].match(/i2c_allow_chan0=/)) {
615             chan0_allow = xdcArgs[i].substr(16);
616         }
617     }
619     return chan0_allow;
622 /*
623  *  ======== getAllowOffloading ========
624  *  Determines if offloading support is enabled
625  *  in sysm3
626  *
627  */
628 function getAllowOffloading(xdcArgs)
630     var allow = "0";
632     /* Check for any XDCARGS with offloading_allow= */
633     for (var i = 0; i < xdcArgs.length; i++) {
634         if (xdcArgs[i].match(/offloading_allow=/)) {
635             allow = xdcArgs[i].substr(17);
636             if (allow.length == 0) {
637                 allow = "0";
638             }
639         }
640     }
642     return allow;
646 function buildOptions(xdcArgs, aCompileOpts, coreName)
648     var buildMode = new Array();
650     var buildMode = getBuildModes(xdcArgs);
652     var compileOpts = " -D_DM270  -D_DM290_IMX_MCFIX_ ";
654     if (aCompileOpts != null){
655         compileOpts += aCompileOpts;
656     }
658     /*Update compile opt if trace is uart*/
659     var traceMode = getTraceMode(xdcArgs);
660     if(traceMode.length != 0)
661     {
662         if(traceMode[0].match("UART"))
663         {
664             compileOpts += " -DUART_TRACES ";
665         }
666     }
668     /*Update compile opt if use cache or not */
669     var cacheMode = getCacheMode(xdcArgs);
670     if(cacheMode.length != 0)
671     {
672         if(cacheMode[0].match("NEWWA"))
673         {
674             compileOpts += " -DNEW_USE_CACHE ";
675             compileOpts += " -DUSE_CACHE ";
676         }
677         if(cacheMode[0].match("OLDWA"))
678         {
679             compileOpts += " -DOLD_USE_CACHE ";
680             compileOpts += " -DUSE_CACHE ";
681         }
682     }
684     /* update the build flag based on configurAtions */
685     for (var j = 0; j < buildMode.length; j++) {
687         if(buildMode[j].match("TESTCOMPONENTS")) {
688             compileOpts += " -DTESTCOMPONENTS=1 ";
689         }
691         if(buildMode[j].match("VIDEOCOMPONENTS")) {
692             compileOpts += " -DVIDEOCOMPONENTS=1 ";
693         }
695         if(buildMode[j].match("ISSCOMPONENTS")) {
696             compileOpts += " -DISSCOMPONENTS=1 ";
697         }
699         if(buildMode[j].match("DRIVERCOMPONENTS")) {
700             compileOpts += " -DDRIVERCOMPONENTS=1 ";
701         }
702     }
705     /*Update compile opt if use cache or not */
706     var SenPosition = getSenPositions(xdcArgs);
707     if(SenPosition.length != 0)
708     {
709         if(SenPosition[0].match("TABLET"))
710         {
711             compileOpts += " -DTABLET_SEN_POSITION ";
712         }
714         if(SenPosition[0].match("SDP"))
715         {
716             compileOpts += " -DSDP_SEN_POSITION ";
717         }
718         if(SenPosition[0].match("BLAZE"))
719         {
720             compileOpts += " -DBLAZE_SEN_POSITION ";
721         }
722     }
725     if (buildMode.length == 0) {
726         compileOpts += " -DDRIVERCOMPONENTS=1 -DISSCOMPONENTS=1 -DVIDEOCOMPONENTS=1 -DTESTCOMPONENTS=1 ";
727     }
729     if(coreName != null) {
730         if(coreName.match(/sys_m3/)){
731             compileOpts += " -DDUCATI_SYS_M3 ";
732         }
734         if(coreName.match(/app_m3/)){
735             compileOpts += " -DDUCATI_APP_M3 ";
736         }
737     }
739     var I2cAllowChan0 = getI2cAllowChan0(xdcArgs);
740     if(I2cAllowChan0.length != 0)
741     {
742         if(I2cAllowChan0[0].match("1"))
743         {
744             compileOpts += " -DI2C_ID0_WORKS_ON_APP_CORE_PATCH ";
745         }
746     }
748     var AllowOffloading = getAllowOffloading(xdcArgs);
749     if(AllowOffloading[0].match("1")) {
750         compileOpts += " -DOFFLOAD_SUPPORT ";
751     }
753     return compileOpts;
758 /*
759  *  ======== buildLibs ========
760  *  This function generates the makefile goals for the libraries taking
761  *  into account the profile variants, specific ducati cores and build modes
762  *
763  */
764 function buildLibs(objList, trgList, xdcArgs, libCompileOpts, coreName)
766     var compileOpts = buildOptions(xdcArgs, libCompileOpts, coreName);
767     var profiles = getProfiles(xdcArgs);
768     //print ("profile length" + profiles.length +"\t" + "profile0" +  profiles[0] +"\n");
769     /* If no profiles were assigned, build for  whole program debug */
770     if (profiles.length == 0) {
771         profiles[0] = "whole_program_debug";
772     }
774     for (var i = 0; i < Build.targets.length; i++) {
776         var targ = Build.targets[i];
778         for (var j = 0; j < profiles.length; j++) {
780             var profile         = profiles[j];
781             var profileOpts     = compileOpts;
783             if (profile.match(/release/)) {
784                 profileOpts += " -O3";
785             }
787             if (coreName == null) {
788                 var lib_name = 'lib/' + profile + '/' + Pkg.name ;
789             }
790             else {
791                 var lib_name = 'lib/' + coreName + '/' + profile + '/' + Pkg.name ;
792             }
794             var lib = Pkg.addLibrary(lib_name, targ, {profile: profile, copts: profileOpts});
796             lib.addObjects(objList);
797         }
798     }
801 /*
802  *  ======== buildLibsByName ========
803  *  This function generates the makefile goals for the libraries taking
804  *  into account the profile variants, specific ducati cores and build
805  *  modes. The output library name can be specified by user.
806  *
807  */
808 function buildLibsByName(objList, trgList, xdcArgs, libCompileOpts, coreName, name)
810     var compileOpts = buildOptions(xdcArgs, libCompileOpts, coreName);
811     var profiles = getProfiles(xdcArgs);
812     //print ("profile length" + profiles.length +"\t" + "profile0" +  profiles[0] +"\n");
813     /* If no profiles were assigned, build for  whole program debug */
814     if (profiles.length == 0) {
815         profiles[0] = "whole_program_debug";
816     }
818     for (var i = 0; i < Build.targets.length; i++) {
820         var targ = Build.targets[i];
822         for (var j = 0; j < profiles.length; j++) {
824             var profile         = profiles[j];
825             var profileOpts     = compileOpts;
827             if (profile.match(/release/)) {
828                 profileOpts += " -O3";
829             }
831             if (coreName == null) {
832                 var lib_name = 'lib/' + profile + '/' + name ;
833             }
834             else {
835                 var lib_name = 'lib/' + coreName + '/' + profile + '/' + name ;
836             }
838             var lib = Pkg.addLibrary(lib_name, targ, {profile: profile, copts: profileOpts});
840             lib.addObjects(objList);
841         }
842     }
845 /*
846  *  ======== supportsCore ========
847  *  Returns true if coreName is in the supported core list. If coreNameList
848  *  is null or empty, that's taken to mean all targets are supported.
849  */
850 function supportsCore(coreName, coreNameList)
852     if ((coreNameList == null) || (coreNameList.length == 0)) {
853         return true;
854     }
856     for (var j = 0; j < coreNameList.length; j++) {
857         if(coreName.match(coreNameList[j])){
858             return true;
859         }
860     }
862     return false;
865 /*
866  *  ======== commonGetLibs ========
867  *  Common getLibs function
868  */
870 function commonGetLibs(prog, bCoreFlag, pkg, dir)
872     var suffix;
874     /* find a compatible suffix */
875     if ("findSuffix" in prog.build.target) {
876         suffix = prog.build.target.findSuffix(pkg);
877     }
878     else {
879         suffix = prog.build.target.suffix;
880     }
882     var name = pkg.$name + ".a" + suffix;
883     var lib  = "";
885     if (bCoreFlag == true) {
886         lib = "lib/" + prog.global.coreName + "/" + pkg.profile + "/" + name;
887     }
888     else {
889         lib = "lib/" + "/" + pkg.profile + "/" + name;
890     }
892     if (java.io.File(dir + lib).exists()) {
893         return lib;
894     }
895     else {
896         print("Default lib not found: " + lib +"\nlooking for release lib");
897         if (bCoreFlag == true) {
898           lib = "lib/" + prog.global.coreName + "/" + "release/" + name;
899         }
900         else {
901           lib = "lib/" + "/" + "release/" + name;
902         }
903         if (java.io.File(dir + lib).exists()) {
904             return lib;
905         }
906     }
908     /* could not find any library, throw exception */
909     throw Error("Library not found: " + lib);