| 1 | from pathlib import Path |
| 2 | |
| 3 | def task_compile(): |
| 4 | working_directory = Path('.') |
| 5 | # Path.glob returns an iterator so turn it into a list |
| 6 | headers = list(working_directory.glob('*.h')) |
| 7 | for source_file in working_directory.glob('*.c'): |
| 8 | object_file = source_file.with_suffix('.o') |
| 9 | yield { |
| 10 | 'name': object_file.name, |
| 11 | 'actions': [['cc', '-c', source_file]], |
| 12 | 'file_dep': [source_file] + headers, |
| 13 | 'targets': [object_file], |
| 14 | } |