MCPcopy Index your code
hub / github.com/Moddable-OpenSource/moddable / run

Method run

tools/mcdevicetree.js:113–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111 }
112
113 run() {
114 let dts = String.fromArrayBuffer(this.readFileBuffer(this.sourcePath));
115 dts = dts.replace(/\/\*[\s\S]*?\*\//g, '') // Remove block comments
116 .replace(/[ \t]+/g, ' ') // Normalize whitespace
117 .replace(/\n\s*\n\s*/g, '\n'); // Remove extra blank lines
118
119 const parser = new DTSParser();
120 const parsed = parser.parse(dts);
121
122 const compatible = new Map;
123 const bindingDirectory = this.resolveDirectoryPath(this.getenv("ZEPHYR_BASE") + "/dts/bindings");
124 for (const kind of this.enumerateDirectory(bindingDirectory)) {
125 if ("." === kind.startsWith("."))
126 continue;
127 if (this.isDirectoryOrFile(bindingDirectory + "/" + kind) >= 0)
128 continue;
129 compatible.set(kind, this.enumerateDirectory(bindingDirectory + "/" + kind).filter(name => {
130 if (name.startsWith("."))
131 return;
132 if (!name.includes(","))
133 return;
134
135 if ("st,dsi-lcd-qsh-030.yaml" === name) //@@ hack so stm32u5a9j_dk links
136 return;
137 if (("nordic,nrf-gpio-forwarder.yaml" === name) || ("nordic,nrf-gpiote.yaml" === name)) //@@ hack so raytac_mdbt53 links
138 return;
139 if ("arduino,uno-adc.yaml" === name) //@@ hack so nrf52840dk links
140 return;
141 if (("raspberrypi,pico-gpio.yaml" === name) || ("raspberrypi,pico-header.yaml" === name)) //@@ hack so pico_plus2 links
142 return;
143
144 return name.endsWith(".yaml");
145 }).map(name => name.substring(0, name.length - 5)));
146 }
147
148 const state = {
149 cCode: "",
150 hCode: "",
151 jsCode: "",
152 tsCode: "",
153 aliasTable: new Map,
154 zephyrConfig: this.zephyrConfig,
155 defines: this.defines,
156 compatible
157 };
158
159 state.hCode +=
160`#ifndef __MC_ZEPHYR_H__
161#define __MC_ZEPHYR_H__
162
163`;
164
165 state.cCode +=
166`#include "./mc.devicetree.h"
167#include <zephyr/device.h>
168#include "xsHost.h"
169#include "mc.defines.h"
170

Callers

nothing calls this directly

Calls 15

parseMethod · 0.95
doAliasesFunction · 0.85
doGPIOBanksFunction · 0.85
doGPIOsFunction · 0.85
doBusFunction · 0.85
doNetworkInterfacesFunction · 0.85
doFileSystemsFunction · 0.85
doFlashFunction · 0.85
doKeyValueFunction · 0.85
replaceMethod · 0.80
mapMethod · 0.80
fromArrayBufferMethod · 0.65

Tested by

no test coverage detected