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

Function compile_object

ci/wasm_compile_native.py:160–224  ·  view source on GitHub ↗

Compile a single source file to an object file using PCH. Args: source_file: Source .cpp file to compile output_object: Output .o file path emcc: Compiler command (e.g., 'clang-tool-chain-emcc') flags: Build flags dictionary verbose: Enable verbose o

(
    source_file: Path,
    output_object: Path,
    emcc: str,
    flags: dict[str, list[str]],
    verbose: bool = False,
    force: bool = False,
)

Source from the content-addressed store, hash-verified

158
159
160def compile_object(
161 source_file: Path,
162 output_object: Path,
163 emcc: str,
164 flags: dict[str, list[str]],
165 verbose: bool = False,
166 force: bool = False,
167) -> bool:
168 """
169 Compile a single source file to an object file using PCH.
170
171 Args:
172 source_file: Source .cpp file to compile
173 output_object: Output .o file path
174 emcc: Compiler command (e.g., 'clang-tool-chain-emcc')
175 flags: Build flags dictionary
176 verbose: Enable verbose output
177 force: Force recompilation even if up-to-date
178
179 Returns:
180 True if successful
181 """
182 # Check if compilation is needed
183 if not force and not needs_compilation(source_file, output_object):
184 if verbose:
185 print(f"✓ {source_file.name} is up-to-date")
186 return True
187
188 # Build includes
189 includes = [
190 "-Isrc",
191 "-Isrc/platforms/wasm",
192 "-Isrc/platforms/wasm/compiler",
193 ]
194
195 # PCH path
196 pch_file = BUILD_DIR / "wasm_pch.h.pch"
197
198 # Build compilation command
199 cmd = [
200 emcc,
201 "-c",
202 ]
203
204 # For .hpp files, explicitly specify language as C++ (fixes .cpp.hpp extension)
205 if source_file.suffix == ".hpp":
206 cmd.extend(["-x", "c++"])
207
208 cmd.extend(
209 [
210 str(source_file),
211 "-o",
212 str(output_object),
213 "-include-pch",
214 str(pch_file),
215 ]
216 )
217 cmd += includes + flags["defines"] + flags["compiler_flags"]

Callers 1

compile_wasmFunction · 0.70

Calls 3

needs_compilationFunction · 0.85
printFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected