1 /*
2 * Copyright (c) 2013-2014, 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 */
33 /*
34 * ======== Build.xs ========
35 */
37 var BIOS = null;
38 var Build = null;
39 var Ipc = null;
41 var custom28xOpts = " -q -mo ";
42 var custom6xOpts = " -q -mi10 -mo -pdr -pden -pds=238 -pds=880 -pds1110 ";
43 var customARP32xOpts = " -q --gen_func_subsections ";
44 var customArmOpts = " -q -ms --opt_for_speed=2 ";
45 var customGnuArmM3Opts = " ";
46 var customGnuArmM4Opts = " ";
47 var customGnuArmM4FOpts = " ";
48 var customGnuArmA9Opts = " ";
49 var customGnuArmA8Opts = " ";
50 var customGnuArmA15Opts = " ";
52 var ccOptsList = {
53 "ti.targets.C28_large" : custom28xOpts,
54 "ti.targets.C28_float" : custom28xOpts,
55 "ti.targets.C64P" : custom6xOpts,
56 "ti.targets.elf.C64P" : custom6xOpts,
57 "ti.targets.C64P_big_endian" : custom6xOpts,
58 "ti.targets.elf.C64P_big_endian" : custom6xOpts,
59 "ti.targets.C674" : custom6xOpts,
60 "ti.targets.elf.C674" : custom6xOpts,
61 "ti.targets.elf.C67P" : custom6xOpts,
62 "ti.targets.elf.C64T" : custom6xOpts,
63 "ti.targets.elf.C66" : custom6xOpts,
64 "ti.targets.elf.C66_big_endian" : custom6xOpts,
65 "ti.targets.arp32.elf.ARP32" : customARP32xOpts,
66 "ti.targets.arp32.elf.ARP32_far" : customARP32xOpts,
67 "ti.targets.arm.elf.Arm9" : customArmOpts,
68 "ti.targets.arm.elf.A8F" : customArmOpts,
69 "ti.targets.arm.elf.A8Fnv" : customArmOpts,
70 "ti.targets.arm.elf.M3" : customArmOpts,
71 "ti.targets.arm.elf.M4" : customArmOpts,
72 "ti.targets.arm.elf.M4F" : customArmOpts,
73 "gnu.targets.arm.M3" : customGnuArmM3Opts,
74 "gnu.targets.arm.M4" : customGnuArmM4Opts,
75 "gnu.targets.arm.M4F" : customGnuArmM4FOpts,
76 "gnu.targets.arm.A8F" : customGnuArmA8Opts,
77 "gnu.targets.arm.A9F" : customGnuArmA9Opts,
78 "gnu.targets.arm.A15F" : customGnuArmA15Opts,
79 };
81 /*
82 * ======== module$meta$init ========
83 */
84 function module$meta$init()
85 {
86 /* Only process during "cfg" phase */
87 if (xdc.om.$name != "cfg") {
88 return;
89 }
91 Build = this;
93 /*
94 * Set default verbose level for custom build flow
95 * User can override this in their cfg file.
96 */
97 var SourceDir = xdc.module("xdc.cfg.SourceDir");
98 SourceDir.verbose = 2;
100 /* register onSet hooks */
101 var GetSet = xdc.module("xdc.services.getset.GetSet");
102 GetSet.onSet(this, "libType", _setLibType);
104 /* Construct default customCCOpts value.
105 * User can override this in their cfg file.
106 */
107 Build.customCCOpts = Build.getDefaultCustomCCOpts();
108 }
110 /*
111 * ======== module$use ========
112 */
113 function module$use()
114 {
115 BIOS = xdc.module("ti.sysbios.BIOS");
116 var profile;
118 /* inform ti.sdo.utils.Build *not* to contribute libraries */
119 // xdc.module("ti.sdo.utils.Build").doBuild = false;
121 /* if Build.libType is undefined, use BIOS.libType */
122 if (Build.libType == undefined) {
123 switch (BIOS.libType) {
124 case BIOS.LibType_Instrumented:
125 Build.libType = Build.LibType_Instrumented;
126 break;
127 case BIOS.LibType_NonInstrumented:
128 Build.libType = Build.LibType_NonInstrumented;
129 break;
130 case BIOS.LibType_Custom:
131 Build.libType = Build.LibType_Custom;
132 break;
133 case BIOS.LibType_Debug:
134 Build.libType = Build.LibType_Debug;
135 break;
136 }
137 }
139 /* Get the profile associated with the ti.sdo.ipc package. The
140 * profile may be specified per package with a line like this
141 * in your .cfg script:
142 *
143 * xdc.loadPackage('ti.sdo.ipc').profile = "release";
144 */
145 if (this.$package.profile != undefined) {
146 profile = this.$package.profile;
147 }
148 else {
149 profile = Program.build.profile;
150 }
152 /* gracefully handle non-supported whole_program profiles */
153 if (profile.match(/whole_program/) &&
154 (Build.libType != Build.LibType_Debug)) {
156 /* allow build to proceed */
157 Build.libType = Build.LibType_Debug;
158 /* but warning the user */
159 Build.$logWarning(
160 "The '" + profile + "' build profile will not be supported " +
161 "in future releases of IPC. Use 'release' or 'debug' profiles " +
162 "together with the 'Build.libType' configuration parameter to " +
163 "specify your preferred library. See the compatibility section " +
164 "of your IPC release notes for more information.",
165 "Profile Deprecation Warning", Build);
166 }
168 /* inform getLibs() about location of library */
169 switch (Build.libType) {
170 case Build.LibType_Instrumented:
171 this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
172 this.$private.outputDir = this.$package.packageBase + "lib/" +
173 (BIOS.smpEnabled ? "smpipc/instrumented/":"ipc/instrumented/");
174 break;
176 case Build.LibType_NonInstrumented:
177 this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
178 this.$private.outputDir = this.$package.packageBase + "lib/" +
179 (BIOS.smpEnabled ? "smpipc/nonInstrumented/" :
180 "ipc/nonInstrumented/");
181 break;
183 case Build.LibType_Debug:
184 case Build.LibType_Custom:
185 this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
186 var SourceDir = xdc.useModule("xdc.cfg.SourceDir");
187 /* if building a pre-built library */
188 if (BIOS.buildingAppLib == false) {
189 var appName = Program.name.substring(0,
190 Program.name.lastIndexOf('.'));
191 this.$private.libDir = this.$package.packageBase + Build.libDir;
192 if (!java.io.File(this.$private.libDir).exists()) {
193 java.io.File(this.$private.libDir).mkdir();
194 }
195 }
196 /*
197 * If building an application in CCS or package.bld world
198 * and libDir has been specified
199 */
200 if ((BIOS.buildingAppLib == true) && (Build.libDir !== null)) {
201 SourceDir.outputDir = Build.libDir;
202 var src = SourceDir.create("ipc");
203 src.libraryName = this.$private.libraryName.substring(1);
204 this.$private.outputDir = src.getGenSourceDir();
205 }
206 else {
207 var curPath = java.io.File(".").getCanonicalPath();
208 /* If package.bld world AND building an application OR
209 * pre-built lib... */
210 if (java.io.File(curPath).getName() != "configPkg") {
211 var appName = Program.name.substring(0,
212 Program.name.lastIndexOf('.'));
213 appName = appName + "_p" + Program.build.target.suffix +
214 ".src";
215 SourceDir.outputDir = "package/cfg/" + appName;
216 SourceDir.toBuildDir = ".";
217 var src = SourceDir.create("ipc");
218 src.libraryName = this.$private.libraryName.substring(1);
219 this.$private.outputDir = src.getGenSourceDir();
220 }
221 /* Here ONLY if building an application in CCS world */
222 else {
223 /* request output source directory for generated files */
224 var appName = Program.name.substring(0,
225 Program.name.lastIndexOf('.'));
226 appName = appName + "_" + Program.name.substr(
227 Program.name.lastIndexOf('.')+1);
228 SourceDir.toBuildDir = "..";
229 var src = SourceDir.create("ipc/");
230 src.libraryName = this.$private.libraryName.substring(1);
232 /* save this directory in our private state (to be
233 * read during generation, see Gen.xdt)
234 */
235 this.$private.outputDir = src.getGenSourceDir();
236 }
237 }
238 break;
239 }
240 }
242 /*
243 * ======== module$validate ========
244 * Some redundant tests are here to catch changes since
245 * module$static$init() and instance$static$init().
246 */
247 function module$validate()
248 {
249 var Defaults = xdc.module('xdc.runtime.Defaults');
250 var Diags = xdc.module("xdc.runtime.Diags");
251 var libType = getEnumString(Build.libType);
253 switch (Build.libType) {
254 case Build.LibType_Instrumented:
255 if (Build.assertsEnabled == false) {
256 Build.$logWarning(
257 "Build.assertsEnabled must be set to true when " +
258 "Build.libType == Build." + libType + ". " + "Set " +
259 "Build.libType = Build.LibType_Custom to build a " +
260 "custom library or update your configuration.",
261 Build, "assertsEnabled");
262 }
263 if (Build.logsEnabled == false) {
264 Build.$logWarning(
265 "Build.logsEnabled must be set to true when " +
266 "Build.libType == Build." + libType + ". " + "Set " +
267 "Build.libType = Build.LibType_Custom to build a " +
268 "custom library or update your configuration.",
269 Build, "logsEnabled");
270 }
271 break;
273 case Build.LibType_NonInstrumented:
274 if ((Build.assertsEnabled == true) &&
275 Build.$written("assertsEnabled")){
276 Build.$logWarning(
277 "Build.assertsEnabled must be set to false when " +
278 "Build.libType == Build." + libType + ". " + "Set " +
279 "Build.libType = Build.LibType_Custom to build a " +
280 "custom library or update your configuration.",
281 Build, "assertsEnabled");
282 }
283 if ((Build.logsEnabled == true) && Build.$written("logsEnabled")) {
284 Build.$logWarning(
285 "Build.logsEnabled must be set to false when " +
286 "Build.libType == Build." + libType + ". " + "Set " +
287 "Build.libType = Build.LibType_Custom to build a " +
288 "custom library or update your configuration.",
289 Build, "logsEnabled");
290 }
291 break;
293 case Build.LibType_Custom:
294 if ((Build.assertsEnabled == true)
295 && (Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
296 && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF)) {
297 Build.$logWarning(
298 "Build.assertsEnabled should be set to 'false' when " +
299 "Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF.",
300 Build, "assertsEnabled");
301 }
302 break;
303 }
304 }
306 /*
307 * ======== getCCOpts ========
308 */
309 function getCCOpts(target)
310 {
311 return(Build.customCCOpts);
312 }
314 /*
315 * ======== getEnumString ========
316 * Return the enum value as a string.
317 *
318 * Example usage:
319 * If obj contains an enumeration type property "Enum enumProp"
320 *
321 * view.enumString = getEnumString(obj.enumProp);
322 */
323 function getEnumString(enumProperty)
324 {
325 /* Split the string into tokens in order to get rid of the
326 * huge package path that precedes the enum string name.
327 * Return the last two tokens concatenated with "_".
328 */
329 var enumStrArray = String(enumProperty).split(".");
330 var len = enumStrArray.length;
331 return (enumStrArray[len - 1]);
332 }
334 /*
335 * Add pre-built Instrumented and Non-Intrumented release libs
336 */
337 var ipcSources = "ipc/GateMP.c " +
338 "ipc/ListMP.c " +
339 "ipc/SharedRegion.c " +
340 "ipc/MessageQ.c " +
341 "ipc/Notify.c ";
343 var gatesSources = "ipc/gates/GatePeterson.c " +
344 "ipc/gates/GatePetersonN.c " +
345 "ipc/gates/GateMPSupportNull.c ";
347 var heapsSources = "ipc/heaps/HeapBufMP.c " +
348 "ipc/heaps/HeapMemMP.c " +
349 "ipc/heaps/HeapMultiBufMP.c ";
351 var notifyDriverSources =
352 "ipc/notifyDrivers/NotifyDriverCirc.c " +
353 "ipc/notifyDrivers/NotifySetupNull.c " +
354 "ipc/notifyDrivers/NotifyDriverShm.c ";
356 var nsremoteSources =
357 "ipc/nsremote/NameServerRemoteNotify.c " +
358 "ipc/nsremote/NameServerMessageQ.c ";
360 var transportsSources =
361 "ipc/transports/TransportShm.c " +
362 "ipc/transports/TransportShmCircSetup.c " +
363 "ipc/transports/TransportShmNotifySetup.c " +
364 "ipc/transports/TransportShmCirc.c " +
365 "ipc/transports/TransportShmNotify.c " +
366 "ipc/transports/TransportShmSetup.c " +
367 "ipc/transports/TransportNullSetup.c " ;
369 var utilsSources = "utils/MultiProc.c " +
370 "utils/List.c " +
371 "utils/NameServerRemoteNull.c " +
372 "utils/NameServer.c ";
374 var commonSources = ipcSources +
375 gatesSources +
376 heapsSources +
377 notifyDriverSources +
378 nsremoteSources +
379 transportsSources;
380 // utilsSources;
382 var C64PSources =
383 "ipc/gates/GateAAMonitor.c " +
384 "ipc/gates/GateHWSpinlock.c " +
385 "ipc/gates/GateHWSem.c " +
386 "ipc/family/dm6446/NotifySetup.c " +
387 "ipc/family/dm6446/NotifyCircSetup.c " +
388 "ipc/family/dm6446/InterruptDsp.c " +
389 "ipc/family/omap3530/NotifySetup.c " +
390 "ipc/family/omap3530/NotifyCircSetup.c " +
391 "ipc/family/omap3530/InterruptDsp.c ";
393 var C66Sources = "ipc/gates/GateHWSem.c " +
394 "ipc/gates/GateHWSpinlock.c " +
395 "ipc/family/tci663x/Interrupt.c " +
396 "ipc/family/tci663x/MultiProcSetup.c " +
397 "ipc/family/tci663x/NotifyCircSetup.c " +
398 "ipc/family/tci663x/NotifySetup.c " +
399 "ipc/family/vayu/InterruptDsp.c " +
400 "ipc/family/vayu/NotifySetup.c ";
402 var C674Sources =
403 "ipc/gates/GateHWSpinlock.c " +
404 "ipc/family/da830/NotifySetup.c " +
405 "ipc/family/da830/NotifyCircSetup.c " +
406 "ipc/family/da830/InterruptDsp.c " +
407 "ipc/family/arctic/NotifySetup.c " +
408 "ipc/family/arctic/NotifyCircSetup.c " +
409 "ipc/family/arctic/InterruptDsp.c " +
410 "ipc/family/ti81xx/NotifySetup.c " +
411 "ipc/family/ti81xx/NotifyCircSetup.c " +
412 "ipc/family/ti81xx/InterruptDsp.c " +
413 "ipc/family/ti81xx/NotifyMbxSetup.c " +
414 "ipc/family/ti81xx/NotifyDriverMbx.c " +
415 "ipc/family/c6a8149/NotifySetup.c " +
416 "ipc/family/c6a8149/NotifyCircSetup.c " +
417 "ipc/family/c6a8149/InterruptDsp.c " +
418 "ipc/family/c6a8149/NotifyMbxSetup.c " +
419 "ipc/family/c6a8149/NotifyDriverMbx.c ";
422 var C647xSources = "ipc/family/c647x/Interrupt.c " +
423 "ipc/family/c647x/NotifyCircSetup.c " +
424 "ipc/family/c647x/MultiProcSetup.c " +
425 "ipc/family/c647x/NotifySetup.c ";
427 var C64TSources =
428 "ipc/gates/GateHWSpinlock.c " +
429 "ipc/family/omap4430/NotifyCircSetup.c " +
430 "ipc/family/omap4430/NotifySetup.c " +
431 "ipc/family/omap4430/InterruptDsp.c ";
433 var C28Sources = "ipc/family/f28m35x/NotifyDriverCirc.c " +
434 "ipc/family/f28m35x/IpcMgr.c " +
435 "ipc/family/f28m35x/TransportCirc.c " +
436 "ipc/family/f28m35x/NameServerBlock.c ";
438 var M3Sources =
439 "ipc/gates/GateHWSpinlock.c " +
440 "ipc/family/omap4430/NotifySetup.c " +
441 "ipc/family/omap4430/NotifyCircSetup.c " +
442 "ipc/family/omap4430/InterruptDucati.c " +
443 "ipc/family/ti81xx/NotifySetup.c " +
444 "ipc/family/ti81xx/NotifyCircSetup.c " +
445 "ipc/family/ti81xx/InterruptDucati.c " +
446 "ipc/family/ti81xx/NotifyMbxSetup.c " +
447 "ipc/family/ti81xx/NotifyDriverMbx.c " +
448 "ipc/family/c6a8149/NotifySetup.c " +
449 "ipc/family/c6a8149/NotifyCircSetup.c " +
450 "ipc/family/c6a8149/InterruptDucati.c " +
451 "ipc/family/c6a8149/NotifyMbxSetup.c " +
452 "ipc/family/c6a8149/NotifyDriverMbx.c " +
453 "ipc/family/f28m35x/IpcMgr.c " +
454 "ipc/family/f28m35x/NotifyDriverCirc.c " +
455 "ipc/family/f28m35x/TransportCirc.c " +
456 "ipc/family/f28m35x/NameServerBlock.c " +
457 "ipc/family/vayu/InterruptIpu.c " +
458 "ipc/family/vayu/NotifySetup.c ";
460 var M4Sources =
461 "ipc/gates/GateHWSpinlock.c " +
462 "ipc/family/vayu/InterruptIpu.c " +
463 "ipc/family/vayu/NotifySetup.c ";
465 var Arm9Sources = "ipc/family/dm6446/NotifySetup.c " +
466 "ipc/family/dm6446/NotifyCircSetup.c " +
467 "ipc/family/dm6446/InterruptArm.c " +
468 "ipc/family/da830/NotifySetup.c " +
469 "ipc/family/da830/NotifyCircSetup.c " +
470 "ipc/family/da830/InterruptArm.c ";
472 var A8FSources =
473 "ipc/gates/GateHWSpinlock.c " +
474 "ipc/family/ti81xx/NotifySetup.c " +
475 "ipc/family/ti81xx/NotifyCircSetup.c " +
476 "ipc/family/ti81xx/InterruptHost.c " +
477 "ipc/family/ti81xx/NotifyMbxSetup.c " +
478 "ipc/family/ti81xx/NotifyDriverMbx.c " +
479 "ipc/family/c6a8149/NotifySetup.c " +
480 "ipc/family/c6a8149/NotifyCircSetup.c " +
481 "ipc/family/c6a8149/InterruptHost.c " +
482 "ipc/family/c6a8149/NotifyMbxSetup.c " +
483 "ipc/family/c6a8149/NotifyDriverMbx.c " +
484 "ipc/family/omap3530/NotifySetup.c " +
485 "ipc/family/omap3530/NotifyCircSetup.c " +
486 "ipc/family/omap3530/InterruptHost.c ";
488 var A8gSources =
489 "ipc/gates/GateHWSpinlock.c " +
490 "ipc/family/ti81xx/NotifySetup.c " +
491 "ipc/family/ti81xx/NotifyCircSetup.c " +
492 "ipc/family/ti81xx/InterruptHost.c " +
493 "ipc/family/ti81xx/NotifyMbxSetup.c " +
494 "ipc/family/ti81xx/NotifyDriverMbx.c " +
495 "ipc/family/c6a8149/NotifySetup.c " +
496 "ipc/family/c6a8149/NotifyCircSetup.c " +
497 "ipc/family/c6a8149/InterruptHost.c " +
498 "ipc/family/c6a8149/NotifyMbxSetup.c " +
499 "ipc/family/c6a8149/NotifyDriverMbx.c " +
500 "ipc/family/omap3530/NotifySetup.c " +
501 "ipc/family/omap3530/NotifyCircSetup.c " +
502 "ipc/family/omap3530/InterruptHost.c ";
505 var A15gSources = "ipc/family/vayu/InterruptHost.c " +
506 "ipc/family/vayu/NotifySetup.c " +
507 "ipc/gates/GateHWSpinlock.c ";
509 var ARP32Sources =
510 "ipc/gates/GateHWSpinlock.c " +
511 "ipc/family/arctic/NotifySetup.c " +
512 "ipc/family/arctic/NotifyCircSetup.c " +
513 "ipc/family/arctic/InterruptArp32.c " +
514 "ipc/family/c6a8149/NotifySetup.c " +
515 "ipc/family/c6a8149/NotifyCircSetup.c " +
516 "ipc/family/c6a8149/InterruptEve.c " +
517 "ipc/family/vayu/InterruptArp32.c " +
518 "ipc/family/vayu/NotifySetup.c ";
520 var cList = {
521 "ti.targets.C28_large" : commonSources + C28Sources,
522 "ti.targets.C28_float" : commonSources + C28Sources,
524 "ti.targets.C64P" : commonSources + C647xSources +
525 C64PSources,
526 "ti.targets.C64P_big_endian" : commonSources + C647xSources +
527 C64PSources,
528 "ti.targets.C674" : commonSources + C674Sources,
530 "ti.targets.elf.C64P" : commonSources + C647xSources +
531 C64PSources,
532 "ti.targets.elf.C64P_big_endian" : commonSources + C647xSources +
533 C64PSources,
534 "ti.targets.elf.C674" : commonSources + C674Sources,
535 "ti.targets.elf.C64T" : commonSources + C64TSources,
536 "ti.targets.elf.C66" : commonSources + C647xSources +
537 C66Sources,
538 "ti.targets.elf.C66_big_endian" : commonSources + C647xSources +
539 C66Sources,
541 "ti.targets.arp32.elf.ARP32" : commonSources + ARP32Sources,
542 "ti.targets.arp32.elf.ARP32_far" : commonSources + ARP32Sources,
544 "ti.targets.arm.elf.Arm9" : commonSources + Arm9Sources,
545 "ti.targets.arm.elf.A8F" : commonSources + A8FSources,
546 "ti.targets.arm.elf.A8Fnv" : commonSources + A8FSources,
547 "ti.targets.arm.elf.M3" : commonSources + M3Sources,
548 "ti.targets.arm.elf.M4" : commonSources + M4Sources,
549 "ti.targets.arm.elf.M4F" : commonSources + M4Sources,
551 "gnu.targets.arm.A15F" : commonSources + A15gSources,
552 "gnu.targets.arm.A8F" : commonSources + A8gSources,
553 "gnu.targets.arm.M3" : commonSources + M3Sources,
554 "gnu.targets.arm.M4" : commonSources + M4Sources,
555 "gnu.targets.arm.M4F" : commonSources + M4Sources,
556 };
558 var cFiles = { };
560 var ipcPackages = [
561 "ti.sdo.ipc",
562 "ti.sdo.ipc.family.omap4430",
563 "ti.sdo.ipc.family.omap3530",
564 "ti.sdo.ipc.family.da830",
565 "ti.sdo.ipc.family.dm6446",
566 "ti.sdo.ipc.family.ti81xx",
567 "ti.sdo.ipc.family.arctic",
568 "ti.sdo.ipc.family.f28m35x",
569 "ti.sdo.ipc.family.c647x",
570 "ti.sdo.ipc.family.c6a8149",
571 "ti.sdo.ipc.family.tci663x",
572 "ti.sdo.ipc.family.vayu",
573 "ti.sdo.ipc.gates",
574 "ti.sdo.ipc.heaps",
575 "ti.sdo.ipc.notifyDrivers",
576 "ti.sdo.ipc.nsremote",
577 "ti.sdo.ipc.transports",
578 "ti.sdo.utils",
579 ];
581 var asmListNone = [
582 ];
584 var asmList64P = [
585 "ipc/gates/GateAAMonitor_asm.s64P",
586 ];
588 var asmList = {
589 "ti.targets.C28_large" : asmListNone,
590 "ti.targets.C28_float" : asmListNone,
592 "ti.targets.C64P" : asmList64P,
593 "ti.targets.C64P_big_endian" : asmList64P,
594 "ti.targets.C674" : asmList64P,
596 "ti.targets.elf.C64P" : asmList64P,
597 "ti.targets.elf.C64P_big_endian" : asmList64P,
598 "ti.targets.elf.C674" : asmList64P,
600 "ti.targets.elf.C64T" : asmListNone,
601 "ti.targets.elf.C66" : asmListNone,
602 "ti.targets.elf.C66_big_endian" : asmListNone,
604 "ti.targets.arp32.elf.ARP32" : asmListNone,
605 "ti.targets.arp32.elf.ARP32_far" : asmListNone,
607 "ti.targets.arm.elf.Arm9" : asmListNone,
608 "ti.targets.arm.elf.A8F" : asmListNone,
609 "ti.targets.arm.elf.A8Fnv" : asmListNone,
610 "ti.targets.arm.elf.M3" : asmListNone,
611 "ti.targets.arm.elf.M4" : asmListNone,
612 "ti.targets.arm.elf.M4F" : asmListNone,
614 "gnu.targets.arm.M3" : asmListNone,
615 "gnu.targets.arm.M4" : asmListNone,
616 "gnu.targets.arm.M4F" : asmListNone,
617 "gnu.targets.arm.A8F" : asmListNone,
618 "gnu.targets.arm.A9F" : asmListNone,
619 "gnu.targets.arm.A15F" : asmListNone,
620 };
622 function getDefaultCustomCCOpts()
623 {
625 /* start with target.cc.opts */
626 var customCCOpts = Program.build.target.cc.opts;
628 /* add target unique custom ccOpts */
629 if (!(ccOptsList[Program.build.target.$name] === undefined)) {
630 customCCOpts += ccOptsList[Program.build.target.$name];
631 }
633 /* gnu targets need to pick up ccOpts.prefix and suffix */
634 if (Program.build.target.$name.match(/gnu/)) {
635 customCCOpts += " -O3 ";
636 customCCOpts += " " + Program.build.target.ccOpts.prefix + " ";
637 customCCOpts += " " + Program.build.target.ccOpts.suffix + " ";
638 }
639 else if (Program.build.target.$name.match(/iar/)) {
640 throw new Error("IAR not supported by IPC");
641 }
642 else {
643 /* ti targets do program level compile */
644 customCCOpts += " --program_level_compile -o3 -g " +
645 "--optimize_with_debug ";
646 }
648 /* undo optimizations if this is a debug build */
649 if (Build.libType == Build.LibType_Debug) {
650 if (Program.build.target.$name.match(/gnu/)) {
651 customCCOpts = customCCOpts.replace("-O3","");
652 /* add in stack frames for stack back trace */
653 customCCOpts += " -mapcs ";
654 }
655 else {
656 customCCOpts = customCCOpts.replace(" -o3","");
657 customCCOpts = customCCOpts.replace(" --optimize_with_debug","");
658 if (Program.build.target.$name.match(/arm/)) {
659 customCCOpts = customCCOpts.replace(" --opt_for_speed=2","");
660 }
661 }
662 }
664 return (customCCOpts);
665 }
667 /*
668 * ======== getDefs ========
669 */
670 function getDefs()
671 {
672 var Defaults = xdc.module('xdc.runtime.Defaults');
673 var Diags = xdc.module("xdc.runtime.Diags");
674 var BIOS = xdc.module("ti.sysbios.BIOS");
675 var MessageQ = xdc.module("ti.sdo.ipc.MessageQ");
677 var defs = "";
679 if ((Build.assertsEnabled == false) ||
680 ((Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
681 && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF))) {
682 defs += " -Dxdc_runtime_Assert_DISABLE_ALL";
683 }
685 if (Build.logsEnabled == false) {
686 defs += " -Dxdc_runtime_Log_DISABLE_ALL";
687 }
689 defs += " -Dti_sdo_ipc_MessageQ_traceFlag__D=" +
690 (MessageQ.traceFlag ? "TRUE" : "FALSE");
692 var InterruptDucati =
693 xdc.module("ti.sdo.ipc.family.ti81xx.InterruptDucati");
695 /* If we truely know which platform we're building against,
696 * add these application specific -D's
697 */
698 if (BIOS.buildingAppLib == true) {
699 defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_videoProcId__D="
700 + InterruptDucati.videoProcId;
701 defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_hostProcId__D="
702 + InterruptDucati.hostProcId;
703 defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_vpssProcId__D="
704 + InterruptDucati.vpssProcId;
705 defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_dspProcId__D="
706 + InterruptDucati.dspProcId;
707 defs +=
708 " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_ducatiCtrlBaseAddr__D="
709 + InterruptDucati.ducatiCtrlBaseAddr;
710 defs +=
711 " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_mailboxBaseAddr__D="
712 + InterruptDucati.mailboxBaseAddr;
713 }
715 return (defs);
716 }
718 /*
719 * ======== getCFiles ========
720 */
721 function getCFiles(target)
722 {
723 var localSources = "ipc/Ipc.c ";
725 /*
726 * logic to trim the C files down to just what the application needs
727 * 3/2/11 disabled for now ...
728 */
729 if (BIOS.buildingAppLib == true) {
730 for each (var mod in Program.targetModules()) {
731 var mn = mod.$name;
732 var pn = mn.substring(0, mn.lastIndexOf("."));
734 /* sanity check package path */
735 var packageMatch = false;
737 for (var i = 0; i < ipcPackages.length; i++) {
738 if (pn == ipcPackages[i]) {
739 packageMatch = true;
740 break;
741 }
742 }
744 if (packageMatch && !mn.match(/Proxy/) &&
745 (mn != "ti.sdo.ipc.Ipc")) {
746 if (cFiles[mn] === undefined) {
747 var prefix = mn.substr(mn.indexOf("sdo")+4);
748 var mod = mn.substr(mn.lastIndexOf(".")+1);
749 prefix = prefix.substring(0, prefix.lastIndexOf('.')+1);
750 prefix = prefix.replace(/\./g, "/");
751 localSources += prefix + mod + ".c ";
752 }
753 else {
754 for (i in cFiles[mn].cSources) {
755 var prefix = mn.substr(mn.indexOf("sdo")+8);
756 prefix = prefix.substring(0, prefix.lastIndexOf('.')+1);
757 prefix = prefix.replace(/\./g, "/");
758 localSources += prefix + cFiles[mn].cSources[i] + " ";
759 }
760 }
761 }
762 }
763 }
764 else {
765 localSources += cList[target];
766 }
768 /* remove trailing " " */
769 localSources = localSources.substring(0, localSources.length-1);
771 return (localSources);
772 }
774 /*
775 * ======== getAsmFiles ========
776 */
777 function getAsmFiles(target)
778 {
779 return (asmList[target]);
780 }
782 /*
783 * ======== getLibs ========
784 * This function called by all IPC packages except ti.sdo.ipc package.
785 */
786 function getLibs(pkg)
787 {
788 var libPath = "";
789 var name = "";
790 var suffix;
792 switch (Build.libType) {
793 case Build.LibType_Custom:
794 case Build.LibType_Instrumented:
795 case Build.LibType_NonInstrumented:
796 case Build.LibType_Debug:
797 return null;
799 case Build.LibType_PkgLib:
800 throw new Error("internal error: Build.getLibs() called with " +
801 "incorret context (libType == PkgLib)");
802 break;
804 default:
805 throw new Error("Build.libType not supported: " + Build.libType);
806 break;
807 }
808 }
810 /*
811 * ======== getProfiles ========
812 * Determines which profiles to build for.
813 *
814 * Any argument in XDCARGS which does not contain platform= is treated
815 * as a profile. This way multiple build profiles can be specified by
816 * separating them with a space.
817 */
818 function getProfiles(xdcArgs)
819 {
820 /*
821 * cmdlProf[1] gets matched to "whole_program,debug" if
822 * ["abc", "profile=whole_program,debug"] is passed in as xdcArgs
823 */
824 var cmdlProf = (" " + xdcArgs.join(" ") + " ").match(/ profile=([^ ]+) /);
826 if (cmdlProf == null) {
827 /* No profile=XYZ found */
828 return [];
829 }
831 /* Split "whole_program,debug" into ["whole_program", "debug"] */
832 var profiles = cmdlProf[1].split(',');
834 return profiles;
835 }
837 /*
838 * ======== buildLibs ========
839 * This function generates the makefile goals for the libraries
840 * produced by a package.
841 */
842 function buildLibs(objList, relList, filter, xdcArgs)
843 {
844 var Build = xdc.useModule('xdc.bld.BuildEnvironment');
846 for (var i = 0; i < Build.targets.length; i++) {
847 var targ = Build.targets[i];
849 /* skip target if not supported */
850 if (!supportsTarget(targ, filter)) {
851 continue;
852 }
854 var profiles = getProfiles(xdcArgs);
856 /* If no profiles were assigned, use only the default one. */
857 if (profiles.length == 0) {
858 profiles[0] = "debug";
859 }
861 for (var j = 0; j < profiles.length; j++) {
862 var ccopts = "";
863 var asmopts = "";
865 if (profiles[j] == "smp") {
866 var libPath = "lib/smpipc/debug/";
867 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
868 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
869 }
870 else {
871 var libPath = "lib/ipc/debug/";
872 /* build all package libs using Hwi macros */
873 ccopts += " -Dti_sysbios_Build_useHwiMacros";
874 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
875 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
876 }
878 /* confirm that this target supports this profile */
879 if (targ.profiles[profiles[j]] !== undefined) {
880 var profile = profiles[j];
881 var lib = Pkg.addLibrary(libPath + Pkg.name,
882 targ, {
883 profile: profile,
884 copts: ccopts,
885 aopts: asmopts,
886 releases: relList
887 });
888 lib.addObjects(objList);
889 }
890 }
891 }
892 }
894 /*
895 * ======== supportsTarget ========
896 * Returns true if target is in the filter object. If filter
897 * is null or empty, that's taken to mean all targets are supported.
898 */
899 function supportsTarget(target, filter)
900 {
901 var list, field;
903 if (filter == null) {
904 return true;
905 }
907 /*
908 * For backwards compatibility, we support filter as an array of
909 * target names. The preferred approach is to specify filter as
910 * an object with 'field' and 'list' elements.
911 *
912 * Old form:
913 * var trgFilter = [ "Arm9", "Arm9t", "Arm9t_big_endian" ]
914 *
915 * New (preferred) form:
916 *
917 * var trgFilter = {
918 * field: "isa",
919 * list: [ "v5T", "v7R" ]
920 * };
921 *
922 */
923 if (filter instanceof Array) {
924 list = filter;
925 field = "name";
926 }
927 else {
928 list = filter.list;
929 field = filter.field;
930 }
932 if (list == null || field == null) {
933 throw("invalid filter parameter, must specify list and field!");
934 }
936 if (field == "noIsa") {
937 if (String(','+list.toString()+',').match(','+target["isa"]+',')) {
938 return (false);
939 }
940 return (true);
941 }
943 /*
944 * add ',' at front and and tail of list and field strings to allow
945 * use of simple match API. For example, the string is updated to:
946 * ',v5T,v7R,' to allow match of ',v5t,'.
947 */
948 if (String(','+list.toString()+',').match(','+target[field]+',')) {
949 return (true);
950 }
952 return (false);
953 }
955 /*
956 * ======== _setLibType ========
957 * The "real-time" setter setLibType function
958 * This function is called whenever libType changes.
959 */
960 function _setLibType(field, val)
961 {
962 var Build = this;
964 if (val == Build.LibType_Instrumented) {
965 Build.assertsEnabled = true;
966 Build.logsEnabled = true;
967 }
968 else if (val == Build.LibType_NonInstrumented) {
969 Build.assertsEnabled = false;
970 Build.logsEnabled = false;
971 }
972 else if (val == Build.LibType_Custom) {
973 Build.assertsEnabled = true;
974 Build.logsEnabled = true;
975 }
976 else if (val == Build.LibType_Debug) {
977 Build.assertsEnabled = true;
978 Build.logsEnabled = true;
979 }
980 else if (val == Build.LibType_PkgLib) {
981 Build.assertsEnabled = true;
982 Build.logsEnabled = true;
983 }
984 else {
985 print(Build.$name + ": unknown libType setting: " + val);
986 }
988 /* re-construct default Build.customCCOpts */
989 Build.customCCOpts = Build.getDefaultCustomCCOpts();
990 }