collab/mm20

git clone https://git.julia.blue/collab/mm20

Allen Jiangmodify codeed897ff

firmware
8.7 KiB268 linesraw
1/*
2 *  ======== package/cfg/gpiointerrupt_pem4f.cfg ========
3 *  This generated configuration script runs the user's configuration script
4 *  the context of a specific target and platform in order to generate
5 *  all the files necessary to create an executable; e.g., linker command
6 *  files, static C/C++ data structures, etc.
7 */
8
9/*
10 *  ======== _applyChanges ========
11 *  Changes that bring the build target to the state at the end of the build
12 *  model
13 */
14function _applyChanges(obj, chgObj) {
15    var wasSealed = false;
16    if (obj.$sealed) {
17        wasSealed = true;
18        obj.$unseal();
19    }
20    for (var prop in chgObj) {
21        if (typeof obj[prop] == 'object' && obj[prop] != undefined) {
22            if ("$category" in obj[prop] && obj[prop].$category == "Vector") {
23               obj[prop].length = chgObj[prop].length;
24               for (var i = 0; i < chgObj[prop].length; i++) {
25                   if (obj[prop].length < i + 1) {
26                       obj[prop].length++;
27                   }
28                   obj[prop][i] = chgObj[prop][i];
29               }
30            }
31            else {
32        	_applyChanges(obj[prop], chgObj[prop]);
33            }
34	}
35	else {
36            obj[prop] = chgObj[prop];
37	}
38    }
39    if (wasSealed) {
40        obj.$seal();
41    }
42}
43
44/*
45 *  ======== _runescape ========
46 *  Recursive unescape to decode serialized strings
47 */
48function _runescape(obj) {
49    for (var i in obj) {
50	if (obj[i] != null) {
51	    if (typeof obj[i] == 'string') {
52		obj[i] = unescape(obj[i]);
53	    }
54	    else if (typeof obj[i] == 'object') {
55		_runescape(obj[i]);
56	    }
57	}
58    }
59}
60
61/*
62 *  ======== _getPlatCfg ========
63 */
64function _getPlatCfg() {
65    var tmp = {};
66    _runescape(tmp);
67    return (tmp);
68}
69/*
70 *  ======== _cfginit ========
71 */
72function _cfginit() {
73    xdc.loadPackage('xdc.services.intern.cmd');
74    var prog = xdc.om['xdc.cfg.Program'];
75
76    /* initialize prog attrs from build model */
77    var build = {
78        profile: "release",
79        cfgScript: "C%3A/Users/Allen/Documents/GitHub/mm20/CCS/mm/gpiointerrupt.cfg",
80        cfgHome: "configPkg",
81        cfgArgs: "null",
82        cfgArgsEncoded: true,
83        releases: {
84            0: {
85                name: "configPkg",
86                attrs: {
87                    prefix: "",
88                    label: "default"
89                },
90                otherFiles: {},
91                excludeDirs: {}
92            }
93        },
94        prelink: false
95    };
96    _runescape(build);
97    build.cfgArgs = null;
98    build.target = xdc.module("ti.targets.arm.elf.M4F");
99    var targChange = {
100        platforms: [
101            "ti.platforms.tiva%3ATM4C1294NCPDT%3A1"
102        ],
103        version: "ti.targets.arm.elf.M4F%7B1%2C0%2C18.12%2C4",
104        extensions: {
105            ".sem4fe": {
106                suf: ".sem4fe",
107                typ: "asm"
108            },
109            ".sem4f": {
110                suf: ".sem4f",
111                typ: "asm"
112            },
113            ".sv7M4": {
114                suf: ".sv7M4",
115                typ: "asm"
116            },
117            ".sv7M": {
118                suf: ".sv7M",
119                typ: "asm"
120            }
121        },
122        rootDir: "C%3A/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS",
123        ccOpts: {
124            prefix: "-mv7M4%20--code_state%3D16%20--float_support%3DFPv4SPD16%20-me%20--include_path%3D%22C%3A/Users/Allen/Documents/GitHub/mm20/CCS/mm%22%20--include_path%3D%22C%3A/Users/Allen/Documents/GitHub/mm20/CCS/mm/inc%22%20--include_path%3D%22C%3A/Users/Allen/Documents/GitHub/mm20/CCS/mm%22%20--include_path%3D%22C%3A/ti/tirtos_tivac_2_16_00_08/products/TivaWare_C_Series-2.1.1.71b%22%20--include_path%3D%22C%3A/ti/tirtos_tivac_2_16_00_08/products/bios_6_45_01_29/packages/ti/sysbios/posix%22%20--include_path%3D%22C%3A/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include%22%20--define%3Dccs%3D%22ccs%22%20--define%3DPART_TM4C123GH6PM%20--define%3Dccs%20--define%3DTIVAWARE%20-g%20--c99%20--gcc%20--diag_warning%3D225%20--diag_warning%3D255%20--diag_wrap%3Doff%20--display_error_number%20--gen_func_subsections%3Don%20--abi%3Deabi%20%20%20-qq%20-pdsw225"
125        },
126        rawVersion: "18.12.4"
127    };
128    _runescape(targChange);
129    _applyChanges(build.target, targChange);
130
131    prog.build = build;
132
133    prog.name = "gpiointerrupt.xem4f";
134    prog.cfgBase = "package/cfg/gpiointerrupt_pem4f";
135
136    prog.endian = prog.build.target.model.endian;
137    prog.codeModel = prog.build.target.model.codeModel;
138
139    /* use the platform package's Platform module */
140    var Platform = xdc.useModule("ti.platforms.tiva.Platform");
141    var platParams = _getPlatCfg();
142    var invalidParams = [];
143    for (var prop in platParams) {
144        if (!(prop in Platform.PARAMS)) {
145            delete platParams[prop];
146            invalidParams.push(prop);
147        }
148    }
149    prog.platformName = "ti.platforms.tiva:TM4C123GH6PM";
150    prog.platform = Platform.create("TM4C123GH6PM", platParams);
151    for (var i = 0; i < invalidParams.length; i++) {
152        Platform.$logWarning("The parameter '" + invalidParams[i] + "' is " +
153            "passed to this platform instance through Build.platformTable, " +
154            "but the instance does not have a configuration parameter with " +
155            "that name.", prog.platform, "TM4C123GH6PM");
156    }
157
158    /* record the executable's package name */
159    prog.buildPackage = "configPkg";
160
161    /* record build-model information required during config generation */
162    prog.$$bind("$$isasm", 0);
163    prog.$$bind("$$isrom", 0);
164    prog.$$bind("$$gentab", [
165    ]);
166
167    /* bind prog to an appropriate execution context */
168    prog.cpu = prog.platform.getExeContext(prog);
169
170    /* import the target's run-time support pkg */
171    xdc.loadPackage("ti.targets.arm.rtsarm");
172}
173
174/* function to import the cfg script's package */
175function _userscript(script) {
176    var home;
177    var spath;
178    home = xdc.loadPackage("configPkg");
179
180    xdc.om.$$bind('$homepkg', home);
181
182    var cfgScript = "C:/Users/Allen/Documents/GitHub/mm20/CCS/mm/gpiointerrupt.cfg";
183    if (!script) {
184        utils.loadCapsule(cfgScript, false, spath);
185    }
186    else {
187        /* set up the same environment that loadCapsule would */
188        var $saveCsd = utils.csd;
189        var $cfgFile = utils.findFile(cfgScript, spath);
190        var cname = cfgScript;
191        if ($cfgFile) {
192            $cfgFile = java.io.File($cfgFile);
193            utils.csd = $cfgFile.getParentFile().getCanonicalPath();
194            cname = "" + $cfgFile.getCanonicalPath();
195        }
196
197        /* create the capsule object */
198        var cap = {
199            prototype:  utils.global,
200            $path:      cname,
201            $private:   {path: cname},
202            $capsule:   undefined,      /* set to cap below */
203        };
204
205        /* 'this.$capsule' is always cap object */
206        cap.$capsule = cap;
207
208        /* save the capsule object */
209        utils.$$capmap[cname] = cap;
210
211        try {
212            var cx =
213                Packages.org.mozilla.javascript.Context.getCurrentContext();
214            var rdr = new
215                java.io.BufferedReader(new java.io.StringReader(script));
216            Packages.config.Shell.evaluateLoad(cx, cap, rdr, cname, 1);
217        }
218        finally {
219            rdr.close();
220            utils.csd = $saveCsd;
221        }
222    }
223}
224
225function _postinit() {
226    var cout = null;
227
228    var Program = xdc.om['xdc.cfg.Program'];
229    /* get the exec command for this executable */
230    if (Program.execCmd == null) {
231        Program.execCmd = Program.platform.getExecCmd(Program,
232            xdc.om["ti.platforms.tiva"].packageBase);
233    }
234    cout = "define EXEC." + Program.name + '\n\n';
235    cout += Program.execCmd;
236    cout += "\nendef\n\n";
237
238    /* if SourceDir generates a makefile, we need to run it */
239    _genSourceDirMak("package/cfg/gpiointerrupt_pem4f", "gpiointerrupt.pem4f");
240
241    utils.genDep("package/cfg/gpiointerrupt_pem4f", "configPkg", utils.loadedFiles, cout, null);
242}
243
244function _genSourceDirMak(cfgBase, cfgName)
245{
246    var SourceDir = xdc.om['xdc.cfg.SourceDir'];
247
248    if (SourceDir && SourceDir.$instances.length > 0) {
249        /* construct rule to run SourceDir generated makefile */
250        var make = "\t$(MAKE) -f "
251            + SourceDir.outputDir + "/" + SourceDir.makefileName;
252
253        /* this file is included by package.mak (if it exists) */
254        var file = new java.io.File(cfgBase + ".cfg.mak");
255        file["delete"]();
256        var out = new java.io.BufferedWriter(new java.io.FileWriter(file));
257
258        /* add rules to run SourceDir generated makefile */
259        out.write("# invoke SourceDir generated makefile for " + cfgName
260            + "\n" + cfgName + ": .libraries," + cfgName
261            + "\n.libraries," + cfgName + ": " + cfgBase + ".xdl\n"
262            + make + "\n\n"
263            + "clean::\n" + make + " clean\n\n"
264        );
265        out.close();
266        out = null;
267    }
268}