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