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

Function parse_dependency_file

ci/wasm_compile_pch.py:120–202  ·  view source on GitHub ↗

Parse a .d dependency file and extract all dependency paths. Args: depfile: Path to .d dependency file Returns: List of dependency file paths (excluding the target itself)

(depfile: Path)

Source from the content-addressed store, hash-verified

118
119
120def parse_dependency_file(depfile: Path) -> list[Path]:
121 """
122 Parse a .d dependency file and extract all dependency paths.
123
124 Args:
125 depfile: Path to .d dependency file
126
127 Returns:
128 List of dependency file paths (excluding the target itself)
129 """
130 if not depfile.exists():
131 return []
132
133 try:
134 with open(depfile, "r", encoding="utf-8") as f:
135 lines = f.readlines()
136
137 # Dependency files have format: target: dep1 dep2 dep3 \
138 # dep4 dep5 ...
139 # The first line contains "target: [optional deps] \"
140 # Subsequent lines contain more dependencies
141
142 if not lines:
143 return []
144
145 # Parse first line to get target
146 first_line = lines[0].rstrip("\r\n")
147
148 # Find the separator ": " or ":\\" in the first line
149 # (target paths may contain colons on Windows, e.g., C:/path)
150 # Look for ": " pattern which separates target from deps
151 sep_idx = first_line.find(": ")
152 if sep_idx == -1:
153 # Try ":\" pattern (no space before backslash)
154 sep_idx = first_line.find(":\\")
155 if sep_idx == -1:
156 return []
157 sep_len = 2 # Length of ":\\"
158 else:
159 sep_len = 2 # Length of ": "
160
161 target_str = first_line[:sep_idx]
162 target = Path(target_str.strip()).resolve()
163
164 # Collect all dependency text from continuation lines
165 # Line format: each line ends with " \" except the last one
166 deps_text = first_line[sep_idx + sep_len :].rstrip()
167
168 # Remove trailing backslash if present (line continuation)
169 if deps_text.endswith("\\"):
170 deps_text = deps_text[:-1]
171
172 # Process continuation lines
173 for line in lines[1:]:
174 line_clean = line.rstrip("\r\n").strip()
175 # Remove trailing backslash if present
176 if line_clean.endswith("\\"):
177 line_clean = line_clean[:-1].strip()

Callers 1

Calls 5

printFunction · 0.50
findMethod · 0.45
resolveMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected