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