Generate all unity build files. Args: num_chunks: Number of unity chunks to create output_dir: Directory to write unity files verbose: Enable verbose output Returns: Tuple of (list of unity file paths, metadata dict)
(
num_chunks: int,
output_dir: Path,
verbose: bool = False,
)
| 138 | |
| 139 | |
| 140 | def generate_unity_builds( |
| 141 | num_chunks: int, |
| 142 | output_dir: Path, |
| 143 | verbose: bool = False, |
| 144 | ) -> tuple[list[Path], dict[str, str | int]]: |
| 145 | """ |
| 146 | Generate all unity build files. |
| 147 | |
| 148 | Args: |
| 149 | num_chunks: Number of unity chunks to create |
| 150 | output_dir: Directory to write unity files |
| 151 | verbose: Enable verbose output |
| 152 | |
| 153 | Returns: |
| 154 | Tuple of (list of unity file paths, metadata dict) |
| 155 | """ |
| 156 | # Get all source files |
| 157 | sources = get_source_files() |
| 158 | |
| 159 | if verbose: |
| 160 | print(f"Found {len(sources)} source files") |
| 161 | |
| 162 | # Split into chunks |
| 163 | chunks = chunk_sources(sources, num_chunks) |
| 164 | |
| 165 | if verbose: |
| 166 | print(f"Split into {len(chunks)} chunks:") |
| 167 | for i, chunk in enumerate(chunks): |
| 168 | print(f" Chunk {i}: {len(chunk)} files") |
| 169 | |
| 170 | # Create output directory |
| 171 | output_dir.mkdir(parents=True, exist_ok=True) |
| 172 | |
| 173 | # Generate unity files |
| 174 | unity_files: list[Path] = [] |
| 175 | for i, chunk in enumerate(chunks): |
| 176 | unity_path = output_dir / f"unity{i}.cpp" |
| 177 | generate_unity_file(i, chunk, unity_path) |
| 178 | unity_files.append(unity_path) |
| 179 | |
| 180 | if verbose: |
| 181 | print(f"Generated: {unity_path.name} ({len(chunk)} sources)") |
| 182 | |
| 183 | # Compute metadata hash |
| 184 | metadata: dict[str, str | int] = { |
| 185 | "num_chunks": len(chunks), |
| 186 | "num_sources": len(sources), |
| 187 | "config_hash": compute_unity_metadata_hash(num_chunks, sources), |
| 188 | } |
| 189 | |
| 190 | return unity_files, metadata |
| 191 | |
| 192 | |
| 193 | def list_unity_groups(num_chunks: int) -> None: |
no test coverage detected