MCPcopy Create free account
hub / github.com/FastLED/FastLED / _normalize_include

Function _normalize_include

ci/check_backend_flag_drift.py:169–209  ·  view source on GitHub ↗

Make include paths comparable across the two backend cache roots. fbuild stores frameworks under ``~/.fbuild/prod/cache/platforms/<...>/`` while PIO stores them under ``~/.platformio/packages/<...>/``. Both eventually point at e.g. ``framework-arduinoteensy/cores/teensy4``. We strip

(path: str)

Source from the content-addressed store, hash-verified

167
168
169def _normalize_include(path: str) -> str:
170 """Make include paths comparable across the two backend cache roots.
171
172 fbuild stores frameworks under ``~/.fbuild/prod/cache/platforms/<...>/``
173 while PIO stores them under ``~/.platformio/packages/<...>/``. Both
174 eventually point at e.g. ``framework-arduinoteensy/cores/teensy4``. We
175 strip everything up to and including a known cache-root marker so two
176 paths that resolve to the same logical directory compare equal.
177 """
178 normalized = path.replace("\\", "/").rstrip("/")
179
180 # Markers in preference order. Whatever lives *after* the marker is the
181 # framework-relative subpath that actually matters for drift detection.
182 cache_markers = (
183 "/.fbuild/prod/cache/platforms/",
184 "/.fbuild/cache/platforms/",
185 "/.platformio/packages/",
186 "/.platformio/lib/",
187 )
188 for marker in cache_markers:
189 idx = normalized.rfind(marker)
190 if idx != -1:
191 tail = normalized[idx + len(marker) :]
192 # Drop the first path component (e.g. "framework-arduinoteensy"
193 # or a long fbuild hash like "dl-framework-arduinoteensy-1.160.0/<hash>/1.160.0").
194 # We keep only what's after the first '/cores/' or '/libraries/'
195 # since those are the meaningful directories.
196 for keep in ("/cores/", "/libraries/", "/variants/", "/tools/"):
197 k = tail.find(keep)
198 if k != -1:
199 return tail[k:].lstrip("/")
200 return tail
201
202 # Repo-relative paths: strip the repo prefix when present so two clones in
203 # different parent dirs still compare equal.
204 for marker in ("/fastled5/", "/FastLED/", "/.build/pio/"):
205 idx = normalized.rfind(marker)
206 if idx != -1:
207 return normalized[idx + len(marker) :]
208
209 return normalized
210
211
212def _normalize_flag(flag: str) -> str:

Callers 1

normalize_build_infoFunction · 0.85

Calls 2

rfindMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected