Rename: git mv src packages to complete application of ipc-j patches to ipcdev.
[ipc/ipcdev.git] / packages / ti / sdo / ipc / Build.xs
1 /*
2  * Copyright (c) 2013, 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;
40 /*
41  *  ======== module$use ========
42  */
43 function module$use()
44 {
45     BIOS = xdc.module("ti.sysbios.BIOS");
46     Build = this;
48     /* inform getLibs() about location of library */
49     switch (BIOS.libType) {
50         case BIOS.LibType_Instrumented:
51             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
52             this.$private.outputDir = this.$package.packageBase + "lib/"
53                         + (BIOS.smpEnabled ? "smpipc/instrumented/" : "ipc/instrumented/");
54             break;
56         case BIOS.LibType_NonInstrumented:
57             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
58             this.$private.outputDir = this.$package.packageBase + "lib/"
59                         + (BIOS.smpEnabled ? "smpipc/nonInstrumented/" : "ipc/nonInstrumented/");
60             break;
62         case BIOS.LibType_Custom:
63             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
64             var SourceDir = xdc.useModule("xdc.cfg.SourceDir");
65             /* if building a pre-built library */
66             if (BIOS.buildingAppLib == false) {
67                 var appName = Program.name.substring(0, Program.name.lastIndexOf('.'));
68                 this.$private.libDir = this.$package.packageBase + Build.libDir;
69                 if (!java.io.File(this.$private.libDir).exists()) {
70                     java.io.File(this.$private.libDir).mkdir();
71                 }
72             }
73             /*
74              * If building an application in CCS or package.bld world
75              * and libDir has been specified
76              */
77             if ((BIOS.buildingAppLib == true) && (Build.libDir !== null)) {
78                 SourceDir.outputDir = Build.libDir;
79                 var src = SourceDir.create("ipc");
80                 src.libraryName = this.$private.libraryName.substring(1);
81                 this.$private.outputDir = src.getGenSourceDir();
82             }
83             else {
84                 var curPath = java.io.File(".").getCanonicalPath();
85                 /* If package.bld world AND building an application OR pre-built lib */
86                 if (java.io.File(curPath).getName() != "configPkg") {
87                     var appName = Program.name.substring(0, Program.name.lastIndexOf('.'));
88                     appName = appName + "_p" + Program.build.target.suffix + ".src";
89                     SourceDir.outputDir = "package/cfg/" + appName;
90                     SourceDir.toBuildDir = ".";
91                     var src = SourceDir.create("ipc");
92                     src.libraryName = this.$private.libraryName.substring(1);
93                     this.$private.outputDir = src.getGenSourceDir();
94                 }
95                 /* Here ONLY if building an application in CCS world */
96                 else {
97                     /* request output source directory for generated files */
98                     var appName = Program.name.substring(0, Program.name.lastIndexOf('.'));
99                     appName = appName + "_" + Program.name.substr(Program.name.lastIndexOf('.')+1);
100                     SourceDir.toBuildDir = "..";
101                     var src = SourceDir.create("ipc/");
102                     src.libraryName = this.$private.libraryName.substring(1);
104                     /* save this directory in our private state (to be read during
105                     * generation, see Gen.xdt)
106                     */
107                     this.$private.outputDir = src.getGenSourceDir();
108                 }
109             }
110             break;
111     }
114 /*
115  * Add pre-built Instrumented and Non-Intrumented release libs
116  */
118 var ipcSources  =  "ipc/GateMP.c " +
119                    "ipc/ListMP.c " +
120                    "ipc/SharedRegion.c " +
121                    "ipc/MessageQ.c " +
122                    "ipc/Notify.c ";
124 var gatesSources = "ipc/gates/GatePeterson.c " +
125                    "ipc/gates/GatePetersonN.c " +
126                    "ipc/gates/GateMPSupportNull.c ";
128 var heapsSources = "ipc/heaps/HeapBufMP.c " +
129                    "ipc/heaps/HeapMemMP.c " +
130                    "ipc/heaps/HeapMultiBufMP.c ";
132 var notifyDriverSources =
133                    "ipc/notifyDrivers/NotifyDriverCirc.c " +
134                    "ipc/notifyDrivers/NotifySetupNull.c " +
135                    "ipc/notifyDrivers/NotifyDriverShm.c ";
137 var nsremoteSources =
138                    "ipc/nsremote/NameServerRemoteNotify.c " +
139                    "ipc/nsremote/NameServerMessageQ.c ";
141 var transportsSources =
142                    "ipc/transports/TransportShm.c " +
143                    "ipc/transports/TransportShmCircSetup.c " +
144                    "ipc/transports/TransportShmNotifySetup.c " +
145                    "ipc/transports/TransportShmCirc.c " +
146                    "ipc/transports/TransportShmNotify.c " +
147                    "ipc/transports/TransportShmSetup.c " +
148                    "ipc/transports/TransportNullSetup.c " ;
150 var utilsSources = "utils/MultiProc.c " +
151                    "utils/List.c " +
152                    "utils/NameServerRemoteNull.c " +
153                    "utils/NameServer.c ";
155 var commonSources = ipcSources +
156                     gatesSources +
157                     heapsSources +
158                     notifyDriverSources +
159                     nsremoteSources +
160                     transportsSources +
161                     utilsSources;
163 var C64PSources  =
164                    "ipc/gates/GateAAMonitor.c " +
165                    "ipc/gates/GateHWSpinlock.c " +
166                    "ipc/gates/GateHWSem.c " +
167                    "ipc/family/dm6446/NotifySetup.c " +
168                    "ipc/family/dm6446/NotifyCircSetup.c " +
169                    "ipc/family/dm6446/InterruptDsp.c " +
170                    "ipc/family/omap3530/NotifySetup.c " +
171                    "ipc/family/omap3530/NotifyCircSetup.c " +
172                    "ipc/family/omap3530/InterruptDsp.c ";
174 var C66Sources   = "ipc/gates/GateHWSem.c " +
175                    "ipc/gates/GateHWSpinlock.c " +
176                    "ipc/family/tci663x/Interrupt.c " +
177                    "ipc/family/tci663x/MultiProcSetup.c " +
178                    "ipc/family/tci663x/NotifyCircSetup.c " +
179                    "ipc/family/tci663x/NotifySetup.c " +
180                    "ipc/family/vayu/InterruptDsp.c " +
181                    "ipc/family/vayu/NotifySetup.c ";
183 var C674Sources  =
184                    "ipc/gates/GateHWSpinlock.c " +
185                    "ipc/family/da830/NotifySetup.c " +
186                    "ipc/family/da830/NotifyCircSetup.c " +
187                    "ipc/family/da830/InterruptDsp.c " +
188                    "ipc/family/arctic/NotifySetup.c " +
189                    "ipc/family/arctic/NotifyCircSetup.c " +
190                    "ipc/family/arctic/InterruptDsp.c " +
191                    "ipc/family/ti81xx/NotifySetup.c " +
192                    "ipc/family/ti81xx/NotifyCircSetup.c " +
193                    "ipc/family/ti81xx/InterruptDsp.c " +
194                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
195                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
196                    "ipc/family/c6a8149/NotifySetup.c " +
197                    "ipc/family/c6a8149/NotifyCircSetup.c " +
198                    "ipc/family/c6a8149/InterruptDsp.c " +
199                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
200                    "ipc/family/c6a8149/NotifyDriverMbx.c ";
203 var C647xSources = "ipc/family/c647x/Interrupt.c " +
204                    "ipc/family/c647x/NotifyCircSetup.c " +
205                    "ipc/family/c647x/MultiProcSetup.c " +
206                    "ipc/family/c647x/NotifySetup.c ";
208 var C64TSources  =
209                    "ipc/gates/GateHWSpinlock.c " +
210                    "ipc/family/omap4430/NotifyCircSetup.c " +
211                    "ipc/family/omap4430/NotifySetup.c " +
212                    "ipc/family/omap4430/InterruptDsp.c ";
214 var C28Sources   = "ipc/family/f28m35x/NotifyDriverCirc.c " +
215                    "ipc/family/f28m35x/IpcMgr.c " +
216                    "ipc/family/f28m35x/TransportCirc.c " +
217                    "ipc/family/f28m35x/NameServerBlock.c ";
219 var M3Sources    =
220                    "ipc/gates/GateHWSpinlock.c " +
221                    "ipc/family/omap4430/NotifySetup.c " +
222                    "ipc/family/omap4430/NotifyCircSetup.c " +
223                    "ipc/family/omap4430/InterruptDucati.c " +
224                    "ipc/family/ti81xx/NotifySetup.c " +
225                    "ipc/family/ti81xx/NotifyCircSetup.c " +
226                    "ipc/family/ti81xx/InterruptDucati.c " +
227                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
228                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
229                    "ipc/family/c6a8149/NotifySetup.c " +
230                    "ipc/family/c6a8149/NotifyCircSetup.c " +
231                    "ipc/family/c6a8149/InterruptDucati.c " +
232                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
233                    "ipc/family/c6a8149/NotifyDriverMbx.c " +
234                    "ipc/family/f28m35x/IpcMgr.c " +
235                    "ipc/family/f28m35x/NotifyDriverCirc.c " +
236                    "ipc/family/f28m35x/TransportCirc.c " +
237                    "ipc/family/f28m35x/NameServerBlock.c " +
238                    "ipc/family/vayu/InterruptIpu.c " +
239                    "ipc/family/vayu/NotifySetup.c ";
241 var M4Sources    =
242                    "ipc/gates/GateHWSpinlock.c " +
243                    "ipc/family/vayu/InterruptIpu.c " +
244                    "ipc/family/vayu/NotifySetup.c ";
246 var Arm9Sources  = "ipc/family/dm6446/NotifySetup.c " +
247                    "ipc/family/dm6446/NotifyCircSetup.c " +
248                    "ipc/family/dm6446/InterruptArm.c " +
249                    "ipc/family/da830/NotifySetup.c " +
250                    "ipc/family/da830/NotifyCircSetup.c " +
251                    "ipc/family/da830/InterruptArm.c ";
253 var A8FSources   =
254                    "ipc/gates/GateHWSpinlock.c " +
255                    "ipc/family/ti81xx/NotifySetup.c " +
256                    "ipc/family/ti81xx/NotifyCircSetup.c " +
257                    "ipc/family/ti81xx/InterruptHost.c " +
258                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
259                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
260                    "ipc/family/c6a8149/NotifySetup.c " +
261                    "ipc/family/c6a8149/NotifyCircSetup.c " +
262                    "ipc/family/c6a8149/InterruptHost.c " +
263                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
264                    "ipc/family/c6a8149/NotifyDriverMbx.c " +
265                    "ipc/family/omap3530/NotifySetup.c " +
266                    "ipc/family/omap3530/NotifyCircSetup.c " +
267                    "ipc/family/omap3530/InterruptHost.c ";
269 var A8gSources  =
270                    "ipc/gates/GateHWSpinlock.c " +
271                    "ipc/family/ti81xx/NotifySetup.c " +
272                    "ipc/family/ti81xx/NotifyCircSetup.c " +
273                    "ipc/family/ti81xx/InterruptHost.c " +
274                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
275                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
276                    "ipc/family/c6a8149/NotifySetup.c " +
277                    "ipc/family/c6a8149/NotifyCircSetup.c " +
278                    "ipc/family/c6a8149/InterruptHost.c " +
279                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
280                    "ipc/family/c6a8149/NotifyDriverMbx.c " +
281                    "ipc/family/omap3530/NotifySetup.c " +
282                    "ipc/family/omap3530/NotifyCircSetup.c " +
283                    "ipc/family/omap3530/InterruptHost.c ";
286 var A15gSources  = "ipc/family/vayu/InterruptHost.c " +
287                    "ipc/family/vayu/NotifySetup.c " +
288                    "ipc/gates/GateHWSpinlock.c ";
290 var ARP32Sources   =
291                    "ipc/gates/GateHWSpinlock.c " +
292                    "ipc/family/arctic/NotifySetup.c " +
293                    "ipc/family/arctic/NotifyCircSetup.c " +
294                    "ipc/family/arctic/InterruptArp32.c " +
295                    "ipc/family/c6a8149/NotifySetup.c " +
296                    "ipc/family/c6a8149/NotifyCircSetup.c " +
297                    "ipc/family/c6a8149/InterruptEve.c " +
298                    "ipc/family/vayu/InterruptArp32.c " +
299                    "ipc/family/vayu/NotifySetup.c ";
301 var cList = {
302     "ti.targets.C28_large"              : commonSources + C28Sources,
303     "ti.targets.C28_float"              : commonSources + C28Sources,
305     "ti.targets.C64P"                   : commonSources + C647xSources + C64PSources,
306     "ti.targets.C64P_big_endian"        : commonSources + C647xSources + C64PSources,
307     "ti.targets.C674"                   : commonSources + C674Sources,
309     "ti.targets.elf.C64P"               : commonSources + C647xSources + C64PSources,
310     "ti.targets.elf.C64P_big_endian"    : commonSources + C647xSources + C64PSources,
311     "ti.targets.elf.C674"               : commonSources + C674Sources,
312     "ti.targets.elf.C64T"               : commonSources + C64TSources,
313     "ti.targets.elf.C66"                : commonSources + C647xSources + C66Sources,
314     "ti.targets.elf.C66_big_endian"     : commonSources + C647xSources + C66Sources,
316     "ti.targets.arp32.elf.ARP32"        : commonSources + ARP32Sources,
317     "ti.targets.arp32.elf.ARP32_far"    : commonSources + ARP32Sources,
319     "ti.targets.arm.elf.Arm9"           : commonSources + Arm9Sources,
320     "ti.targets.arm.elf.A8F"            : commonSources + A8FSources,
321     "ti.targets.arm.elf.A8Fnv"          : commonSources + A8FSources,
322     "ti.targets.arm.elf.M3"             : commonSources + M3Sources,
323     "ti.targets.arm.elf.M4"             : commonSources + M4Sources,
324     "ti.targets.arm.elf.M4F"            : commonSources + M4Sources,
326     "gnu.targets.arm.A15F"              : commonSources + A15gSources,
327     "gnu.targets.arm.A8F"               : commonSources + A8gSources,
328     "gnu.targets.arm.M3"                : commonSources + M3Sources,
329     "gnu.targets.arm.M4"                : commonSources + M4Sources,
330     "gnu.targets.arm.M4F"               : commonSources + M4Sources,
331 };
333 var ipcPackages = [
334     "ti.sdo.ipc",
335     "ti.sdo.ipc.family.omap4430",
336     "ti.sdo.ipc.family.omap3530",
337     "ti.sdo.ipc.family.da830",
338     "ti.sdo.ipc.family.dm6446",
339     "ti.sdo.ipc.family.ti81xx",
340     "ti.sdo.ipc.family.arctic",
341     "ti.sdo.ipc.family.f28m35x",
342     "ti.sdo.ipc.family.c647x",
343     "ti.sdo.ipc.family.c6a8149",
344     "ti.sdo.ipc.family.tci663x",
345     "ti.sdo.ipc.family.vayu",
346     "ti.sdo.ipc.gates",
347     "ti.sdo.ipc.heaps",
348     "ti.sdo.ipc.notifyDrivers",
349     "ti.sdo.ipc.nsremote",
350     "ti.sdo.ipc.transports",
351     "ti.sdo.utils",
352 ];
354 var asmListNone = [
355 ];
357 var asmList64P = [
358     "ipc/gates/GateAAMonitor_asm.s64P",
359 ];
361 var asmList = {
362     "ti.targets.C28_large"              : asmListNone,
363     "ti.targets.C28_float"              : asmListNone,
365     "ti.targets.C64P"                   : asmList64P,
366     "ti.targets.C64P_big_endian"        : asmList64P,
367     "ti.targets.C674"                   : asmList64P,
369     "ti.targets.elf.C64P"               : asmList64P,
370     "ti.targets.elf.C64P_big_endian"    : asmList64P,
371     "ti.targets.elf.C674"               : asmList64P,
373     "ti.targets.elf.C64T"               : asmListNone,
374     "ti.targets.elf.C66"                : asmListNone,
375     "ti.targets.elf.C66_big_endian"     : asmListNone,
377     "ti.targets.arp32.elf.ARP32"        : asmListNone,
378     "ti.targets.arp32.elf.ARP32_far"    : asmListNone,
380     "ti.targets.arm.elf.Arm9"           : asmListNone,
381     "ti.targets.arm.elf.A8F"            : asmListNone,
382     "ti.targets.arm.elf.A8Fnv"          : asmListNone,
383     "ti.targets.arm.elf.M3"             : asmListNone,
384     "ti.targets.arm.elf.M4"             : asmListNone,
385     "ti.targets.arm.elf.M4F"            : asmListNone,
387     "gnu.targets.arm.M3"                : asmListNone,
388     "gnu.targets.arm.M4"                : asmListNone,
389     "gnu.targets.arm.M4F"               : asmListNone,
390     "gnu.targets.arm.A8F"               : asmListNone,
391     "gnu.targets.arm.A9F"               : asmListNone,
392     "gnu.targets.arm.A15F"              : asmListNone,
393 };
395 var cFiles = {};
397 /*
398  *  ======== getCFiles ========
399  */
400 function getCFiles(target)
402     var localSources = "ipc/Ipc.c ";
404     /*
405      * logic to trim the C files down to just what the application needs
406      * 3/2/11 disabled for now ...
407      */
408     if (BIOS.buildingAppLib == true) {
409         for each (var mod in Program.targetModules()) {
410             var mn = mod.$name;
411             var pn = mn.substring(0, mn.lastIndexOf("."));
413             /* sanity check package path */
414             var packageMatch = false;
416             for (var i = 0; i < ipcPackages.length; i++) {
417                 if (pn == ipcPackages[i]) {
418                     packageMatch = true;
419                     break;
420                 }
421             }
423             if (packageMatch && !mn.match(/Proxy/) &&
424                (mn != "ti.sdo.ipc.Ipc")) {
425                 if (cFiles[mn] === undefined) {
426                     var prefix = mn.substr(mn.indexOf("sdo")+4);
427                     var mod = mn.substr(mn.lastIndexOf(".")+1);
428                     prefix = prefix.substring(0, prefix.lastIndexOf('.')+1);
429                     prefix = prefix.replace(/\./g, "/");
430                     localSources += prefix + mod + ".c ";
431                 }
432                 else {
433                     for (i in cFiles[mn].cSources) {
434                         var prefix = mn.substr(mn.indexOf("sdo")+8);
435                         prefix = prefix.substring(0, prefix.lastIndexOf('.')+1);
436                         prefix = prefix.replace(/\./g, "/");
437                         localSources += prefix + cFiles[mn].cSources[i] + " ";
438                     }
439                 }
440             }
441         }
442     }
443     else {
444         localSources += cList[target];
445     }
447     /* remove trailing " " */
448     localSources = localSources.substring(0, localSources.length-1);
450     return (localSources);
453 /*
454  *  ======== getAsmFiles ========
455  */
456 function getAsmFiles(target)
458     return (asmList[target]);
461 /*
462  *  ======== getDefs ========
463  */
464 function getDefs()
466     var Defaults = xdc.module('xdc.runtime.Defaults');
467     var Diags = xdc.module("xdc.runtime.Diags");
468     var BIOS = xdc.module("ti.sysbios.BIOS");
469     var MessageQ = xdc.module("ti.sdo.ipc.MessageQ");
471     var defs = "";
473     if ((BIOS.assertsEnabled == false) ||
474         ((Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
475             && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF))) {
476         defs += " -Dxdc_runtime_Assert_DISABLE_ALL";
477     }
479     if (BIOS.logsEnabled == false) {
480         defs += " -Dxdc_runtime_Log_DISABLE_ALL";
481     }
483     defs += " -Dti_sdo_ipc_MessageQ_traceFlag__D=" + (MessageQ.traceFlag ? "TRUE" : "FALSE");
485     var InterruptDucati = xdc.module("ti.sdo.ipc.family.ti81xx.InterruptDucati");
487     /*
488      * If we truely know which platform we're building against,
489      * add these application specific -D's
490      */
491     if (BIOS.buildingAppLib == true) {
492         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_videoProcId__D=" + InterruptDucati.videoProcId;
493         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_hostProcId__D=" + InterruptDucati.hostProcId;
494         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_vpssProcId__D=" + InterruptDucati.vpssProcId;
495         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_dspProcId__D=" + InterruptDucati.dspProcId;
496         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_ducatiCtrlBaseAddr__D=" + InterruptDucati.ducatiCtrlBaseAddr;
497         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_mailboxBaseAddr__D=" + InterruptDucati.mailboxBaseAddr;
498     }
500     return (defs);
503 /*
504  *  ======== getLibs ========
505  */
506 function getLibs(pkg)
508     var BIOS = xdc.module("ti.sysbios.BIOS");
510     if (BIOS.libType != BIOS.LibType_Debug) {
511         return null;
512     }
514     var lib = "";
515     var name = pkg.$name + ".a" + prog.build.target.suffix;
517     if (BIOS.smpEnabled == true) {
518         lib = "lib/smpipc/debug/" + name;
519     }
520     else {
521         lib = "lib/ipc/debug/" + name;
522     }
524     if (java.io.File(pkg.packageBase + lib).exists()) {
525         return lib;
526     }
528     /* could not find any library, throw exception */
529     throw Error("Library not found: " + name);
533 /*
534  *  ======== getProfiles ========
535  *  Determines which profiles to build for.
536  *
537  *  Any argument in XDCARGS which does not contain platform= is treated
538  *  as a profile. This way multiple build profiles can be specified by
539  *  separating them with a space.
540  */
541 function getProfiles(xdcArgs)
543     /*
544      * cmdlProf[1] gets matched to "whole_program,debug" if
545      * ["abc", "profile=whole_program,debug"] is passed in as xdcArgs
546      */
547     var cmdlProf = (" " + xdcArgs.join(" ") + " ").match(/ profile=([^ ]+) /);
549     if (cmdlProf == null) {
550         /* No profile=XYZ found */
551         return [];
552     }
554     /* Split "whole_program,debug" into ["whole_program", "debug"] */
555     var profiles = cmdlProf[1].split(',');
557     return profiles;
560 /*
561  *  ======== buildLibs ========
562  *  This function generates the makefile goals for the libraries
563  *  produced by a ti.sysbios package.
564  */
565 function buildLibs(objList, relList, filter, xdcArgs)
567     for (var i = 0; i < xdc.module('xdc.bld.BuildEnvironment').targets.length; i++) {
568         var targ = xdc.module('xdc.bld.BuildEnvironment').targets[i];
570         /* skip target if not supported */
571         if (!supportsTarget(targ, filter)) {
572             continue;
573         }
575         var profiles = getProfiles(xdcArgs);
577         /* If no profiles were assigned, use only the default one. */
578         if (profiles.length == 0) {
579             profiles[0] = "debug";
580         }
582         for (var j = 0; j < profiles.length; j++) {
583             var ccopts = "";
584             var asmopts = "";
586             if (profiles[j] == "smp") {
587                 var libPath = "lib/smpipc/debug/";
588                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
589                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
590             }
591             else {
592                 var libPath = "lib/ipc/debug/";
593                 /* build all package libs using Hwi macros */
594                 ccopts += " -Dti_sysbios_Build_useHwiMacros";
595                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
596                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
597             }
599             /* confirm that this target supports this profile */
600             if (targ.profiles[profiles[j]] !== undefined) {
601                 var profile = profiles[j];
602                 var lib = Pkg.addLibrary(libPath + Pkg.name,
603                                 targ, {
604                                 profile: profile,
605                                 copts: ccopts,
606                                 aopts: asmopts,
607                                 releases: relList
608                                 });
609                 lib.addObjects(objList);
610             }
611         }
612     }
616 /*
617  *  ======== supportsTarget ========
618  *  Returns true if target is in the filter object. If filter
619  *  is null or empty, that's taken to mean all targets are supported.
620  */
621 function supportsTarget(target, filter)
623     var list, field;
625     if (filter == null) {
626         return true;
627     }
629     /*
630      * For backwards compatibility, we support filter as an array of
631      * target names.  The preferred approach is to specify filter as
632      * an object with 'field' and 'list' elements.
633      *
634      * Old form:
635      *     var trgFilter = [ "Arm9", "Arm9t", "Arm9t_big_endian" ]
636      *
637      * New (preferred) form:
638      *
639      *     var trgFilter = {
640      *         field: "isa",
641      *         list: [ "v5T", "v7R" ]
642      *     };
643      *
644      */
645     if (filter instanceof Array) {
646         list = filter;
647         field = "name";
648     }
649     else {
650         list = filter.list;
651         field = filter.field;
652     }
654     if (list == null || field == null) {
655         throw("invalid filter parameter, must specify list and field!");
656     }
658     if (field == "noIsa") {
659         if (String(','+list.toString()+',').match(','+target["isa"]+',')) {
660             return (false);
661         }
662         return (true);
663     }
665     /*
666      * add ',' at front and and tail of list and field strings to allow
667      * use of simple match API.  For example, the string is updated to:
668      * ',v5T,v7R,' to allow match of ',v5t,'.
669      */
670     if (String(','+list.toString()+',').match(','+target[field]+',')) {
671         return (true);
672     }
674     return (false);