Merge remote-tracking branch 'origin/ipc-3.10-next' into ipc-3.20-next
[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;
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();
110 /*
111  *  ======== module$use ========
112  */
113 function module$use()
115 //  Build = this;
116     BIOS = xdc.module("ti.sysbios.BIOS");
117     var profile;
119     /* inform ti.sdo.utils.Build *not* to contribute libraries */
120 //  xdc.module("ti.sdo.utils.Build").doBuild = false;
122     /* if Build.libType is undefined, use BIOS.libType */
123     if (Build.libType == undefined) {
124         switch (BIOS.libType) {
125             case BIOS.LibType_Instrumented:
126                 Build.libType = Build.LibType_Instrumented;
127                 break;
128             case BIOS.LibType_NonInstrumented:
129                 Build.libType = Build.LibType_NonInstrumented;
130                 break;
131             case BIOS.LibType_Custom:
132                 Build.libType = Build.LibType_Custom;
133                 break;
134             case BIOS.LibType_Debug:
135                 Build.libType = Build.LibType_Debug;
136                 break;
137         }
138     }
140     /*  Get the profile associated with the ti.sdo.ipc package. The
141      *  profile may be specified per package with a line like this
142      *  in your .cfg script:
143      *
144      *  xdc.loadPackage('ti.sdo.ipc').profile = "release";
145      */
146     if (this.$package.profile != undefined) {
147         profile = this.$package.profile;
148     }
149     else {
150         profile = Program.build.profile;
151     }
153     /* gracefully handle non-supported whole_program profiles */
154     if (profile.match(/whole_program/) &&
155             (Build.libType != Build.LibType_Debug)) {
157         /* allow build to proceed */
158         Build.libType = Build.LibType_Debug;
159         /* but warning the user */
160         Build.$logWarning(
161             "The '" + profile + "' build profile will not be supported " +
162             "in future releases of IPC. Use 'release' or 'debug' profiles " +
163             "together with the 'Build.libType' configuration parameter to " +
164             "specify your preferred library. See the compatibility section " +
165             "of your IPC release notes for more information.",
166             "Profile Deprecation Warning", Build);
167     }
169     /* inform getLibs() about location of library */
170     switch (Build.libType) {
171         case Build.LibType_Instrumented:
172             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
173             this.$private.outputDir = this.$package.packageBase + "lib/" +
174                 (BIOS.smpEnabled ? "smpipc/instrumented/":"ipc/instrumented/");
175             break;
177         case Build.LibType_NonInstrumented:
178             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
179             this.$private.outputDir = this.$package.packageBase + "lib/" +
180                 (BIOS.smpEnabled ? "smpipc/nonInstrumented/" :
181                 "ipc/nonInstrumented/");
182             break;
184         case Build.LibType_Debug:
185         case Build.LibType_Custom:
186             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
187             var SourceDir = xdc.useModule("xdc.cfg.SourceDir");
188             /* if building a pre-built library */
189             if (BIOS.buildingAppLib == false) {
190                 var appName = Program.name.substring(0,
191                         Program.name.lastIndexOf('.'));
192                 this.$private.libDir = this.$package.packageBase + Build.libDir;
193                 if (!java.io.File(this.$private.libDir).exists()) {
194                     java.io.File(this.$private.libDir).mkdir();
195                 }
196             }
197             /*
198              * If building an application in CCS or package.bld world
199              * and libDir has been specified
200              */
201             if ((BIOS.buildingAppLib == true) && (Build.libDir !== null)) {
202                 SourceDir.outputDir = Build.libDir;
203                 var src = SourceDir.create("ipc");
204                 src.libraryName = this.$private.libraryName.substring(1);
205                 this.$private.outputDir = src.getGenSourceDir();
206             }
207             else {
208                 var curPath = java.io.File(".").getCanonicalPath();
209                 /* If package.bld world AND building an application OR
210                  * pre-built lib... */
211                 if (java.io.File(curPath).getName() != "configPkg") {
212                     var appName = Program.name.substring(0,
213                             Program.name.lastIndexOf('.'));
214                     appName = appName + "_p" + Program.build.target.suffix +
215                             ".src";
216                     SourceDir.outputDir = "package/cfg/" + appName;
217                     SourceDir.toBuildDir = ".";
218                     var src = SourceDir.create("ipc");
219                     src.libraryName = this.$private.libraryName.substring(1);
220                     this.$private.outputDir = src.getGenSourceDir();
221                 }
222                 /* Here ONLY if building an application in CCS world */
223                 else {
224                     /* request output source directory for generated files */
225                     var appName = Program.name.substring(0,
226                             Program.name.lastIndexOf('.'));
227                     appName = appName + "_" + Program.name.substr(
228                             Program.name.lastIndexOf('.')+1);
229                     SourceDir.toBuildDir = "..";
230                     var src = SourceDir.create("ipc/");
231                     src.libraryName = this.$private.libraryName.substring(1);
233                     /*  save this directory in our private state (to be
234                      *  read during generation, see Gen.xdt)
235                      */
236                     this.$private.outputDir = src.getGenSourceDir();
237                 }
238             }
239             break;
240     }
243 /*
244  *  ======== module$validate ========
245  *  Some redundant tests are here to catch changes since
246  *  module$static$init() and instance$static$init().
247  */
248 function module$validate()
250     var Defaults = xdc.module('xdc.runtime.Defaults');
251     var Diags = xdc.module("xdc.runtime.Diags");
252     var libType = getEnumString(Build.libType);
254     switch (Build.libType) {
255         case Build.LibType_Instrumented:
256             if (Build.assertsEnabled == false) {
257                 Build.$logWarning(
258                         "Build.assertsEnabled must be set to true when " +
259                         "Build.libType == Build." + libType + ". " + "Set " +
260                         "Build.libType = Build.LibType_Custom to build a " +
261                         "custom library or update your configuration.",
262                         Build, "assertsEnabled");
263             }
264             if (Build.logsEnabled == false) {
265                 Build.$logWarning(
266                         "Build.logsEnabled must be set to true when " +
267                         "Build.libType == Build." + libType + ". " + "Set " +
268                         "Build.libType = Build.LibType_Custom to build a " +
269                         "custom library or update your configuration.",
270                         Build, "logsEnabled");
271             }
272             break;
274         case Build.LibType_NonInstrumented:
275             if ((Build.assertsEnabled == true) &&
276                     Build.$written("assertsEnabled")){
277                 Build.$logWarning(
278                         "Build.assertsEnabled must be set to false when " +
279                         "Build.libType == Build." + libType + ". " + "Set " +
280                         "Build.libType = Build.LibType_Custom to build a " +
281                         "custom library or update your configuration.",
282                         Build, "assertsEnabled");
283             }
284             if ((Build.logsEnabled == true) && Build.$written("logsEnabled")) {
285                 Build.$logWarning(
286                         "Build.logsEnabled must be set to false when " +
287                         "Build.libType == Build." + libType + ". " + "Set " +
288                         "Build.libType = Build.LibType_Custom to build a " +
289                         "custom library or update your configuration.",
290                         Build, "logsEnabled");
291             }
292             break;
294         case Build.LibType_Custom:
295             if ((Build.assertsEnabled == true)
296                 && (Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
297                 && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF)) {
298                 Build.$logWarning(
299                         "Build.assertsEnabled should be set to 'false' when " +
300                         "Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF.",
301                         Build, "assertsEnabled");
302             }
303             break;
304     }
307 /*
308  *  ======== getEnumString ========
309  *  Return the enum value as a string.
310  *
311  *  Example usage:
312  *  If obj contains an enumeration type property "Enum enumProp"
313  *
314  *  view.enumString = getEnumString(obj.enumProp);
315  */
316 function getEnumString(enumProperty)
318     /*  Split the string into tokens in order to get rid of the
319      *  huge package path that precedes the enum string name.
320      *  Return the last two tokens concatenated with "_".
321      */
322     var enumStrArray = String(enumProperty).split(".");
323     var len = enumStrArray.length;
324     return (enumStrArray[len - 1]);
327 /*
328  * Add pre-built Instrumented and Non-Intrumented release libs
329  */
330 var ipcSources  =  "ipc/GateMP.c " +
331                    "ipc/ListMP.c " +
332                    "ipc/SharedRegion.c " +
333                    "ipc/MessageQ.c " +
334                    "ipc/Notify.c ";
336 var gatesSources = "ipc/gates/GatePeterson.c " +
337                    "ipc/gates/GatePetersonN.c " +
338                    "ipc/gates/GateMPSupportNull.c ";
340 var heapsSources = "ipc/heaps/HeapBufMP.c " +
341                    "ipc/heaps/HeapMemMP.c " +
342                    "ipc/heaps/HeapMultiBufMP.c ";
344 var notifyDriverSources =
345                    "ipc/notifyDrivers/NotifyDriverCirc.c " +
346                    "ipc/notifyDrivers/NotifySetupNull.c " +
347                    "ipc/notifyDrivers/NotifyDriverShm.c ";
349 var nsremoteSources =
350                    "ipc/nsremote/NameServerRemoteNotify.c " +
351                    "ipc/nsremote/NameServerMessageQ.c ";
353 var transportsSources =
354                    "ipc/transports/TransportShm.c " +
355                    "ipc/transports/TransportShmCircSetup.c " +
356                    "ipc/transports/TransportShmNotifySetup.c " +
357                    "ipc/transports/TransportShmCirc.c " +
358                    "ipc/transports/TransportShmNotify.c " +
359                    "ipc/transports/TransportShmSetup.c " +
360                    "ipc/transports/TransportNullSetup.c " ;
362 var utilsSources = "utils/MultiProc.c " +
363                    "utils/List.c " +
364                    "utils/NameServerRemoteNull.c " +
365                    "utils/NameServer.c ";
367 var commonSources = ipcSources +
368                     gatesSources +
369                     heapsSources +
370                     notifyDriverSources +
371                     nsremoteSources +
372                     transportsSources;
373 //                  utilsSources;
375 var C64PSources  =
376                    "ipc/gates/GateAAMonitor.c " +
377                    "ipc/gates/GateHWSpinlock.c " +
378                    "ipc/gates/GateHWSem.c " +
379                    "ipc/family/dm6446/NotifySetup.c " +
380                    "ipc/family/dm6446/NotifyCircSetup.c " +
381                    "ipc/family/dm6446/InterruptDsp.c " +
382                    "ipc/family/omap3530/NotifySetup.c " +
383                    "ipc/family/omap3530/NotifyCircSetup.c " +
384                    "ipc/family/omap3530/InterruptDsp.c ";
386 var C66Sources   = "ipc/gates/GateHWSem.c " +
387                    "ipc/gates/GateHWSpinlock.c " +
388                    "ipc/family/tci663x/Interrupt.c " +
389                    "ipc/family/tci663x/MultiProcSetup.c " +
390                    "ipc/family/tci663x/NotifyCircSetup.c " +
391                    "ipc/family/tci663x/NotifySetup.c " +
392                    "ipc/family/vayu/InterruptDsp.c " +
393                    "ipc/family/vayu/NotifySetup.c ";
395 var C674Sources  =
396                    "ipc/gates/GateHWSpinlock.c " +
397                    "ipc/family/da830/NotifySetup.c " +
398                    "ipc/family/da830/NotifyCircSetup.c " +
399                    "ipc/family/da830/InterruptDsp.c " +
400                    "ipc/family/arctic/NotifySetup.c " +
401                    "ipc/family/arctic/NotifyCircSetup.c " +
402                    "ipc/family/arctic/InterruptDsp.c " +
403                    "ipc/family/ti81xx/NotifySetup.c " +
404                    "ipc/family/ti81xx/NotifyCircSetup.c " +
405                    "ipc/family/ti81xx/InterruptDsp.c " +
406                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
407                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
408                    "ipc/family/c6a8149/NotifySetup.c " +
409                    "ipc/family/c6a8149/NotifyCircSetup.c " +
410                    "ipc/family/c6a8149/InterruptDsp.c " +
411                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
412                    "ipc/family/c6a8149/NotifyDriverMbx.c ";
415 var C647xSources = "ipc/family/c647x/Interrupt.c " +
416                    "ipc/family/c647x/NotifyCircSetup.c " +
417                    "ipc/family/c647x/MultiProcSetup.c " +
418                    "ipc/family/c647x/NotifySetup.c ";
420 var C64TSources  =
421                    "ipc/gates/GateHWSpinlock.c " +
422                    "ipc/family/omap4430/NotifyCircSetup.c " +
423                    "ipc/family/omap4430/NotifySetup.c " +
424                    "ipc/family/omap4430/InterruptDsp.c ";
426 var C28Sources   = "ipc/family/f28m35x/NotifyDriverCirc.c " +
427                    "ipc/family/f28m35x/IpcMgr.c " +
428                    "ipc/family/f28m35x/TransportCirc.c " +
429                    "ipc/family/f28m35x/NameServerBlock.c ";
431 var M3Sources    =
432                    "ipc/gates/GateHWSpinlock.c " +
433                    "ipc/family/omap4430/NotifySetup.c " +
434                    "ipc/family/omap4430/NotifyCircSetup.c " +
435                    "ipc/family/omap4430/InterruptDucati.c " +
436                    "ipc/family/ti81xx/NotifySetup.c " +
437                    "ipc/family/ti81xx/NotifyCircSetup.c " +
438                    "ipc/family/ti81xx/InterruptDucati.c " +
439                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
440                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
441                    "ipc/family/c6a8149/NotifySetup.c " +
442                    "ipc/family/c6a8149/NotifyCircSetup.c " +
443                    "ipc/family/c6a8149/InterruptDucati.c " +
444                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
445                    "ipc/family/c6a8149/NotifyDriverMbx.c " +
446                    "ipc/family/f28m35x/IpcMgr.c " +
447                    "ipc/family/f28m35x/NotifyDriverCirc.c " +
448                    "ipc/family/f28m35x/TransportCirc.c " +
449                    "ipc/family/f28m35x/NameServerBlock.c " +
450                    "ipc/family/vayu/InterruptIpu.c " +
451                    "ipc/family/vayu/NotifySetup.c ";
453 var M4Sources    =
454                    "ipc/gates/GateHWSpinlock.c " +
455                    "ipc/family/vayu/InterruptIpu.c " +
456                    "ipc/family/vayu/NotifySetup.c ";
458 var Arm9Sources  = "ipc/family/dm6446/NotifySetup.c " +
459                    "ipc/family/dm6446/NotifyCircSetup.c " +
460                    "ipc/family/dm6446/InterruptArm.c " +
461                    "ipc/family/da830/NotifySetup.c " +
462                    "ipc/family/da830/NotifyCircSetup.c " +
463                    "ipc/family/da830/InterruptArm.c ";
465 var A8FSources   =
466                    "ipc/gates/GateHWSpinlock.c " +
467                    "ipc/family/ti81xx/NotifySetup.c " +
468                    "ipc/family/ti81xx/NotifyCircSetup.c " +
469                    "ipc/family/ti81xx/InterruptHost.c " +
470                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
471                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
472                    "ipc/family/c6a8149/NotifySetup.c " +
473                    "ipc/family/c6a8149/NotifyCircSetup.c " +
474                    "ipc/family/c6a8149/InterruptHost.c " +
475                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
476                    "ipc/family/c6a8149/NotifyDriverMbx.c " +
477                    "ipc/family/omap3530/NotifySetup.c " +
478                    "ipc/family/omap3530/NotifyCircSetup.c " +
479                    "ipc/family/omap3530/InterruptHost.c ";
481 var A8gSources  =
482                    "ipc/gates/GateHWSpinlock.c " +
483                    "ipc/family/ti81xx/NotifySetup.c " +
484                    "ipc/family/ti81xx/NotifyCircSetup.c " +
485                    "ipc/family/ti81xx/InterruptHost.c " +
486                    "ipc/family/ti81xx/NotifyMbxSetup.c " +
487                    "ipc/family/ti81xx/NotifyDriverMbx.c " +
488                    "ipc/family/c6a8149/NotifySetup.c " +
489                    "ipc/family/c6a8149/NotifyCircSetup.c " +
490                    "ipc/family/c6a8149/InterruptHost.c " +
491                    "ipc/family/c6a8149/NotifyMbxSetup.c " +
492                    "ipc/family/c6a8149/NotifyDriverMbx.c " +
493                    "ipc/family/omap3530/NotifySetup.c " +
494                    "ipc/family/omap3530/NotifyCircSetup.c " +
495                    "ipc/family/omap3530/InterruptHost.c ";
498 var A15gSources  = "ipc/family/vayu/InterruptHost.c " +
499                    "ipc/family/vayu/NotifySetup.c " +
500                    "ipc/gates/GateHWSpinlock.c ";
502 var ARP32Sources   =
503                    "ipc/gates/GateHWSpinlock.c " +
504                    "ipc/family/arctic/NotifySetup.c " +
505                    "ipc/family/arctic/NotifyCircSetup.c " +
506                    "ipc/family/arctic/InterruptArp32.c " +
507                    "ipc/family/c6a8149/NotifySetup.c " +
508                    "ipc/family/c6a8149/NotifyCircSetup.c " +
509                    "ipc/family/c6a8149/InterruptEve.c " +
510                    "ipc/family/vayu/InterruptArp32.c " +
511                    "ipc/family/vayu/NotifySetup.c ";
513 var cList = {
514     "ti.targets.C28_large"              : commonSources + C28Sources,
515     "ti.targets.C28_float"              : commonSources + C28Sources,
517     "ti.targets.C64P"                   : commonSources + C647xSources +
518                                                 C64PSources,
519     "ti.targets.C64P_big_endian"        : commonSources + C647xSources +
520                                                 C64PSources,
521     "ti.targets.C674"                   : commonSources + C674Sources,
523     "ti.targets.elf.C64P"               : commonSources + C647xSources +
524                                                 C64PSources,
525     "ti.targets.elf.C64P_big_endian"    : commonSources + C647xSources +
526                                                 C64PSources,
527     "ti.targets.elf.C674"               : commonSources + C674Sources,
528     "ti.targets.elf.C64T"               : commonSources + C64TSources,
529     "ti.targets.elf.C66"                : commonSources + C647xSources +
530                                                 C66Sources,
531     "ti.targets.elf.C66_big_endian"     : commonSources + C647xSources +
532                                                 C66Sources,
534     "ti.targets.arp32.elf.ARP32"        : commonSources + ARP32Sources,
535     "ti.targets.arp32.elf.ARP32_far"    : commonSources + ARP32Sources,
537     "ti.targets.arm.elf.Arm9"           : commonSources + Arm9Sources,
538     "ti.targets.arm.elf.A8F"            : commonSources + A8FSources,
539     "ti.targets.arm.elf.A8Fnv"          : commonSources + A8FSources,
540     "ti.targets.arm.elf.M3"             : commonSources + M3Sources,
541     "ti.targets.arm.elf.M4"             : commonSources + M4Sources,
542     "ti.targets.arm.elf.M4F"            : commonSources + M4Sources,
544     "gnu.targets.arm.A15F"              : commonSources + A15gSources,
545     "gnu.targets.arm.A8F"               : commonSources + A8gSources,
546     "gnu.targets.arm.M3"                : commonSources + M3Sources,
547     "gnu.targets.arm.M4"                : commonSources + M4Sources,
548     "gnu.targets.arm.M4F"               : commonSources + M4Sources,
549 };
551 var cFiles = { };
553 var ipcPackages = [
554     "ti.sdo.ipc",
555     "ti.sdo.ipc.family.omap4430",
556     "ti.sdo.ipc.family.omap3530",
557     "ti.sdo.ipc.family.da830",
558     "ti.sdo.ipc.family.dm6446",
559     "ti.sdo.ipc.family.ti81xx",
560     "ti.sdo.ipc.family.arctic",
561     "ti.sdo.ipc.family.f28m35x",
562     "ti.sdo.ipc.family.c647x",
563     "ti.sdo.ipc.family.c6a8149",
564     "ti.sdo.ipc.family.tci663x",
565     "ti.sdo.ipc.family.vayu",
566     "ti.sdo.ipc.gates",
567     "ti.sdo.ipc.heaps",
568     "ti.sdo.ipc.notifyDrivers",
569     "ti.sdo.ipc.nsremote",
570     "ti.sdo.ipc.transports",
571     "ti.sdo.utils",
572 ];
574 var asmListNone = [
575 ];
577 var asmList64P = [
578     "ipc/gates/GateAAMonitor_asm.s64P",
579 ];
581 var asmList = {
582     "ti.targets.C28_large"              : asmListNone,
583     "ti.targets.C28_float"              : asmListNone,
585     "ti.targets.C64P"                   : asmList64P,
586     "ti.targets.C64P_big_endian"        : asmList64P,
587     "ti.targets.C674"                   : asmList64P,
589     "ti.targets.elf.C64P"               : asmList64P,
590     "ti.targets.elf.C64P_big_endian"    : asmList64P,
591     "ti.targets.elf.C674"               : asmList64P,
593     "ti.targets.elf.C64T"               : asmListNone,
594     "ti.targets.elf.C66"                : asmListNone,
595     "ti.targets.elf.C66_big_endian"     : asmListNone,
597     "ti.targets.arp32.elf.ARP32"        : asmListNone,
598     "ti.targets.arp32.elf.ARP32_far"    : asmListNone,
600     "ti.targets.arm.elf.Arm9"           : asmListNone,
601     "ti.targets.arm.elf.A8F"            : asmListNone,
602     "ti.targets.arm.elf.A8Fnv"          : asmListNone,
603     "ti.targets.arm.elf.M3"             : asmListNone,
604     "ti.targets.arm.elf.M4"             : asmListNone,
605     "ti.targets.arm.elf.M4F"            : asmListNone,
607     "gnu.targets.arm.M3"                : asmListNone,
608     "gnu.targets.arm.M4"                : asmListNone,
609     "gnu.targets.arm.M4F"               : asmListNone,
610     "gnu.targets.arm.A8F"               : asmListNone,
611     "gnu.targets.arm.A9F"               : asmListNone,
612     "gnu.targets.arm.A15F"              : asmListNone,
613 };
615 function getDefaultCustomCCOpts()
617     var Build = this;
619     /* start with target.cc.opts */
620     var customCCOpts = Program.build.target.cc.opts;
622     /* add target unique custom ccOpts */
623     if (!(ccOptsList[Program.build.target.$name] === undefined)) {
624         customCCOpts += ccOptsList[Program.build.target.$name];
625     }
627     /* gnu targets need to pick up ccOpts.prefix and suffix */
628     if (Program.build.target.$name.match(/gnu/)) {
629         customCCOpts += " -O3 ";
630         customCCOpts += " " + Program.build.target.ccOpts.prefix + " ";
631         customCCOpts += " " + Program.build.target.ccOpts.suffix + " ";
632     }
633     else if (Program.build.target.$name.match(/iar/)) {
634         throw new Error("IAR not supported by IPC");
635     }
636     else {
637         /* ti targets do program level compile */
638         customCCOpts += " --program_level_compile -o3 -g " +
639                 "--optimize_with_debug ";
640     }
642     /* undo optimizations if this is a debug build */
643     if (Build.libType == Build.LibType_Debug) {
644         if (Program.build.target.$name.match(/gnu/)) {
645             customCCOpts = customCCOpts.replace("-O3","");
646             /* add in stack frames for stack back trace */
647             customCCOpts += " -mapcs ";
648         }
649         else {
650             customCCOpts = customCCOpts.replace(" -o3","");
651             customCCOpts = customCCOpts.replace(" --optimize_with_debug","");
652             if (Program.build.target.$name.match(/arm/)) {
653                 customCCOpts = customCCOpts.replace(" --opt_for_speed=2","");
654             }
655         }
656     }
658     return (customCCOpts);
661 /*
662  *  ======== getDefs ========
663  */
664 function getDefs()
666     var Build = this;
667     var Defaults = xdc.module('xdc.runtime.Defaults');
668     var Diags = xdc.module("xdc.runtime.Diags");
669     var BIOS = xdc.module("ti.sysbios.BIOS");
670     var MessageQ = xdc.module("ti.sdo.ipc.MessageQ");
672     var defs = "";
674     if ((Build.assertsEnabled == false) ||
675         ((Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
676             && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF))) {
677         defs += " -Dxdc_runtime_Assert_DISABLE_ALL";
678     }
680     if (Build.logsEnabled == false) {
681         defs += " -Dxdc_runtime_Log_DISABLE_ALL";
682     }
684     defs += " -Dti_sdo_ipc_MessageQ_traceFlag__D=" +
685             (MessageQ.traceFlag ? "TRUE" : "FALSE");
687     var InterruptDucati =
688             xdc.module("ti.sdo.ipc.family.ti81xx.InterruptDucati");
690     /* If we truely know which platform we're building against,
691      * add these application specific -D's
692      */
693     if (BIOS.buildingAppLib == true) {
694         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_videoProcId__D="
695                 + InterruptDucati.videoProcId;
696         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_hostProcId__D="
697                 + InterruptDucati.hostProcId;
698         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_vpssProcId__D="
699                 + InterruptDucati.vpssProcId;
700         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_dspProcId__D="
701                 + InterruptDucati.dspProcId;
702         defs +=
703             " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_ducatiCtrlBaseAddr__D="
704             + InterruptDucati.ducatiCtrlBaseAddr;
705         defs +=
706             " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_mailboxBaseAddr__D="
707             + InterruptDucati.mailboxBaseAddr;
708     }
710     return (defs);
713 /*
714  *  ======== getCFiles ========
715  */
716 function getCFiles(target)
718     var localSources = "ipc/Ipc.c ";
720     /*
721      * logic to trim the C files down to just what the application needs
722      * 3/2/11 disabled for now ...
723      */
724     if (BIOS.buildingAppLib == true) {
725         for each (var mod in Program.targetModules()) {
726             var mn = mod.$name;
727             var pn = mn.substring(0, mn.lastIndexOf("."));
729             /* sanity check package path */
730             var packageMatch = false;
732             for (var i = 0; i < ipcPackages.length; i++) {
733                 if (pn == ipcPackages[i]) {
734                     packageMatch = true;
735                     break;
736                 }
737             }
739             if (packageMatch && !mn.match(/Proxy/) &&
740                (mn != "ti.sdo.ipc.Ipc")) {
741                 if (cFiles[mn] === undefined) {
742                     var prefix = mn.substr(mn.indexOf("sdo")+4);
743                     var mod = mn.substr(mn.lastIndexOf(".")+1);
744                     prefix = prefix.substring(0, prefix.lastIndexOf('.')+1);
745                     prefix = prefix.replace(/\./g, "/");
746                     localSources += prefix + mod + ".c ";
747                 }
748                 else {
749                     for (i in cFiles[mn].cSources) {
750                         var prefix = mn.substr(mn.indexOf("sdo")+8);
751                         prefix = prefix.substring(0, prefix.lastIndexOf('.')+1);
752                         prefix = prefix.replace(/\./g, "/");
753                         localSources += prefix + cFiles[mn].cSources[i] + " ";
754                     }
755                 }
756             }
757         }
758     }
759     else {
760         localSources += cList[target];
761     }
763     /* remove trailing " " */
764     localSources = localSources.substring(0, localSources.length-1);
766     return (localSources);
769 /*
770  *  ======== getAsmFiles ========
771  */
772 function getAsmFiles(target)
774     return (asmList[target]);
777 /*
778  *  ======== getLibs ========
779  *  This function called by all IPC packages except ti.sdo.ipc package.
780  */
781 function getLibs(pkg)
783     var Build = this;
784     var libPath = "";
785     var name = "";
786     var suffix;
788     switch (Build.libType) {
789         case Build.LibType_Custom:
790         case Build.LibType_Instrumented:
791         case Build.LibType_NonInstrumented:
792         case Build.LibType_Debug:
793             return null;
795         case Build.LibType_PkgLib:
796             throw new Error("internal error: Build.getLibs() called with " +
797                     "incorret context (libType == PkgLib)");
798             break;
800         default:
801             throw new Error("Build.libType not supported: " + Build.libType);
802             break;
803     }
806 /*
807  *  ======== getProfiles ========
808  *  Determines which profiles to build for.
809  *
810  *  Any argument in XDCARGS which does not contain platform= is treated
811  *  as a profile. This way multiple build profiles can be specified by
812  *  separating them with a space.
813  */
814 function getProfiles(xdcArgs)
816     /*
817      * cmdlProf[1] gets matched to "whole_program,debug" if
818      * ["abc", "profile=whole_program,debug"] is passed in as xdcArgs
819      */
820     var cmdlProf = (" " + xdcArgs.join(" ") + " ").match(/ profile=([^ ]+) /);
822     if (cmdlProf == null) {
823         /* No profile=XYZ found */
824         return [];
825     }
827     /* Split "whole_program,debug" into ["whole_program", "debug"] */
828     var profiles = cmdlProf[1].split(',');
830     return profiles;
833 /*
834  *  ======== buildLibs ========
835  *  This function generates the makefile goals for the libraries
836  *  produced by a package.
837  */
838 function buildLibs(objList, relList, filter, xdcArgs)
840     var Build = xdc.useModule('xdc.bld.BuildEnvironment');
842     for (var i = 0; i < Build.targets.length; i++) {
843         var targ = Build.targets[i];
845         /* skip target if not supported */
846         if (!supportsTarget(targ, filter)) {
847             continue;
848         }
850         var profiles = getProfiles(xdcArgs);
852         /* If no profiles were assigned, use only the default one. */
853         if (profiles.length == 0) {
854             profiles[0] = "debug";
855         }
857         for (var j = 0; j < profiles.length; j++) {
858             var ccopts = "";
859             var asmopts = "";
861             if (profiles[j] == "smp") {
862                 var libPath = "lib/smpipc/debug/";
863                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
864                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
865             }
866             else {
867                 var libPath = "lib/ipc/debug/";
868                 /* build all package libs using Hwi macros */
869                 ccopts += " -Dti_sysbios_Build_useHwiMacros";
870                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
871                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
872             }
874             /* confirm that this target supports this profile */
875             if (targ.profiles[profiles[j]] !== undefined) {
876                 var profile = profiles[j];
877                 var lib = Pkg.addLibrary(libPath + Pkg.name,
878                                 targ, {
879                                 profile: profile,
880                                 copts: ccopts,
881                                 aopts: asmopts,
882                                 releases: relList
883                                 });
884                 lib.addObjects(objList);
885             }
886         }
887     }
890 /*
891  *  ======== supportsTarget ========
892  *  Returns true if target is in the filter object. If filter
893  *  is null or empty, that's taken to mean all targets are supported.
894  */
895 function supportsTarget(target, filter)
897     var list, field;
899     if (filter == null) {
900         return true;
901     }
903     /*
904      * For backwards compatibility, we support filter as an array of
905      * target names.  The preferred approach is to specify filter as
906      * an object with 'field' and 'list' elements.
907      *
908      * Old form:
909      *     var trgFilter = [ "Arm9", "Arm9t", "Arm9t_big_endian" ]
910      *
911      * New (preferred) form:
912      *
913      *     var trgFilter = {
914      *         field: "isa",
915      *         list: [ "v5T", "v7R" ]
916      *     };
917      *
918      */
919     if (filter instanceof Array) {
920         list = filter;
921         field = "name";
922     }
923     else {
924         list = filter.list;
925         field = filter.field;
926     }
928     if (list == null || field == null) {
929         throw("invalid filter parameter, must specify list and field!");
930     }
932     if (field == "noIsa") {
933         if (String(','+list.toString()+',').match(','+target["isa"]+',')) {
934             return (false);
935         }
936         return (true);
937     }
939     /*
940      * add ',' at front and and tail of list and field strings to allow
941      * use of simple match API.  For example, the string is updated to:
942      * ',v5T,v7R,' to allow match of ',v5t,'.
943      */
944     if (String(','+list.toString()+',').match(','+target[field]+',')) {
945         return (true);
946     }
948     return (false);
951 /*
952  *  ======== _setLibType ========
953  *  The "real-time" setter setLibType function
954  *  This function is called whenever libType changes.
955  */
956 function _setLibType(field, val)
958     var Build = this;
960     if (val == Build.LibType_Instrumented) {
961         Build.assertsEnabled = true;
962         Build.logsEnabled = true;
963     }
964     else if (val == Build.LibType_NonInstrumented) {
965         Build.assertsEnabled = false;
966         Build.logsEnabled = false;
967     }
968     else if (val == Build.LibType_Custom) {
969         Build.assertsEnabled = true;
970         Build.logsEnabled = true;
971     }
972     else if (val == Build.LibType_Debug) {
973         Build.assertsEnabled = true;
974         Build.logsEnabled = true;
975     }
976     else if (val == Build.LibType_PkgLib) {
977         Build.assertsEnabled = true;
978         Build.logsEnabled = true;
979     }
980     else {
981         print(Build.$name + ": unknown libType setting: " + val);
982     }
984     /* re-construct default Build.customCCOpts */
985     Build.customCCOpts = Build.getDefaultCustomCCOpts();