MCPcopy Create free account
hub / github.com/F-Stack/f-stack / remove_includes

Function remove_includes

dpdk/devtools/process-iwyu.py:35–54  ·  view source on GitHub ↗

Attempts to remove include, if it fails then revert to original state

(filepath, include, build_dir)

Source from the content-addressed store, hash-verified

33
34
35def 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
57def get_build_config(builddir, condition):

Callers 1

processFunction · 0.85

Calls 3

run_mesonFunction · 0.85
printFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected