3 def write_file_without_lines(source, lines, without_lines)
4 out = File.new(source, 'w')
5 lines.each_with_index { |v, i|
6 if without_lines.member? i then
15 def optimize(source, target)
16 lines = File.new(source).readlines()
18 lines.each_with_index { |v, i|
19 if v =~ /^#include/ then
25 unneeded_includes = []
29 write_file_without_lines(source, lines, [i])
31 ret = system("scons", "-u", target)
33 puts "INCUNNEEDED #{source} #{lines[i].chop}"
34 unneeded_includes << i
38 write_file_without_lines(source, lines, unneeded_includes)
43 target = "build/#{filename.gsub(/\..pp$/, '.o')}"
44 puts "#{source} => #{target}"
46 optimize(source, target)