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

Function generate_unity_file

ci/wasm_unity_generator.py:93–129  ·  view source on GitHub ↗

Generate a single unity build file. Args: chunk_index: Index of this chunk (for naming) sources: List of source files to include in this unity file output_path: Path to write the unity file

(
    chunk_index: int,
    sources: list[Path],
    output_path: Path,
)

Source from the content-addressed store, hash-verified

91
92
93def generate_unity_file(
94 chunk_index: int,
95 sources: list[Path],
96 output_path: Path,
97) -> None:
98 """
99 Generate a single unity build file.
100
101 Args:
102 chunk_index: Index of this chunk (for naming)
103 sources: List of source files to include in this unity file
104 output_path: Path to write the unity file
105 """
106 lines: list[str] = []
107 lines.append(f"// Unity build file {chunk_index}")
108 lines.append("// Generated by ci/wasm_unity_generator.py")
109 lines.append(
110 f"// Combines {len(sources)} source files into single compilation unit"
111 )
112 lines.append("")
113
114 for source in sources:
115 # Use absolute paths (Emscripten em++ handles them correctly)
116 # Use angle brackets like Meson does
117 lines.append(f"#include<{source.as_posix()}>")
118
119 lines.append("")
120
121 content = "\n".join(lines)
122
123 # Only write if content changed (preserve timestamps for incremental builds)
124 if output_path.exists():
125 existing_content = output_path.read_text(encoding="utf-8")
126 if existing_content == content:
127 return # No change, skip write
128
129 output_path.write_text(content, encoding="utf-8")
130
131
132def compute_unity_metadata_hash(num_chunks: int, sources: list[Path]) -> str:

Callers 1

generate_unity_buildsFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected