]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - packages/ti/sdo/ipc/Build.xs
Build.xs: Cleanup item identified
[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             if (!Program.build.target.$name.match(/A53F/)) {
703                 /* add in stack frames for stack back trace */
704                 customCCOpts += " -mapcs-frame ";
705             }
706         }
707         else {
708             customCCOpts = customCCOpts.replace(" -o3","");
709             customCCOpts = customCCOpts.replace(" --optimize_with_debug","");
710             if (Program.build.target.$name.match(/arm/)) {
711                 customCCOpts = customCCOpts.replace(" --opt_for_speed=2","");
712             }
713         }
714     }
716     return (customCCOpts);
719 /*
720  *  ======== getDefs ========
721  */
722 function getDefs()
724     var Defaults = xdc.module('xdc.runtime.Defaults');
725     var Diags = xdc.module("xdc.runtime.Diags");
726     var BIOS = xdc.module("ti.sysbios.BIOS");
727     var MessageQ = xdc.module("ti.sdo.ipc.MessageQ");
729     var defs = "";
731     if ((Build.assertsEnabled == false) ||
732         ((Defaults.common$.diags_ASSERT == Diags.ALWAYS_OFF)
733             && (Defaults.common$.diags_INTERNAL == Diags.ALWAYS_OFF))) {
734         defs += " -Dxdc_runtime_Assert_DISABLE_ALL";
735     }
737     if (Build.logsEnabled == false) {
738         defs += " -Dxdc_runtime_Log_DISABLE_ALL";
739     }
741     defs += " -Dti_sdo_ipc_MessageQ_traceFlag__D=" +
742             (MessageQ.traceFlag ? "TRUE" : "FALSE");
744     if ("ti.ipc.ipcmgr.IpcMgr" in xdc.om) {
745         defs += xdc.module("ti.ipc.ipcmgr.IpcMgr").getDefs();
746     }
748     if ("ti.ipc.rpmsg" in xdc.om) {
749         defs += xdc.module('ti.ipc.rpmsg.Build').getDefs();
750     }
752     /* TODO: Need to clean up : Why is InterruptDucati added here which is platform specific */
753     var InterruptDucati =
754             xdc.module("ti.sdo.ipc.family.ti81xx.InterruptDucati");
756     /* If we truely know which platform we're building against,
757      * add these application specific -D's
758      */
759     if (BIOS.buildingAppLib == true) {
760         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_videoProcId__D="
761                 + InterruptDucati.videoProcId;
762         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_hostProcId__D="
763                 + InterruptDucati.hostProcId;
764         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_vpssProcId__D="
765                 + InterruptDucati.vpssProcId;
766         defs += " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_dspProcId__D="
767                 + InterruptDucati.dspProcId;
768         defs +=
769             " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_ducatiCtrlBaseAddr__D="
770             + InterruptDucati.ducatiCtrlBaseAddr;
771         defs +=
772             " -Dti_sdo_ipc_family_ti81xx_InterruptDucati_mailboxBaseAddr__D="
773             + InterruptDucati.mailboxBaseAddr;
774     }
776     return (defs);
779 /*
780  *  ======== getCFiles ========
781  */
782 function getCFiles(target)
784     var localSources = "";
786     if (BIOS.buildingAppLib == true) {
787         var targetModules = Program.targetModules();
789         for (var m = 0; m < targetModules.length; m++) {
790             var mod = targetModules[m];
791             var mn = mod.$name;
792             var pn = mod.$package.$name;
794             /* determine if this is an ipc package */
795             var packageMatch = false;
797             for (var i = 0; i < ipcPackages.length; i++) {
798                 if (pn == ipcPackages[i]) {
799                     packageMatch = true;
800                     break;
801                 }
802             }
804             if (packageMatch && !mn.match(/Proxy/)) {
805                 localSources += mn.replace(/\./g, "/") + ".c" + " ";
806             }
807         }
809         /* special handling for non-target modules */
810         for (var p in cFiles) {
811             if (p in xdc.om) {
812                 for (var f in cFiles[p].cSources) {
813                     localSources += p.replace(/\./g, "/")
814                             + "/" + cFiles[p].cSources[f] + " ";
815                 }
816             }
817         }
818     }
819     else {
820         localSources += cList[target];
821     }
823     /* remove trailing " " */
824     localSources = localSources.substring(0, localSources.length-1);
826     return (localSources);
829 /*
830  *  ======== getAsmFiles ========
831  */
832 function getAsmFiles(target)
834     return (asmList[target]);
837 /*
838  *  ======== getLibs ========
839  *  This function called by all IPC packages except ti.sdo.ipc package.
840  */
841 function getLibs(pkg)
843     var libPath = "";
844     var name = "";
845     var suffix;
847     switch (Build.libType) {
848         case Build.LibType_Custom:
849         case Build.LibType_Instrumented:
850         case Build.LibType_NonInstrumented:
851         case Build.LibType_Debug:
852             return null;
854         case Build.LibType_PkgLib:
855             throw new Error("internal error: Build.getLibs() called with " +
856                     "incorret context (libType == PkgLib)");
857             break;
859         default:
860             throw new Error("Build.libType not supported: " + Build.libType);
861             break;
862     }
865 /*
866  *  ======== getProfiles ========
867  *  Determines which profiles to build for.
868  *
869  *  Any argument in XDCARGS which does not contain platform= is treated
870  *  as a profile. This way multiple build profiles can be specified by
871  *  separating them with a space.
872  */
873 function getProfiles(xdcArgs)
875     /*
876      * cmdlProf[1] gets matched to "whole_program,debug" if
877      * ["abc", "profile=whole_program,debug"] is passed in as xdcArgs
878      */
879     var cmdlProf = (" " + xdcArgs.join(" ") + " ").match(/ profile=([^ ]+) /);
881     if (cmdlProf == null) {
882         /* No profile=XYZ found */
883         return [];
884     }
886     /* Split "whole_program,debug" into ["whole_program", "debug"] */
887     var profiles = cmdlProf[1].split(',');
889     return profiles;
892 /*
893  *  ======== buildLibs ========
894  *  This function generates the makefile goals for the libraries
895  *  produced by a package.
896  */
897 function buildLibs(objList, relList, filter, xdcArgs)
899     var Build = xdc.useModule('xdc.bld.BuildEnvironment');
901     for (var i = 0; i < Build.targets.length; i++) {
902         var targ = Build.targets[i];
904         /* skip target if not supported */
905         if (!supportsTarget(targ, filter)) {
906             continue;
907         }
909         var profiles = getProfiles(xdcArgs);
911         /* If no profiles were assigned, use only the default one. */
912         if (profiles.length == 0) {
913             profiles[0] = "debug";
914         }
916         for (var j = 0; j < profiles.length; j++) {
917             var ccopts = "";
918             var asmopts = "";
920             if (profiles[j] == "smp") {
921                 var libPath = "lib/smpipc/debug/";
922                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
923                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
924             }
925             else {
926                 var libPath = "lib/ipc/debug/";
927                 /* build all package libs using Hwi macros */
928                 ccopts += " -Dti_sysbios_Build_useHwiMacros";
929                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
930                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
931             }
933             /* confirm that this target supports this profile */
934             if (targ.profiles[profiles[j]] !== undefined) {
935                 var profile = profiles[j];
936                 var lib = Pkg.addLibrary(libPath + Pkg.name,
937                                 targ, {
938                                 profile: profile,
939                                 copts: ccopts,
940                                 aopts: asmopts,
941                                 releases: relList
942                                 });
943                 lib.addObjects(objList);
944             }
945         }
946     }
949 /*
950  *  ======== supportsTarget ========
951  *  Returns true if target is in the filter object. If filter
952  *  is null or empty, that's taken to mean all targets are supported.
953  */
954 function supportsTarget(target, filter)
956     var list, field;
958     if (filter == null) {
959         return true;
960     }
962     /*
963      * For backwards compatibility, we support filter as an array of
964      * target names.  The preferred approach is to specify filter as
965      * an object with 'field' and 'list' elements.
966      *
967      * Old form:
968      *     var trgFilter = [ "Arm9", "Arm9t", "Arm9t_big_endian" ]
969      *
970      * New (preferred) form:
971      *
972      *     var trgFilter = {
973      *         field: "isa",
974      *         list: [ "v5T", "v7R" ]
975      *     };
976      *
977      */
978     if (filter instanceof Array) {
979         list = filter;
980         field = "name";
981     }
982     else {
983         list = filter.list;
984         field = filter.field;
985     }
987     if (list == null || field == null) {
988         throw("invalid filter parameter, must specify list and field!");
989     }
991     if (field == "noIsa") {
992         if (String(','+list.toString()+',').match(','+target["isa"]+',')) {
993             return (false);
994         }
995         return (true);
996     }
998     /*
999      * add ',' at front and and tail of list and field strings to allow
1000      * use of simple match API.  For example, the string is updated to:
1001      * ',v5T,v7R,' to allow match of ',v5t,'.
1002      */
1003     if (String(','+list.toString()+',').match(','+target[field]+',')) {
1004         return (true);
1005     }
1007     return (false);
1010 /*
1011  *  ======== _setLibType ========
1012  *  The "real-time" setter setLibType function
1013  *  This function is called whenever libType changes.
1014  */
1015 function _setLibType(field, val)
1017     var Build = this;
1019     if (val == Build.LibType_Instrumented) {
1020         Build.assertsEnabled = true;
1021         Build.logsEnabled = true;
1022     }
1023     else if (val == Build.LibType_NonInstrumented) {
1024         Build.assertsEnabled = false;
1025         Build.logsEnabled = false;
1026     }
1027     else if (val == Build.LibType_Custom) {
1028         Build.assertsEnabled = true;
1029         Build.logsEnabled = true;
1030     }
1031     else if (val == Build.LibType_Debug) {
1032         Build.assertsEnabled = true;
1033         Build.logsEnabled = true;
1034     }
1035     else if (val == Build.LibType_PkgLib) {
1036         Build.assertsEnabled = true;
1037         Build.logsEnabled = true;
1038     }
1039     else {
1040         print(Build.$name + ": unknown libType setting: " + val);
1041     }
1043     /* re-construct default Build.customCCOpts */
1044     Build.customCCOpts = Build.getDefaultCustomCCOpts();