Build.xs: remove unused utilsSources
[ipc/ipcdev.git] / packages / ti / sdo / ipc / Build.xs
1 /*
2  * Copyright (c) 2013-2018 Texas Instruments Incorporated - http://www.ti.com
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 custom6xOpts = " -q -mi10 -mo -pdr -pden -pds=238 -pds=880 -pds1110 --mem_model:const=data --mem_model:data=far ";
42 var customARP32xOpts = " -q --gen_func_subsections ";
43 var customArmOpts = " -q -ms --opt_for_speed=2 ";
44 var customGnuArmM3Opts = " ";
45 var customGnuArmM4Opts = " ";
46 var customGnuArmM4FOpts = " ";
47 var customGnuArmA9Opts = " ";
48 var customGnuArmA8Opts = " ";
49 var customGnuArmA15Opts = " ";
50 var customGnuArmA53Opts = " ";
52 var ccOptsList = {
53     "ti.targets.C64P"                           : custom6xOpts,
54     "ti.targets.elf.C64P"                       : custom6xOpts,
55     "ti.targets.C64P_big_endian"                : custom6xOpts,
56     "ti.targets.elf.C64P_big_endian"            : custom6xOpts,
57     "ti.targets.C674"                           : custom6xOpts,
58     "ti.targets.elf.C674"                       : custom6xOpts,
59     "ti.targets.elf.C67P"                       : custom6xOpts,
60     "ti.targets.elf.C64T"                       : custom6xOpts,
61     "ti.targets.elf.C66"                        : custom6xOpts,
62     "ti.targets.elf.C66_big_endian"             : custom6xOpts,
63     "ti.targets.arp32.elf.ARP32"                : customARP32xOpts,
64     "ti.targets.arp32.elf.ARP32_far"            : customARP32xOpts,
65     "ti.targets.arm.elf.Arm9"                   : customArmOpts,
66     "ti.targets.arm.elf.A8F"                    : customArmOpts,
67     "ti.targets.arm.elf.A8Fnv"                  : customArmOpts,
68     "ti.targets.arm.elf.M3"                     : customArmOpts,
69     "ti.targets.arm.elf.M4"                     : customArmOpts,
70     "ti.targets.arm.elf.M4F"                    : customArmOpts,
71     "ti.targets.arm.elf.R5F"                    : customArmOpts,
72     "gnu.targets.arm.M3"                        : customGnuArmM3Opts,
73     "gnu.targets.arm.M4"                        : customGnuArmM4Opts,
74     "gnu.targets.arm.M4F"                       : customGnuArmM4FOpts,
75     "gnu.targets.arm.A8F"                       : customGnuArmA8Opts,
76     "gnu.targets.arm.A9F"                       : customGnuArmA9Opts,
77     "gnu.targets.arm.A15F"                      : customGnuArmA15Opts,
78     "gnu.targets.arm.A53F"                      : customGnuArmA53Opts,
79 };
81 var ipcPackages = [
82     "ti.sdo.ipc",
83     "ti.sdo.ipc.family.omap4430",
84     "ti.sdo.ipc.family.omap3530",
85     "ti.sdo.ipc.family.da830",
86     "ti.sdo.ipc.family.dm6446",
87     "ti.sdo.ipc.family.ti81xx",
88     "ti.sdo.ipc.family.arctic",
89     "ti.sdo.ipc.family.c647x",
90     "ti.sdo.ipc.family.c6a8149",
91     "ti.sdo.ipc.family.tci663x",
92     "ti.sdo.ipc.family.tda3xx",
93     "ti.sdo.ipc.family.vayu",
94     "ti.sdo.ipc.family.am65xx",
95     "ti.sdo.ipc.gates",
96     "ti.sdo.ipc.heaps",
97     "ti.sdo.ipc.notifyDrivers",
98     "ti.sdo.ipc.nsremote",
99     "ti.sdo.ipc.transports",
100     "ti.sdo.utils",
101     "ti.ipc.family.tci6614",
102     "ti.ipc.family.tci6638",
103     "ti.ipc.family.vayu",
104     "ti.ipc.family.am65xx",
105     "ti.ipc.namesrv",
106     "ti.ipc.remoteproc",
107     "ti.ipc.transports"
108 ];
110 var cFiles = {
111     "ti.ipc.ipcmgr" : {
112         cSources: [ "IpcMgr.c" ]
113     },
114     "ti.ipc.family.vayu" : {
115         cSources: [ "VirtQueue.c" ]
116     },
117     "ti.ipc.family.am65xx" : {
118         cSources: [ "VirtQueue.c" ]
119     },
120     "ti.ipc.rpmsg" : {
121         cSources: [ "NameMap.c", "RPMessage.c" ]
122     }
123 };
125 /*
126  *  ======== module$meta$init ========
127  */
128 function module$meta$init()
130     /* Only process during "cfg" phase */
131     if (xdc.om.$name != "cfg") {
132         return;
133     }
135     Build = this;
137     /*
138      * Set default verbose level for custom build flow
139      * User can override this in their cfg file.
140      */
141     var SourceDir = xdc.module("xdc.cfg.SourceDir");
142     SourceDir.verbose = 2;
144     /* register onSet hooks */
145     var GetSet = xdc.module("xdc.services.getset.GetSet");
146     GetSet.onSet(this, "libType", _setLibType);
148     /* Construct default customCCOpts value.
149      * User can override this in their cfg file.
150      */
151     Build.customCCOpts = Build.getDefaultCustomCCOpts();
153     /* needed by IPackage.close() method */
154     Build.$private.ipcPkgs = ipcPackages;
155     Build.$private.cFiles = cFiles;
158 /*
159  *  ======== module$use ========
160  */
161 function module$use()
163     BIOS = xdc.module("ti.sysbios.BIOS");
164     var profile;
166     /* inform ti.sdo.utils.Build *not* to contribute libraries */
167 //  xdc.module("ti.sdo.utils.Build").doBuild = false;
169     /* if Build.libType is undefined, use BIOS.libType */
170     if (Build.libType == undefined) {
171         switch (BIOS.libType) {
172             case BIOS.LibType_Instrumented:
173                 Build.libType = Build.LibType_Instrumented;
174                 break;
175             case BIOS.LibType_NonInstrumented:
176                 Build.libType = Build.LibType_NonInstrumented;
177                 break;
178             case BIOS.LibType_Custom:
179                 Build.libType = Build.LibType_Custom;
180                 break;
181             case BIOS.LibType_Debug:
182                 Build.libType = Build.LibType_Debug;
183                 break;
184         }
185     }
187     /*  Get the profile associated with the ti.sdo.ipc package. The
188      *  profile may be specified per package with a line like this
189      *  in your .cfg script:
190      *
191      *  xdc.loadPackage('ti.sdo.ipc').profile = "release";
192      */
193     if (this.$package.profile != undefined) {
194         profile = this.$package.profile;
195     }
196     else {
197         profile = Program.build.profile;
198     }
200     /* gracefully handle non-supported whole_program profiles */
201     if (profile.match(/whole_program/) &&
202             (Build.libType != Build.LibType_Debug)) {
204         /* allow build to proceed */
205         Build.libType = Build.LibType_Debug;
206         /* but warning the user */
207         Build.$logWarning(
208             "The '" + profile + "' build profile will not be supported " +
209             "in future releases of IPC. Use 'release' or 'debug' profiles " +
210             "together with the 'Build.libType' configuration parameter to " +
211             "specify your preferred library. See the compatibility section " +
212             "of your IPC release notes for more information.",
213             "Profile Deprecation Warning", Build);
214     }
216     /* inform getLibs() about location of library */
217     switch (Build.libType) {
218         case Build.LibType_Instrumented:
219             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
220             this.$private.outputDir = this.$package.packageBase + "lib/" +
221                 (BIOS.smpEnabled ? "smpipc/instrumented/":"ipc/instrumented/");
222             break;
224         case Build.LibType_NonInstrumented:
225             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
226             this.$private.outputDir = this.$package.packageBase + "lib/" +
227                 (BIOS.smpEnabled ? "smpipc/nonInstrumented/" :
228                 "ipc/nonInstrumented/");
229             break;
231         case Build.LibType_Debug:
232         case Build.LibType_Custom:
233             this.$private.libraryName = "/ipc.a" + Program.build.target.suffix;
234             var SourceDir = xdc.useModule("xdc.cfg.SourceDir");
235             /* if building a pre-built library */
236             if (BIOS.buildingAppLib == false) {
237                 var appName = Program.name.substring(0,
238                         Program.name.lastIndexOf('.'));
239                 this.$private.libDir = this.$package.packageBase + Build.libDir;
240                 if (!java.io.File(this.$private.libDir).exists()) {
241                     java.io.File(this.$private.libDir).mkdir();
242                 }
243             }
244             /*
245              * If building an application in CCS or package.bld world
246              * and libDir has been specified
247              */
248             if ((BIOS.buildingAppLib == true) && (Build.libDir !== null)) {
249                 SourceDir.outputDir = Build.libDir;
250                 var src = SourceDir.create("ipc");
251                 src.libraryName = this.$private.libraryName.substring(1);
252                 this.$private.outputDir = src.getGenSourceDir();
253             }
254             else {
255                 var curPath = java.io.File(".").getCanonicalPath();
256                 /* If package.bld world AND building an application OR
257                  * pre-built lib... */
258                 if (java.io.File(curPath).getName() != "configPkg") {
259                     var appName = Program.name.substring(0,
260                             Program.name.lastIndexOf('.'));
261                     appName = appName + "_p" + Program.build.target.suffix +
262                             ".src";
263                     SourceDir.outputDir = "package/cfg/" + appName;
264                     SourceDir.toBuildDir = ".";
265                     var src = SourceDir.create("ipc");
266                     src.libraryName = this.$private.libraryName.substring(1);
267                     this.$private.outputDir = src.getGenSourceDir();
268                 }
269                 /* Here ONLY if building an application in CCS world */
270                 else {
271                     /* request output source directory for generated files */
272                     var appName = Program.name.substring(0,
273                             Program.name.lastIndexOf('.'));
274                     appName = appName + "_" + Program.name.substr(
275                             Program.name.lastIndexOf('.')+1);
276                     SourceDir.toBuildDir = "..";
277                     var src = SourceDir.create("ipc/");
278                     src.libraryName = this.$private.libraryName.substring(1);
280                     /*  save this directory in our private state (to be
281                      *  read during generation, see Gen.xdt)
282                      */
283                     this.$private.outputDir = src.getGenSourceDir();
284                 }
285             }
286             break;
287     }
290 /*
291  *  ======== module$validate ========
292  *  Some redundant tests are here to catch changes since
293  *  module$static$init() and instance$static$init().
294  */
295 function module$validate()
297     var Defaults = xdc.module('xdc.runtime.Defaults');
298     var Diags = xdc.module("xdc.runtime.Diags");
299     var libType = getEnumString(Build.libType);
301     switch (Build.libType) {
302         case Build.LibType_Instrumented:
303             if (Build.assertsEnabled == false) {
304                 Build.$logWarning(
305                         "Build.assertsEnabled must be set to true when " +
306                         "Build.libType == Build." + libType + ". " + "Set " +
307                         "Build.libType = Build.LibType_Custom to build a " +
308                         "custom library or update your configuration.",
309                         Build, "assertsEnabled");
310             }
311             if (Build.logsEnabled == false) {
312                 Build.$logWarning(
313                         "Build.logsEnabled must be set to true when " +
314                         "Build.libType == Build." + libType + ". " + "Set " +
315                         "Build.libType = Build.LibType_Custom to build a " +
316                         "custom library or update your configuration.",
317                         Build, "logsEnabled");
318             }
319             break;
321         case Build.LibType_NonInstrumented:
322             if ((Build.assertsEnabled == true) &&
323                     Build.$written("assertsEnabled")){
324                 Build.$logWarning(
325                         "Build.assertsEnabled must be set to false when " +
326                         "Build.libType == Build." + libType + ". " + "Set " +
327                         "Build.libType = Build.LibType_Custom to build a " +
328                         "custom library or update your configuration.",
329                         Build, "assertsEnabled");
330             }
331             if ((Build.logsEnabled == true) && Build.$written("logsEnabled")) {
332                 Build.$logWarning(
333                         "Build.logsEnabled must be set to false when " +
334                         "Build.libType == Build." + libType + ". " + "Set " +
335                         "Build.libType = Build.LibType_Custom to build a " +
336                         "custom library or update your configuration.",
337                         Build, "logsEnabled");
338             }
339             break;
341         case Build.LibType_Custom:
342             if ((Build.assertsEnabled == true)
343                 && (Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
344                 && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF)) {
345                 Build.$logWarning(
346                         "Build.assertsEnabled should be set to 'false' when " +
347                         "Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF.",
348                         Build, "assertsEnabled");
349             }
350             break;
351     }
354 /*
355  *  ======== getCCOpts ========
356  */
357 function getCCOpts(target)
359     var ccOpts = "";
361     if (target.$name.match(/^ti\.targets\./)) {
362         if (("ti.ipc.rpmsg" in xdc.om) || ("ti.ipc.transports" in xdc.om)) {
363             ccOpts += " --gcc";
364         }
365     }
367     return (Build.customCCOpts + ccOpts);
370 /*
371  *  ======== getEnumString ========
372  *  Return the enum value as a string.
373  *
374  *  Example usage:
375  *  If obj contains an enumeration type property "Enum enumProp"
376  *
377  *  view.enumString = getEnumString(obj.enumProp);
378  */
379 function getEnumString(enumProperty)
381     /*  Split the string into tokens in order to get rid of the
382      *  huge package path that precedes the enum string name.
383      *  Return the last two tokens concatenated with "_".
384      */
385     var enumStrArray = String(enumProperty).split(".");
386     var len = enumStrArray.length;
387     return (enumStrArray[len - 1]);
390 /*
391  * Add pre-built Instrumented and Non-Intrumented release libs
392  */
393 var ipcSources  =  "ti/sdo/ipc/GateMP.c " +
394                    "ti/sdo/ipc/ListMP.c " +
395                    "ti/sdo/ipc/SharedRegion.c " +
396                    "ti/sdo/ipc/MessageQ.c " +
397                    "ti/sdo/ipc/Ipc.c " +
398                    "ti/sdo/ipc/Notify.c " +
399                    "ti/ipc/namesrv/NameServerRemoteRpmsg.c " +
400                    "ti/ipc/remoteproc/Resource.c ";
402 var gatesSources = "ti/sdo/ipc/gates/GatePeterson.c " +
403                    "ti/sdo/ipc/gates/GatePetersonN.c " +
404                    "ti/sdo/ipc/gates/GateMPSupportNull.c ";
406 var heapsSources = "ti/sdo/ipc/heaps/HeapBufMP.c " +
407                    "ti/sdo/ipc/heaps/HeapMemMP.c " +
408                    "ti/sdo/ipc/heaps/HeapMultiBufMP.c ";
410 var notifyDriverSources =
411                    "ti/sdo/ipc/notifyDrivers/NotifyDriverCirc.c " +
412                    "ti/sdo/ipc/notifyDrivers/NotifySetupNull.c " +
413                    "ti/sdo/ipc/notifyDrivers/NotifyDriverShm.c ";
415 var nsremoteSources =
416                    "ti/sdo/ipc/nsremote/NameServerRemoteNotify.c " +
417                    "ti/sdo/ipc/nsremote/NameServerMessageQ.c ";
419 var transportsSources =
420                    "ti/sdo/ipc/transports/TransportShm.c " +
421                    "ti/sdo/ipc/transports/TransportShmCircSetup.c " +
422                    "ti/sdo/ipc/transports/TransportShmNotifySetup.c " +
423                    "ti/sdo/ipc/transports/TransportShmCirc.c " +
424                    "ti/sdo/ipc/transports/TransportShmNotify.c " +
425                    "ti/sdo/ipc/transports/TransportShmSetup.c " +
426                    "ti/sdo/ipc/transports/TransportNullSetup.c " ;
428 var commonSources = ipcSources +
429                     gatesSources +
430                     heapsSources +
431                     notifyDriverSources +
432                     nsremoteSources +
433                     transportsSources;
435 var C64PSources  = "ti/sdo/ipc/gates/GateAAMonitor.c " +
436                    "ti/sdo/ipc/gates/GateHWSpinlock.c " +
437                    "ti/sdo/ipc/gates/GateHWSem.c " +
438                    "ti/sdo/ipc/family/dm6446/NotifySetup.c " +
439                    "ti/sdo/ipc/family/dm6446/NotifyCircSetup.c " +
440                    "ti/sdo/ipc/family/dm6446/InterruptDsp.c " +
441                    "ti/sdo/ipc/family/omap3530/NotifySetup.c " +
442                    "ti/sdo/ipc/family/omap3530/NotifyCircSetup.c " +
443                    "ti/sdo/ipc/family/omap3530/InterruptDsp.c ";
445 var C66Sources   = "ti/sdo/ipc/gates/GateHWSem.c " +
446                    "ti/sdo/ipc/gates/GateHWSpinlock.c " +
447                    "ti/sdo/ipc/family/tci663x/Interrupt.c " +
448                    "ti/sdo/ipc/family/tci663x/MultiProcSetup.c " +
449                    "ti/sdo/ipc/family/tci663x/NotifyCircSetup.c " +
450                    "ti/sdo/ipc/family/tci663x/NotifySetup.c " +
451                    "ti/sdo/ipc/family/vayu/InterruptDsp.c " +
452                    "ti/sdo/ipc/family/vayu/NotifyDriverMbx.c " +
453                    "ti/sdo/ipc/family/vayu/NotifySetup.c " +
454                    "ti/sdo/ipc/family/tda3xx/InterruptDsp.c " +
455                    "ti/sdo/ipc/family/tda3xx/NotifyDriverMbx.c " +
456                    "ti/sdo/ipc/family/tda3xx/NotifySetup.c " +
457                    "ti/ipc/family/tci6614/Interrupt.c " +
458                    "ti/ipc/family/tci6614/VirtQueue.c " +
459                    "ti/ipc/family/tci6614/NotifySetup.c " +
460                    "ti/ipc/family/tci6638/VirtQueue.c " +
461                    "ti/ipc/family/vayu/VirtQueue.c ";
463 var C674Sources  = "ti/sdo/ipc/gates/GateHWSpinlock.c " +
464                    "ti/sdo/ipc/family/da830/NotifySetup.c " +
465                    "ti/sdo/ipc/family/da830/NotifyCircSetup.c " +
466                    "ti/sdo/ipc/family/da830/InterruptDsp.c " +
467                    "ti/sdo/ipc/family/arctic/NotifySetup.c " +
468                    "ti/sdo/ipc/family/arctic/NotifyCircSetup.c " +
469                    "ti/sdo/ipc/family/arctic/InterruptDsp.c " +
470                    "ti/sdo/ipc/family/ti81xx/NotifySetup.c " +
471                    "ti/sdo/ipc/family/ti81xx/NotifyCircSetup.c " +
472                    "ti/sdo/ipc/family/ti81xx/InterruptDsp.c " +
473                    "ti/sdo/ipc/family/ti81xx/NotifyMbxSetup.c " +
474                    "ti/sdo/ipc/family/ti81xx/NotifyDriverMbx.c " +
475                    "ti/sdo/ipc/family/c6a8149/NotifySetup.c " +
476                    "ti/sdo/ipc/family/c6a8149/NotifyCircSetup.c " +
477                    "ti/sdo/ipc/family/c6a8149/InterruptDsp.c " +
478                    "ti/sdo/ipc/family/c6a8149/NotifyMbxSetup.c " +
479                    "ti/sdo/ipc/family/c6a8149/NotifyDriverMbx.c ";
481 var C647xSources = "ti/sdo/ipc/family/c647x/Interrupt.c " +
482                    "ti/sdo/ipc/family/c647x/NotifyCircSetup.c " +
483                    "ti/sdo/ipc/family/c647x/MultiProcSetup.c " +
484                    "ti/sdo/ipc/family/c647x/NotifySetup.c ";
486 var C64TSources  = "ti/sdo/ipc/gates/GateHWSpinlock.c " +
487                    "ti/sdo/ipc/family/omap4430/NotifyCircSetup.c " +
488                    "ti/sdo/ipc/family/omap4430/NotifySetup.c " +
489                    "ti/sdo/ipc/family/omap4430/InterruptDsp.c ";
491 var M3Sources    = "ti/sdo/ipc/gates/GateHWSpinlock.c " +
492                    "ti/sdo/ipc/family/omap4430/NotifySetup.c " +
493                    "ti/sdo/ipc/family/omap4430/NotifyCircSetup.c " +
494                    "ti/sdo/ipc/family/omap4430/InterruptDucati.c " +
495                    "ti/sdo/ipc/family/ti81xx/NotifySetup.c " +
496                    "ti/sdo/ipc/family/ti81xx/NotifyCircSetup.c " +
497                    "ti/sdo/ipc/family/ti81xx/InterruptDucati.c " +
498                    "ti/sdo/ipc/family/ti81xx/NotifyMbxSetup.c " +
499                    "ti/sdo/ipc/family/ti81xx/NotifyDriverMbx.c " +
500                    "ti/sdo/ipc/family/c6a8149/NotifySetup.c " +
501                    "ti/sdo/ipc/family/c6a8149/NotifyCircSetup.c " +
502                    "ti/sdo/ipc/family/c6a8149/InterruptDucati.c " +
503                    "ti/sdo/ipc/family/c6a8149/NotifyMbxSetup.c " +
504                    "ti/sdo/ipc/family/c6a8149/NotifyDriverMbx.c " +
505                    "ti/sdo/ipc/family/vayu/InterruptIpu.c " +
506                    "ti/sdo/ipc/family/vayu/NotifyDriverMbx.c " +
507                    "ti/sdo/ipc/family/vayu/NotifySetup.c " +
508                    "ti/sdo/ipc/family/tda3xx/InterruptIpu.c " +
509                    "ti/sdo/ipc/family/tda3xx/NotifyDriverMbx.c " +
510                    "ti/sdo/ipc/family/tda3xx/NotifySetup.c " +
511                    "ti/ipc/family/vayu/VirtQueue.c ";
513 var M4Sources    = "ti/sdo/ipc/gates/GateHWSpinlock.c " +
514                    "ti/sdo/ipc/family/vayu/InterruptIpu.c " +
515                    "ti/sdo/ipc/family/vayu/NotifyDriverMbx.c " +
516                    "ti/sdo/ipc/family/vayu/NotifySetup.c " +
517                    "ti/sdo/ipc/family/tda3xx/InterruptIpu.c " +
518                    "ti/sdo/ipc/family/tda3xx/NotifyDriverMbx.c " +
519                    "ti/sdo/ipc/family/tda3xx/NotifySetup.c " +
520                    "ti/ipc/family/vayu/VirtQueue.c ";
522 var Arm9Sources  = "ti/sdo/ipc/family/dm6446/NotifySetup.c " +
523                    "ti/sdo/ipc/family/dm6446/NotifyCircSetup.c " +
524                    "ti/sdo/ipc/family/dm6446/InterruptArm.c " +
525                    "ti/sdo/ipc/family/da830/NotifySetup.c " +
526                    "ti/sdo/ipc/family/da830/NotifyCircSetup.c " +
527                    "ti/sdo/ipc/family/da830/InterruptArm.c ";
529 var A8FSources   = "ti/sdo/ipc/gates/GateHWSpinlock.c " +
530                    "ti/sdo/ipc/family/ti81xx/NotifySetup.c " +
531                    "ti/sdo/ipc/family/ti81xx/NotifyCircSetup.c " +
532                    "ti/sdo/ipc/family/ti81xx/InterruptHost.c " +
533                    "ti/sdo/ipc/family/ti81xx/NotifyMbxSetup.c " +
534                    "ti/sdo/ipc/family/ti81xx/NotifyDriverMbx.c " +
535                    "ti/sdo/ipc/family/c6a8149/NotifySetup.c " +
536                    "ti/sdo/ipc/family/c6a8149/NotifyCircSetup.c " +
537                    "ti/sdo/ipc/family/c6a8149/InterruptHost.c " +
538                    "ti/sdo/ipc/family/c6a8149/NotifyMbxSetup.c " +
539                    "ti/sdo/ipc/family/c6a8149/NotifyDriverMbx.c " +
540                    "ti/sdo/ipc/family/omap3530/NotifySetup.c " +
541                    "ti/sdo/ipc/family/omap3530/NotifyCircSetup.c " +
542                    "ti/sdo/ipc/family/omap3530/InterruptHost.c ";
544 var A8gSources  =  "ti/sdo/ipc/gates/GateHWSpinlock.c " +
545                    "ti/sdo/ipc/family/ti81xx/NotifySetup.c " +
546                    "ti/sdo/ipc/family/ti81xx/NotifyCircSetup.c " +
547                    "ti/sdo/ipc/family/ti81xx/InterruptHost.c " +
548                    "ti/sdo/ipc/family/ti81xx/NotifyMbxSetup.c " +
549                    "ti/sdo/ipc/family/ti81xx/NotifyDriverMbx.c " +
550                    "ti/sdo/ipc/family/c6a8149/NotifySetup.c " +
551                    "ti/sdo/ipc/family/c6a8149/NotifyCircSetup.c " +
552                    "ti/sdo/ipc/family/c6a8149/InterruptHost.c " +
553                    "ti/sdo/ipc/family/c6a8149/NotifyMbxSetup.c " +
554                    "ti/sdo/ipc/family/c6a8149/NotifyDriverMbx.c " +
555                    "ti/sdo/ipc/family/omap3530/NotifySetup.c " +
556                    "ti/sdo/ipc/family/omap3530/NotifyCircSetup.c " +
557                    "ti/sdo/ipc/family/omap3530/InterruptHost.c ";
559 var A15gSources  = "ti/sdo/ipc/family/vayu/InterruptHost.c " +
560                    "ti/sdo/ipc/family/vayu/NotifyDriverMbx.c " +
561                    "ti/sdo/ipc/family/vayu/NotifySetup.c " +
562                    "ti/sdo/ipc/gates/GateHWSpinlock.c " +
563                    "ti/sdo/ipc/gates/GateHWSem.c " +
564                    "ti/sdo/ipc/family/tci663x/Interrupt.c " +
565                    "ti/sdo/ipc/family/tci663x/MultiProcSetup.c " +
566                    "ti/sdo/ipc/family/tci663x/NotifyCircSetup.c " +
567                    "ti/sdo/ipc/family/tci663x/NotifySetup.c ";
569 var ARP32Sources = "ti/sdo/ipc/gates/GateHWSpinlock.c " +
570                    "ti/sdo/ipc/family/arctic/NotifySetup.c " +
571                    "ti/sdo/ipc/family/arctic/NotifyCircSetup.c " +
572                    "ti/sdo/ipc/family/arctic/InterruptArp32.c " +
573                    "ti/sdo/ipc/family/c6a8149/NotifySetup.c " +
574                    "ti/sdo/ipc/family/c6a8149/NotifyCircSetup.c " +
575                    "ti/sdo/ipc/family/c6a8149/InterruptEve.c " +
576                    "ti/sdo/ipc/family/vayu/InterruptArp32.c " +
577                    "ti/sdo/ipc/family/vayu/NotifyDriverMbx.c " +
578                    "ti/sdo/ipc/family/vayu/NotifySetup.c " +
579                    "ti/sdo/ipc/family/tda3xx/InterruptArp32.c " +
580                    "ti/sdo/ipc/family/tda3xx/NotifyDriverMbx.c " +
581                    "ti/sdo/ipc/family/tda3xx/NotifySetup.c ";
583 var A53FSources  = "ti/sdo/ipc/family/am65xx/InterruptHost.c " +
584                    "ti/sdo/ipc/family/am65xx/NotifyDriverMbx.c " +
585                    "ti/sdo/ipc/family/am65xx/NotifySetup.c " +
586                    "ti/sdo/ipc/gates/GateHWSpinlock.c " +
587                    "ti/sdo/ipc/gates/GateHWSem.c ";
589 var R5FSources    = "ti/sdo/ipc/gates/GateHWSpinlock.c " +
590                    "ti/sdo/ipc/family/am65xx/InterruptR5f.c " +
591                    "ti/sdo/ipc/family/am65xx/NotifyDriverMbx.c " +
592                    "ti/sdo/ipc/family/am65xx/NotifySetup.c " +
593                    "ti/ipc/family/am65xx/VirtQueue.c ";
595 var cList = {
596     "ti.targets.C64P"                   : commonSources + C647xSources +
597                                                 C64PSources,
598     "ti.targets.C64P_big_endian"        : commonSources + C647xSources +
599                                                 C64PSources,
600     "ti.targets.C674"                   : commonSources + C674Sources,
602     "ti.targets.elf.C64P"               : commonSources + C647xSources +
603                                                 C64PSources,
604     "ti.targets.elf.C64P_big_endian"    : commonSources + C647xSources +
605                                                 C64PSources,
606     "ti.targets.elf.C674"               : commonSources + C674Sources,
607     "ti.targets.elf.C64T"               : commonSources + C64TSources,
608     "ti.targets.elf.C66"                : commonSources + C647xSources +
609                                                 C66Sources,
610     "ti.targets.elf.C66_big_endian"     : commonSources + C647xSources +
611                                                 C66Sources,
613     "ti.targets.arp32.elf.ARP32"        : commonSources + ARP32Sources,
614     "ti.targets.arp32.elf.ARP32_far"    : commonSources + ARP32Sources,
616     "ti.targets.arm.elf.Arm9"           : commonSources + Arm9Sources,
617     "ti.targets.arm.elf.A8F"            : commonSources + A8FSources,
618     "ti.targets.arm.elf.A8Fnv"          : commonSources + A8FSources,
619     "ti.targets.arm.elf.M3"             : commonSources + M3Sources,
620     "ti.targets.arm.elf.M4"             : commonSources + M4Sources,
621     "ti.targets.arm.elf.M4F"            : commonSources + M4Sources,
622     "ti.targets.arm.elf.R5F"            : commonSources + R5FSources,
624     "gnu.targets.arm.A15F"              : commonSources + A15gSources,
625     "gnu.targets.arm.A8F"               : commonSources + A8gSources,
626     "gnu.targets.arm.M3"                : commonSources + M3Sources,
627     "gnu.targets.arm.M4"                : commonSources + M4Sources,
628     "gnu.targets.arm.M4F"               : commonSources + M4Sources,
629     "gnu.targets.arm.A53F"              : commonSources + A53FSources,
630 };
632 var asmListNone = [
633 ];
635 var asmList64P = [
636     "ti/sdo/ipc/gates/GateAAMonitor_asm.s64P",
637 ];
639 var asmList = {
640     "ti.targets.C64P"                   : asmList64P,
641     "ti.targets.C64P_big_endian"        : asmList64P,
642     "ti.targets.C674"                   : asmList64P,
644     "ti.targets.elf.C64P"               : asmList64P,
645     "ti.targets.elf.C64P_big_endian"    : asmList64P,
646     "ti.targets.elf.C674"               : asmList64P,
648     "ti.targets.elf.C64T"               : asmListNone,
649     "ti.targets.elf.C66"                : asmListNone,
650     "ti.targets.elf.C66_big_endian"     : asmListNone,
652     "ti.targets.arp32.elf.ARP32"        : asmListNone,
653     "ti.targets.arp32.elf.ARP32_far"    : asmListNone,
655     "ti.targets.arm.elf.Arm9"           : asmListNone,
656     "ti.targets.arm.elf.A8F"            : asmListNone,
657     "ti.targets.arm.elf.A8Fnv"          : asmListNone,
658     "ti.targets.arm.elf.M3"             : asmListNone,
659     "ti.targets.arm.elf.M4"             : asmListNone,
660     "ti.targets.arm.elf.M4F"            : asmListNone,
661     "ti.targets.arm.elf.R5F"            : asmListNone,
663     "gnu.targets.arm.M3"                : asmListNone,
664     "gnu.targets.arm.M4"                : asmListNone,
665     "gnu.targets.arm.M4F"               : asmListNone,
666     "gnu.targets.arm.A8F"               : asmListNone,
667     "gnu.targets.arm.A9F"               : asmListNone,
668     "gnu.targets.arm.A15F"              : asmListNone,
669     "gnu.targets.arm.A53F"              : asmListNone,
670 };
672 function getDefaultCustomCCOpts()
675     /* start with target.cc.opts */
676     var customCCOpts = Program.build.target.cc.opts;
678     /* add target unique custom ccOpts */
679     if (!(ccOptsList[Program.build.target.$name] === undefined)) {
680         customCCOpts += ccOptsList[Program.build.target.$name];
681     }
683     /* gnu targets need to pick up ccOpts.prefix and suffix */
684     if (Program.build.target.$name.match(/gnu/)) {
685         customCCOpts += " -O3 ";
686         customCCOpts += " " + Program.build.target.ccOpts.prefix + " ";
687         customCCOpts += " " + Program.build.target.ccOpts.suffix + " ";
688     }
689     else if (Program.build.target.$name.match(/iar/)) {
690         throw new Error("IAR not supported by IPC");
691     }
692     else {
693         /* ti targets do program level compile */
694         customCCOpts += " --program_level_compile -o3 -g " +
695                 "--optimize_with_debug ";
696     }
698     /* undo optimizations if this is a debug build */
699     if (Build.libType == Build.LibType_Debug) {
700         if (Program.build.target.$name.match(/gnu/)) {
701             customCCOpts = customCCOpts.replace("-O3","");
702             /* add in stack frames for stack back trace */
703             customCCOpts += " -mapcs ";
704         }
705         else {
706             customCCOpts = customCCOpts.replace(" -o3","");
707             customCCOpts = customCCOpts.replace(" --optimize_with_debug","");
708             if (Program.build.target.$name.match(/arm/)) {
709                 customCCOpts = customCCOpts.replace(" --opt_for_speed=2","");
710             }
711         }
712     }
714     return (customCCOpts);
717 /*
718  *  ======== getDefs ========
719  */
720 function getDefs()
722     var Defaults = xdc.module('xdc.runtime.Defaults');
723     var Diags = xdc.module("xdc.runtime.Diags");
724     var BIOS = xdc.module("ti.sysbios.BIOS");
725     var MessageQ = xdc.module("ti.sdo.ipc.MessageQ");
727     var defs = "";
729     if ((Build.assertsEnabled == false) ||
730         ((Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
731             && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF))) {
732         defs += " -Dxdc_runtime_Assert_DISABLE_ALL";
733     }
735     if (Build.logsEnabled == false) {
736         defs += " -Dxdc_runtime_Log_DISABLE_ALL";
737     }
739     defs += " -Dti_sdo_ipc_MessageQ_traceFlag__D=" +
740             (MessageQ.traceFlag ? "TRUE" : "FALSE");
742     if ("ti.ipc.ipcmgr.IpcMgr" in xdc.om) {
743         defs += xdc.module("ti.ipc.ipcmgr.IpcMgr").getDefs();
744     }
746     if ("ti.ipc.rpmsg" in xdc.om) {
747         defs += xdc.module('ti.ipc.rpmsg.Build').getDefs();
748     }
750     var InterruptDucati =
751             xdc.module("ti.sdo.ipc.family.ti81xx.InterruptDucati");
753     /* If we truely know which platform we're building against,
754      * add these application specific -D's
755      */
756     if (BIOS.buildingAppLib == true) {
757         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_videoProcId__D="
758                 + InterruptDucati.videoProcId;
759         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_hostProcId__D="
760                 + InterruptDucati.hostProcId;
761         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_vpssProcId__D="
762                 + InterruptDucati.vpssProcId;
763         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_dspProcId__D="
764                 + InterruptDucati.dspProcId;
765         defs +=
766             " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_ducatiCtrlBaseAddr__D="
767             + InterruptDucati.ducatiCtrlBaseAddr;
768         defs +=
769             " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_mailboxBaseAddr__D="
770             + InterruptDucati.mailboxBaseAddr;
771     }
773     return (defs);
776 /*
777  *  ======== getCFiles ========
778  */
779 function getCFiles(target)
781     var localSources = "";
783     if (BIOS.buildingAppLib == true) {
784         var targetModules = Program.targetModules();
786         for (var m = 0; m < targetModules.length; m++) {
787             var mod = targetModules[m];
788             var mn = mod.$name;
789             var pn = mod.$package.$name;
791             /* determine if this is an ipc package */
792             var packageMatch = false;
794             for (var i = 0; i < ipcPackages.length; i++) {
795                 if (pn == ipcPackages[i]) {
796                     packageMatch = true;
797                     break;
798                 }
799             }
801             if (packageMatch && !mn.match(/Proxy/)) {
802                 localSources += mn.replace(/\./g, "/") + ".c" + " ";
803             }
804         }
806         /* special handling for non-target modules */
807         for (var p in cFiles) {
808             if (p in xdc.om) {
809                 for (var f in cFiles[p].cSources) {
810                     localSources += p.replace(/\./g, "/")
811                             + "/" + cFiles[p].cSources[f] + " ";
812                 }
813             }
814         }
815     }
816     else {
817         localSources += cList[target];
818     }
820     /* remove trailing " " */
821     localSources = localSources.substring(0, localSources.length-1);
823     return (localSources);
826 /*
827  *  ======== getAsmFiles ========
828  */
829 function getAsmFiles(target)
831     return (asmList[target]);
834 /*
835  *  ======== getLibs ========
836  *  This function called by all IPC packages except ti.sdo.ipc package.
837  */
838 function getLibs(pkg)
840     var libPath = "";
841     var name = "";
842     var suffix;
844     switch (Build.libType) {
845         case Build.LibType_Custom:
846         case Build.LibType_Instrumented:
847         case Build.LibType_NonInstrumented:
848         case Build.LibType_Debug:
849             return null;
851         case Build.LibType_PkgLib:
852             throw new Error("internal error: Build.getLibs() called with " +
853                     "incorret context (libType == PkgLib)");
854             break;
856         default:
857             throw new Error("Build.libType not supported: " + Build.libType);
858             break;
859     }
862 /*
863  *  ======== getProfiles ========
864  *  Determines which profiles to build for.
865  *
866  *  Any argument in XDCARGS which does not contain platform= is treated
867  *  as a profile. This way multiple build profiles can be specified by
868  *  separating them with a space.
869  */
870 function getProfiles(xdcArgs)
872     /*
873      * cmdlProf[1] gets matched to "whole_program,debug" if
874      * ["abc", "profile=whole_program,debug"] is passed in as xdcArgs
875      */
876     var cmdlProf = (" " + xdcArgs.join(" ") + " ").match(/ profile=([^ ]+) /);
878     if (cmdlProf == null) {
879         /* No profile=XYZ found */
880         return [];
881     }
883     /* Split "whole_program,debug" into ["whole_program", "debug"] */
884     var profiles = cmdlProf[1].split(',');
886     return profiles;
889 /*
890  *  ======== buildLibs ========
891  *  This function generates the makefile goals for the libraries
892  *  produced by a package.
893  */
894 function buildLibs(objList, relList, filter, xdcArgs)
896     var Build = xdc.useModule('xdc.bld.BuildEnvironment');
898     for (var i = 0; i < Build.targets.length; i++) {
899         var targ = Build.targets[i];
901         /* skip target if not supported */
902         if (!supportsTarget(targ, filter)) {
903             continue;
904         }
906         var profiles = getProfiles(xdcArgs);
908         /* If no profiles were assigned, use only the default one. */
909         if (profiles.length == 0) {
910             profiles[0] = "debug";
911         }
913         for (var j = 0; j < profiles.length; j++) {
914             var ccopts = "";
915             var asmopts = "";
917             if (profiles[j] == "smp") {
918                 var libPath = "lib/smpipc/debug/";
919                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
920                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
921             }
922             else {
923                 var libPath = "lib/ipc/debug/";
924                 /* build all package libs using Hwi macros */
925                 ccopts += " -Dti_sysbios_Build_useHwiMacros";
926                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
927                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
928             }
930             /* confirm that this target supports this profile */
931             if (targ.profiles[profiles[j]] !== undefined) {
932                 var profile = profiles[j];
933                 var lib = Pkg.addLibrary(libPath + Pkg.name,
934                                 targ, {
935                                 profile: profile,
936                                 copts: ccopts,
937                                 aopts: asmopts,
938                                 releases: relList
939                                 });
940                 lib.addObjects(objList);
941             }
942         }
943     }
946 /*
947  *  ======== supportsTarget ========
948  *  Returns true if target is in the filter object. If filter
949  *  is null or empty, that's taken to mean all targets are supported.
950  */
951 function supportsTarget(target, filter)
953     var list, field;
955     if (filter == null) {
956         return true;
957     }
959     /*
960      * For backwards compatibility, we support filter as an array of
961      * target names.  The preferred approach is to specify filter as
962      * an object with 'field' and 'list' elements.
963      *
964      * Old form:
965      *     var trgFilter = [ "Arm9", "Arm9t", "Arm9t_big_endian" ]
966      *
967      * New (preferred) form:
968      *
969      *     var trgFilter = {
970      *         field: "isa",
971      *         list: [ "v5T", "v7R" ]
972      *     };
973      *
974      */
975     if (filter instanceof Array) {
976         list = filter;
977         field = "name";
978     }
979     else {
980         list = filter.list;
981         field = filter.field;
982     }
984     if (list == null || field == null) {
985         throw("invalid filter parameter, must specify list and field!");
986     }
988     if (field == "noIsa") {
989         if (String(','+list.toString()+',').match(','+target["isa"]+',')) {
990             return (false);
991         }
992         return (true);
993     }
995     /*
996      * add ',' at front and and tail of list and field strings to allow
997      * use of simple match API.  For example, the string is updated to:
998      * ',v5T,v7R,' to allow match of ',v5t,'.
999      */
1000     if (String(','+list.toString()+',').match(','+target[field]+',')) {
1001         return (true);
1002     }
1004     return (false);
1007 /*
1008  *  ======== _setLibType ========
1009  *  The "real-time" setter setLibType function
1010  *  This function is called whenever libType changes.
1011  */
1012 function _setLibType(field, val)
1014     var Build = this;
1016     if (val == Build.LibType_Instrumented) {
1017         Build.assertsEnabled = true;
1018         Build.logsEnabled = true;
1019     }
1020     else if (val == Build.LibType_NonInstrumented) {
1021         Build.assertsEnabled = false;
1022         Build.logsEnabled = false;
1023     }
1024     else if (val == Build.LibType_Custom) {
1025         Build.assertsEnabled = true;
1026         Build.logsEnabled = true;
1027     }
1028     else if (val == Build.LibType_Debug) {
1029         Build.assertsEnabled = true;
1030         Build.logsEnabled = true;
1031     }
1032     else if (val == Build.LibType_PkgLib) {
1033         Build.assertsEnabled = true;
1034         Build.logsEnabled = true;
1035     }
1036     else {
1037         print(Build.$name + ": unknown libType setting: " + val);
1038     }
1040     /* re-construct default Build.customCCOpts */
1041     Build.customCCOpts = Build.getDefaultCustomCCOpts();