Get lists of C source and header files from Makefile targets.
()
| 39 | |
| 40 | |
| 41 | def get_files_to_check(): |
| 42 | """Get lists of C source and header files from Makefile targets.""" |
| 43 | # Get C source files |
| 44 | result = subprocess.run( |
| 45 | ["make", "print-src-to-check"], |
| 46 | capture_output=True, |
| 47 | text=True, |
| 48 | cwd=os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 49 | ) |
| 50 | if result.returncode != 0: |
| 51 | print( |
| 52 | f"Error running 'make print-src-to-check': {result.stderr}", file=sys.stderr |
| 53 | ) |
| 54 | sys.exit(1) |
| 55 | |
| 56 | src_files = parse_makefile_output(result.stdout) |
| 57 | |
| 58 | # Get header files |
| 59 | result = subprocess.run( |
| 60 | ["make", "print-hdr-to-check"], |
| 61 | capture_output=True, |
| 62 | text=True, |
| 63 | cwd=os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 64 | ) |
| 65 | if result.returncode != 0: |
| 66 | print( |
| 67 | f"Error running 'make print-hdr-to-check': {result.stderr}", file=sys.stderr |
| 68 | ) |
| 69 | sys.exit(1) |
| 70 | |
| 71 | hdr_files = parse_makefile_output(result.stdout) |
| 72 | |
| 73 | # Return files with their types |
| 74 | files_with_types = [] |
| 75 | for f in src_files: |
| 76 | files_with_types.append((f, "c")) |
| 77 | for f in hdr_files: |
| 78 | files_with_types.append((f, "h")) |
| 79 | |
| 80 | return files_with_types |
| 81 | |
| 82 | |
| 83 | def extract_includes(content): |
no test coverage detected