MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / generateConfigurationRules

Method generateConfigurationRules

tools/mcmanifest.js:201–454  ·  view source on GitHub ↗
(tool)

Source from the content-addressed store, hash-verified

199 return { sdkconfig, changed };
200 }
201 generateConfigurationRules(tool) {
202 if ("esp32" !== tool.platform)
203 return;
204
205 if (!tool.environment.SDKCONFIGPATH)
206 return; // mcrun
207
208 const ESP32_SUBCLASS = tool.environment.ESP32_SUBCLASS ?? "esp32";
209 const baseConfigDirectory = tool.buildPath + tool.slash + "devices" + tool.slash + "esp32" + tool.slash + "xsProj-" + ESP32_SUBCLASS;
210 const outputConfigDirectory = tool.outputPath + tool.slash + "tmp" + tool.slash + "esp32" + tool.slash + (tool.subplatform ?? "") + tool.slash + (tool.debug ? "debug" : (tool.instrument ? "instrument" : "release")) + tool.slash + tool.environment.NAME + tool.slash + "xsProj-" + ESP32_SUBCLASS;
211 tool.createDirectory(outputConfigDirectory);
212
213 let PARTITIONS_FILE = tool.environment.PARTITIONS_FILE ?? tool.environment.PARTITIONS_FILE_FOR_TARGET;
214 if (!PARTITIONS_FILE) {
215 const PROJ_DIR_TEMPLATE = `${tool.buildPath}/devices/esp32/xsProj-${tool.environment.ESP32_SUBCLASS}`;
216 PARTITIONS_FILE = `${PROJ_DIR_TEMPLATE}/partitions.csv`
217 }
218 let partitions = tool.readFileString(PARTITIONS_FILE);
219
220 const usesMods = tool.defines.xs?.mods || tool.defines.XS_MODS;
221 const wantsTest = tool.defines.xs?.test || tool.defines.XS_TEST
222 const wantsOTA = tool.defines.ota?.autosplit;
223 const wantsStorage = tool.defines.file?.partition;
224
225 if (wantsOTA || usesMods || wantsStorage || wantsTest) {
226 let factoryLine, hasOTA, hasMod, hasStorage, storagePartition = wantsStorage?.slice(1);
227
228 function parse(value) {
229 if (value.startsWith("0x"))
230 return parseInt(value, 16);
231 if (value.endsWith("K"))
232 return parseInt(value) * 1024;
233 if (value.endsWith("M"))
234 return parseInt(value) * 1024 * 1024;
235 return parseInt(value);
236 }
237
238 partitions = partitions.split("\n");
239 for (let i = 0; i < partitions.length; i++) {
240 let line = partitions[i].trim();
241 if (!line || line.startsWith("#")) continue;
242
243 line = line.split(",").map(item => item.trim());
244 if ("app" === line[1]) {
245 const kind = line[2].toLowerCase();
246 if (kind.startsWith("ota"))
247 hasOTA = true;
248 else if ("factory" === kind)
249 factoryLine = i;
250 }
251 else if (("xs" === line[0]) && (("data" === line[1]) || (64 === parse(line[1]))))
252 hasMod = true;
253 else if ((storagePartition === line[0]) && ("data" === line[1]))
254 hasStorage = true;
255 }
256
257 if (undefined !== factoryLine) {
258 const OTADATA_SIZE = 0x2000;

Callers 1

generateRulesMethod · 0.95

Calls 12

setConfigOptionMethod · 0.95
mapMethod · 0.80
idivMethod · 0.80
reportMethod · 0.80
replaceMethod · 0.80
sliceMethod · 0.65
concatMethod · 0.65
parseFunction · 0.50
createDirectoryMethod · 0.45
toStringMethod · 0.45
lineMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected