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)
108 {
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;
119 }
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)
129 {
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;
140 }
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)
150 {
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;
161 }
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)
171 {
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;
182 }
186 /*
187 * ======== getTraceMode ========
188 * Determines which trace mode to use.
189 *
190 */
191 function getTraceMode(xdcArgs)
192 {
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;
203 }
205 /*
206 * ======== getCacheMode ========
207 * Determines which Cache mode to use.
208 *
209 */
210 function getCacheMode(xdcArgs)
211 {
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;
222 }
224 /*
225 * ======== getSenPositions ========
226 * Determines which Cache mode to use.
227 *
228 */
229 function getSenPositions(xdcArgs)
230 {
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;
241 }
243 // Possible options - none Virtio
244 // ISS_SIMULATOR
245 // VIRTIO
246 // ...
247 function getTargetEnvironment(xdcArgs)
248 {
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;
258 }
260 /*
261 * ======== getTargetBuild ========
262 * Determines which build to use.
263 *
264 */
265 function getTargetBuild(xdcArgs)
266 {
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;
277 }
279 /*
280 * ======== getHwType ========
281 * Determines which OMAP version to use.
282 *
283 */
284 function getHwType(xdcArgs)
285 {
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;
298 }
301 /*
302 * ======== isSmpBios ========
303 * Determines which type of BIOS is used - SMP or non-SMP.
304 *
305 */
306 function isSmpBios(xdcArgs)
307 {
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;
326 }
329 /*
330 * ======== getGitTag ========
331 * Determines TAG.
332 *
333 */
334 function getGitTag(xdcArgs)
335 {
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;
346 }
348 /*
349 * ======== getBoardConfig ========
350 * Determines which board config to use.
351 *
352 */
353 function getBoardConfig(xdcArgs)
354 {
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;
370 }
372 /*
373 * ======== getGitCommitID ========
374 * Determines commit ID.
375 *
376 */
377 function getGitCommitID(xdcArgs)
378 {
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;
389 }
391 /*
392 * ======== getGitBranch ========
393 * Determines commit ID.
394 *
395 */
396 function getGitBranch(xdcArgs)
397 {
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;
406 }
409 /*
410 * ======== commonGetVersion ========
411 * Common commonGetVersion function
412 */
413 function GetVersionTag()
414 {
415 var exitCode = 1;
416 var verFlags = "";
417 status = {};
418 var verInfo;
419 var git_cmd = "git ";
420 var ipc_ver = " IPC 3_50_01_00 ";
421 var ipumm_ver = " MMIP 3_00_15_00 ";
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.22.01";
431 Program.global.ducati_ver_mpeg4d = "MPEG4D-01.00.17.01";
432 Program.global.ducati_ver_mpeg2d = "MPEG2D-01.00.18.01";
433 Program.global.ducati_ver_vc1d = "VC1D-01.00.02.08";
434 Program.global.ducati_ver_mjpegd = "MJPEGD-01.00.16.01";
435 Program.global.ducati_ver_mjpege = "MJPEGE-01.00.17.01";
436 Program.global.ducati_ver_h264e = "H264E-02.00.09.01";
437 Program.global.ducati_ver_mpeg4e = "MPEG4E-01.00.02.01";
440 /*Check the target environment */
441 var host_env =environment["user.dir"];
442 if(host_env[1] == ':')
443 {
444 git_cmd = "git.exe "
445 echo_cmd = "c:/windows/system32/cmd /c echo "
446 }
448 //exitCode = xdc.exec(echo_cmd + "dummy write " + " >> ducati_version.h", {}, status);
451 //branch
453 exitCode = xdc.exec(git_cmd + "branch -a", {}, status)
454 if (exitCode == -1)
455 {
456 print("Version Information not Generated \n");
457 return;
458 }
459 var lines = status.output.split('\n')
460 for (var i = 0; i < lines.length - 1; i++) {
461 var line = lines[i];
463 if(line.indexOf('*')!=-1){
464 var GitBranch = line.substr(2)
465 if (GitBranch.length) {
466 Program.global.ducati_ver_branch = GitBranch;
467 //exitCode = xdc.exec(echo_cmd + "#define GIT_BRANCH_VER " + "\""+ GitBranch + "\"" + " > ducati_version.h", {}, status);
468 //verFlags += " -DGIT_BRANCH=\\\""+GitBranch+"\\\" "
470 }
471 }
472 }
474 //commit-id
475 exitCode = xdc.exec(git_cmd + "log --oneline", {}, status)
476 if (exitCode == -1) return verFlags;
477 var lines = status.output.split('\n')
478 var GitCommitId = lines[0].substr(0,7)
479 if (GitCommitId.length)
480 {
481 Program.global.ducati_ver_commit_id = GitCommitId;
482 //exitCode = xdc.exec(echo_cmd + "#define GIT_COMMIT_ID_VER " + "\""+ GitCommitId + "\""+ " >> ducati_version.h", {}, status);
485 //verFlags += " -DGIT_COMMIT_ID=\\\""+GitCommitId+"\\\" "
486 //print (verFlags)
487 }
489 //tag
490 exitcode = xdc.exec(git_cmd + "describe", {}, status)
491 if (exitCode == -1) return verFlags;
492 var lines = status.output.split('\n')
493 var tail_pos = lines.length
494 var GitTag = lines[0]
495 var MMIPtag = "IPUMM commit " + GitCommitId + " version" + ipumm_ver;
497 Program.global.ducati_ver_tag=MMIPtag;
498 print (Program.global.ducati_ver_tag);
500 //codec
501 var h264d="", mpeg4d="", vc1d="", mpeg2d="", mpeg4e="", h264e="", mjpege="";
502 var codecFlags="";
504 for (var i = 0; i < lines.length - 1; i++) {
505 var line = lines[i];
506 var tail_pos = line.length
507 var CodecVersion = line.substr(tail_pos -11, 11);
508 //print(line + "\n");
510 /* First Occurance only */
511 if(h264d.length==0){
512 if(line.indexOf('codec-library H264D')!=-1){
513 if (CodecVersion.length) {
514 //print(CodecVersion );
515 h264d += "H264D-"+CodecVersion
516 //exitCode = xdc.exec(echo_cmd + "#define VER_H264D " + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {}, status);
517 Program.global.ducati_ver_h264d = h264d;
518 }
519 //codecFlags+= h264d
520 //print("\n " + codecFlags);
521 }
522 }
524 if(mpeg4d.length==0){
525 if(line.indexOf('codec-library MPEG4D')!=-1){
526 if (CodecVersion.length) {
527 mpeg4d += "MPEG4D-"+CodecVersion
528 // exitCode = xdc.exec(echo_cmd + "#define VER_MPEG4D " + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {}, status);
529 Program.global.ducati_ver_mpeg4d = mpeg4d;
530 }
531 //print("\n " + mpeg4d);
532 }
533 }
535 if(mpeg2d.length==0){
536 if(line.indexOf('codec-library MPEG2D')!=-1){
537 if (CodecVersion.length) {
538 mpeg2d += "MPEG2D-"+CodecVersion
539 //print("MPEG2 Codec ver \n" + CodecVersion + "line " + line + "line2" + lines[i+1]);
540 //exitCode = xdc.exec(echo_cmd + "#define VER_MPEG2D " + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {}, status);
541 Program.global.ducati_ver_mpeg2d = mpeg2d;
542 }
543 //print("\n " + mpeg2d);
544 }
545 }
548 if(vc1d.length==0){
549 if(line.indexOf('codec-library VC1D')!=-1){
550 if (CodecVersion.length) {
551 vc1d += "VC1D-"+CodecVersion
552 //exitCode = xdc.exec(echo_cmd + "#define VER_VC1D " + "\""+ CodecVersion + "\""+ " >> ducati_version.h", {}, status);
553 Program.global.ducati_ver_vc1d = vc1d;
554 }
555 //print("\n " + vc1d);
556 }
557 }
560 if(h264e.length==0){
561 if(line.indexOf('codec-library H264E')!=-1){
562 if (CodecVersion.length) {
563 h264e += "H264E-"+CodecVersion
564 //exitCode = xdc.exec(echo_cmd + "#define VER_H264E " + "\""+ CodecVersion+ "\"" + " >> ducati_version.h", {}, status);
565 Program.global.ducati_ver_h264e = h264e;
566 }
567 //print("\n " + h264e);
568 }
569 }
572 if(mpeg4e.length==0){
573 if(line.indexOf('codec-library MPEG4E')!=-1){
574 if (CodecVersion.length) {
575 mpeg4e += "MPEG4E-"+CodecVersion
576 //exitCode = xdc.exec(echo_cmd + "#define VER_MPEG4E " + "\""+ CodecVersion+ "\"" + " >> ducati_version.h", {}, status);
577 Program.global.ducati_ver_mpeg4e= mpeg4e;
578 }
579 //print("\n " + mpeg4e);
580 }
581 }
583 if(mjpege.length==0){
584 if(line.indexOf('codec-library MJPEGE')!=-1){
585 if (CodecVersion.length) {
586 mjpege += "MJPEGE-"+CodecVersion
587 //exitCode = xdc.exec(echo_cmd + "#define VER_MJPEGE " + "\""+ CodecVersion+ "\"" + " >> ducati_version.h", {}, status);
588 Program.global.ducati_ver_mjpege= mjpege;
589 }
590 //print("\n " + mjpege);
591 }
592 }
594 }
595 //codecFlags= h264d+mpeg4d+vc1d+mpeg2d+mpeg4e+h264e+mjpege;
596 //print("\n Codec Flags" + codecFlags);
597 //if(codecFlags.length){
598 //exitCode = xdc.exec(echo_cmd + "CODEC FLAGS " + codecFlags + " >> ducati_version.h", {}, status);
599 //verFlags += " -DCODEC_LIB_VERSION=\\\""+codecFlags+"\\\" "
601 //}
604 //return verFlags;
605 }
608 /*
609 * ======== getI2cAllowChan0========
610 * Determines whether usage of i2c
611 * channel 0 will be permitted
612 *
613 */
614 function getI2cAllowChan0(xdcArgs)
615 {
616 var chan0_allow = "";
618 /* Check for any XDCARGS with target_build= */
619 for (var i = 0; i < xdcArgs.length; i++) {
620 if (xdcArgs[i].match(/i2c_allow_chan0=/)) {
621 chan0_allow = xdcArgs[i].substr(16);
622 }
623 }
625 return chan0_allow;
626 }
628 /*
629 * ======== getAllowOffloading ========
630 * Determines if offloading support is enabled
631 * in sysm3
632 *
633 */
634 function getAllowOffloading(xdcArgs)
635 {
636 var allow = "0";
638 /* Check for any XDCARGS with offloading_allow= */
639 for (var i = 0; i < xdcArgs.length; i++) {
640 if (xdcArgs[i].match(/offloading_allow=/)) {
641 allow = xdcArgs[i].substr(17);
642 if (allow.length == 0) {
643 allow = "0";
644 }
645 }
646 }
648 return allow;
649 }
652 function buildOptions(xdcArgs, aCompileOpts, coreName)
653 {
654 var buildMode = new Array();
656 var buildMode = getBuildModes(xdcArgs);
658 var compileOpts = " -D_DM270 -D_DM290_IMX_MCFIX_ ";
660 if (aCompileOpts != null){
661 compileOpts += aCompileOpts;
662 }
664 /*Update compile opt if trace is uart*/
665 var traceMode = getTraceMode(xdcArgs);
666 if(traceMode.length != 0)
667 {
668 if(traceMode[0].match("UART"))
669 {
670 compileOpts += " -DUART_TRACES ";
671 }
672 }
674 /*Update compile opt if use cache or not */
675 var cacheMode = getCacheMode(xdcArgs);
676 if(cacheMode.length != 0)
677 {
678 if(cacheMode[0].match("NEWWA"))
679 {
680 compileOpts += " -DNEW_USE_CACHE ";
681 compileOpts += " -DUSE_CACHE ";
682 }
683 if(cacheMode[0].match("OLDWA"))
684 {
685 compileOpts += " -DOLD_USE_CACHE ";
686 compileOpts += " -DUSE_CACHE ";
687 }
688 }
690 /* update the build flag based on configurAtions */
691 for (var j = 0; j < buildMode.length; j++) {
693 if(buildMode[j].match("TESTCOMPONENTS")) {
694 compileOpts += " -DTESTCOMPONENTS=1 ";
695 }
697 if(buildMode[j].match("VIDEOCOMPONENTS")) {
698 compileOpts += " -DVIDEOCOMPONENTS=1 ";
699 }
701 if(buildMode[j].match("ISSCOMPONENTS")) {
702 compileOpts += " -DISSCOMPONENTS=1 ";
703 }
705 if(buildMode[j].match("DRIVERCOMPONENTS")) {
706 compileOpts += " -DDRIVERCOMPONENTS=1 ";
707 }
708 }
711 /*Update compile opt if use cache or not */
712 var SenPosition = getSenPositions(xdcArgs);
713 if(SenPosition.length != 0)
714 {
715 if(SenPosition[0].match("TABLET"))
716 {
717 compileOpts += " -DTABLET_SEN_POSITION ";
718 }
720 if(SenPosition[0].match("SDP"))
721 {
722 compileOpts += " -DSDP_SEN_POSITION ";
723 }
724 if(SenPosition[0].match("BLAZE"))
725 {
726 compileOpts += " -DBLAZE_SEN_POSITION ";
727 }
728 }
731 if (buildMode.length == 0) {
732 compileOpts += " -DDRIVERCOMPONENTS=1 -DISSCOMPONENTS=1 -DVIDEOCOMPONENTS=1 -DTESTCOMPONENTS=1 ";
733 }
735 if(coreName != null) {
736 if(coreName.match(/sys_m3/)){
737 compileOpts += " -DDUCATI_SYS_M3 ";
738 }
740 if(coreName.match(/app_m3/)){
741 compileOpts += " -DDUCATI_APP_M3 ";
742 }
743 }
745 var I2cAllowChan0 = getI2cAllowChan0(xdcArgs);
746 if(I2cAllowChan0.length != 0)
747 {
748 if(I2cAllowChan0[0].match("1"))
749 {
750 compileOpts += " -DI2C_ID0_WORKS_ON_APP_CORE_PATCH ";
751 }
752 }
754 var AllowOffloading = getAllowOffloading(xdcArgs);
755 if(AllowOffloading[0].match("1")) {
756 compileOpts += " -DOFFLOAD_SUPPORT ";
757 }
759 return compileOpts;
760 }
764 /*
765 * ======== buildLibs ========
766 * This function generates the makefile goals for the libraries taking
767 * into account the profile variants, specific ducati cores and build modes
768 *
769 */
770 function buildLibs(objList, trgList, xdcArgs, libCompileOpts, coreName)
771 {
772 var compileOpts = buildOptions(xdcArgs, libCompileOpts, coreName);
773 var profiles = getProfiles(xdcArgs);
774 //print ("profile length" + profiles.length +"\t" + "profile0" + profiles[0] +"\n");
775 /* If no profiles were assigned, build for whole program debug */
776 if (profiles.length == 0) {
777 profiles[0] = "whole_program_debug";
778 }
780 for (var i = 0; i < Build.targets.length; i++) {
782 var targ = Build.targets[i];
784 for (var j = 0; j < profiles.length; j++) {
786 var profile = profiles[j];
787 var profileOpts = compileOpts;
789 if (profile.match(/release/)) {
790 profileOpts += " -O3";
791 }
793 if (coreName == null) {
794 var lib_name = 'lib/' + profile + '/' + Pkg.name ;
795 }
796 else {
797 var lib_name = 'lib/' + coreName + '/' + profile + '/' + Pkg.name ;
798 }
800 var lib = Pkg.addLibrary(lib_name, targ, {profile: profile, copts: profileOpts});
802 lib.addObjects(objList);
803 }
804 }
805 }
807 /*
808 * ======== buildLibsByName ========
809 * This function generates the makefile goals for the libraries taking
810 * into account the profile variants, specific ducati cores and build
811 * modes. The output library name can be specified by user.
812 *
813 */
814 function buildLibsByName(objList, trgList, xdcArgs, libCompileOpts, coreName, name)
815 {
816 var compileOpts = buildOptions(xdcArgs, libCompileOpts, coreName);
817 var profiles = getProfiles(xdcArgs);
818 //print ("profile length" + profiles.length +"\t" + "profile0" + profiles[0] +"\n");
819 /* If no profiles were assigned, build for whole program debug */
820 if (profiles.length == 0) {
821 profiles[0] = "whole_program_debug";
822 }
824 for (var i = 0; i < Build.targets.length; i++) {
826 var targ = Build.targets[i];
828 for (var j = 0; j < profiles.length; j++) {
830 var profile = profiles[j];
831 var profileOpts = compileOpts;
833 if (profile.match(/release/)) {
834 profileOpts += " -O3";
835 }
837 if (coreName == null) {
838 var lib_name = 'lib/' + profile + '/' + name ;
839 }
840 else {
841 var lib_name = 'lib/' + coreName + '/' + profile + '/' + name ;
842 }
844 var lib = Pkg.addLibrary(lib_name, targ, {profile: profile, copts: profileOpts});
846 lib.addObjects(objList);
847 }
848 }
849 }
851 /*
852 * ======== supportsCore ========
853 * Returns true if coreName is in the supported core list. If coreNameList
854 * is null or empty, that's taken to mean all targets are supported.
855 */
856 function supportsCore(coreName, coreNameList)
857 {
858 if ((coreNameList == null) || (coreNameList.length == 0)) {
859 return true;
860 }
862 for (var j = 0; j < coreNameList.length; j++) {
863 if(coreName.match(coreNameList[j])){
864 return true;
865 }
866 }
868 return false;
869 }
871 /*
872 * ======== commonGetLibs ========
873 * Common getLibs function
874 */
876 function commonGetLibs(prog, bCoreFlag, pkg, dir)
877 {
878 var suffix;
880 /* find a compatible suffix */
881 if ("findSuffix" in prog.build.target) {
882 suffix = prog.build.target.findSuffix(pkg);
883 }
884 else {
885 suffix = prog.build.target.suffix;
886 }
888 var name = pkg.$name + ".a" + suffix;
889 var lib = "";
891 if (bCoreFlag == true) {
892 lib = "lib/" + prog.global.coreName + "/" + pkg.profile + "/" + name;
893 }
894 else {
895 lib = "lib/" + "/" + pkg.profile + "/" + name;
896 }
898 if (java.io.File(dir + lib).exists()) {
899 return lib;
900 }
901 else {
902 print("Default lib not found: " + lib +"\nlooking for release lib");
903 if (bCoreFlag == true) {
904 lib = "lib/" + prog.global.coreName + "/" + "release/" + name;
905 }
906 else {
907 lib = "lib/" + "/" + "release/" + name;
908 }
909 if (java.io.File(dir + lib).exists()) {
910 return lib;
911 }
912 }
914 /* could not find any library, throw exception */
915 throw Error("Library not found: " + lib);
916 }