Check if linking is needed by comparing timestamps. Args: sketch_object: Sketch .o file library_archive: Library .a archive (includes entry_point via _build.hpp) output_wasm: Output .wasm file Returns: True if linking is needed, False if output is up-to
(
sketch_object: Path,
library_archive: Path,
output_wasm: Path,
)
| 103 | |
| 104 | |
| 105 | def needs_linking( |
| 106 | sketch_object: Path, |
| 107 | library_archive: Path, |
| 108 | output_wasm: Path, |
| 109 | ) -> bool: |
| 110 | """ |
| 111 | Check if linking is needed by comparing timestamps. |
| 112 | |
| 113 | Args: |
| 114 | sketch_object: Sketch .o file |
| 115 | library_archive: Library .a archive (includes entry_point via _build.hpp) |
| 116 | output_wasm: Output .wasm file |
| 117 | |
| 118 | Returns: |
| 119 | True if linking is needed, False if output is up-to-date |
| 120 | """ |
| 121 | # If output doesn't exist, we need to link |
| 122 | if not output_wasm.exists(): |
| 123 | return True |
| 124 | |
| 125 | # Get output modification time |
| 126 | output_mtime = output_wasm.stat().st_mtime |
| 127 | |
| 128 | # Check if any input is newer than output |
| 129 | inputs = [sketch_object, library_archive] |
| 130 | for input_file in inputs: |
| 131 | if not input_file.exists(): |
| 132 | return True # Input missing, need to link |
| 133 | if input_file.stat().st_mtime > output_mtime: |
| 134 | return True # Input is newer, need to link |
| 135 | |
| 136 | # All inputs are older than output, no linking needed |
| 137 | return False |
| 138 | |
| 139 | |
| 140 | def needs_compilation(source_file: Path, output_object: Path) -> bool: |