]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - packages/ti/sdo/ipc/build/common.bld
Rename: git mv src packages to complete application of ipc-j patches to ipcdev.
[ipc/ipcdev.git] / packages / ti / sdo / ipc / build / common.bld
1 /*
2  * Copyright (c) 2012-2013, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  *  ======== common.bld ========
34  *
35  */
38 /*
39  *  ======== getProfiles ========
40  *  Determines which profiles to build for.
41  *
42  *  Any argument in XDCARGS which does not contain platform= is treated
43  *  as a profile. This way multiple build profiles can be specified by
44  *  separating them with a space.
45  */
46 function getProfiles(xdcArgs)
47 {
48     /*
49      * cmdlProf[1] gets matched to "whole_program,debug" if
50      * ["abc", "profile=whole_program,debug"] is passed in as xdcArgs
51      */
52     var cmdlProf = (" " + xdcArgs.join(" ") + " ").match(/ profile=([^ ]+) /);
55     if (cmdlProf == null) {
56         /* No profile=XYZ found */
57         return [];
58     }
60     /* Split "whole_program,debug" into ["whole_program", "debug"] */
61     var profiles = cmdlProf[1].split(',');
63     return profiles;
64 }
66 /*
67  *  ======== buildLibs ========
68  *  This function generates the makefile goals for the libraries
69  *  produced by a ti.sysbios package.
70  */
71 function buildLibs(objList, relList, filter, xdcArgs)
72 {
73     var ccopts = "";
74     var asmopts = "";
76     for (var i = 0; i < Build.targets.length; i++) {
77         var targ = Build.targets[i];
79         /* skip target if not supported */
80         if (!supportsTarget(targ, filter)) {
81             continue;
82         }
84         var profiles = getProfiles(xdcArgs);
86         /* If no profiles were assigned, use only the default one. */
87         if (profiles.length == 0) {
88             profiles[0] = "debug";
89         }
91         for (var j = 0; j < profiles.length; j++) {
93             if (profiles[j] == "smp") {
94                 var libPath = "lib/smpipc/debug/";
95                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
96                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=TRUE";
97             }
98             else {
99                 var libPath = "lib/ipc/debug/";
100                 /* build all package libs using Hwi macros */
101                 ccopts += " -Dti_sysbios_Build_useHwiMacros";
102                 ccopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
103                 asmopts += " -Dti_sysbios_BIOS_smpEnabled__D=FALSE";
104             }
106             /* confirm that this target supports this profile */
107             if (targ.profiles[profiles[j]] !== undefined) {
108                 var profile = profiles[j];
109                 var lib = Pkg.addLibrary(libPath + Pkg.name,
110                                 targ, {
111                                 profile: profile,
112                                 copts: ccopts,
113                                 aopts: asmopts,
114                                 releases: relList
115                                 });
116                 lib.addObjects(objList);
117             }
118         }
119     }
123 /*
124  *  ======== supportsTarget ========
125  *  Returns true if target is in the filter object. If filter
126  *  is null or empty, that's taken to mean all targets are supported.
127  */
128 function supportsTarget(target, filter)
130     var list, field;
132     if (filter == null) {
133         return true;
134     }
136     /*
137      * For backwards compatibility, we support filter as an array of
138      * target names.  The preferred approach is to specify filter as
139      * an object with 'field' and 'list' elements.
140      *
141      * Old form:
142      *     var trgFilter = [ "Arm9", "Arm9t", "Arm9t_big_endian" ]
143      *
144      * New (preferred) form:
145      *
146      *     var trgFilter = {
147      *         field: "isa",
148      *         list: [ "v5T", "v7R" ]
149      *     };
150      *
151      */
152     if (filter instanceof Array) {
153         list = filter;
154         field = "name";
155     }
156     else {
157         list = filter.list;
158         field = filter.field;
159     }
161     if (list == null || field == null) {
162         throw("invalid filter parameter, must specify list and field!");
163     }
165     if (field == "noIsa") {
166         if (String(','+list.toString()+',').match(','+target["isa"]+',')) {
167             return (false);
168         }
169         return (true);
170     }
172     /*
173      * add ',' at front and and tail of list and field strings to allow
174      * use of simple match API.  For example, the string is updated to:
175      * ',v5T,v7R,' to allow match of ',v5t,'.
176      */
177     if (String(','+list.toString()+',').match(','+target[field]+',')) {
178         return (true);
179     }
181     return (false);