Attempts to remove include, if it fails then revert to original state
(filepath, include, build_dir)
| 33 | |
| 34 | |
| 35 | def remove_includes(filepath, include, build_dir): |
| 36 | "Attempts to remove include, if it fails then revert to original state" |
| 37 | with open(filepath) as f: |
| 38 | lines = f.readlines() # Read lines when file is opened |
| 39 | |
| 40 | with open(filepath, 'w') as f: |
| 41 | for ln in lines: # Removes the include passed in |
| 42 | if not ln.startswith(include): |
| 43 | f.write(ln) |
| 44 | |
| 45 | # run test build -> call meson on the build folder, meson compile -C build |
| 46 | ret = run_meson(['compile', '-C', build_dir]) |
| 47 | if (ret == 0): # Include is not needed -> build is successful |
| 48 | print('SUCCESS') |
| 49 | else: |
| 50 | # failed, catch the error |
| 51 | # return file to original state |
| 52 | with open(filepath, 'w') as f: |
| 53 | f.writelines(lines) |
| 54 | print('FAILED') |
| 55 | |
| 56 | |
| 57 | def get_build_config(builddir, condition): |