From: grumbel Date: Thu, 19 Nov 2009 04:37:32 +0000 (+0000) Subject: Added scripts for source code maintainance X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=75ad1e7d14380b3873758c75ca9d53cda65dd157;p=supertux.git Added scripts for source code maintainance git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6042 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/tools/fix_include_guards.sh b/tools/fix_include_guards.sh new file mode 100755 index 000000000..d8ecafaac --- /dev/null +++ b/tools/fix_include_guards.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +for i in "$@"; do + echo $i + NAME=$(echo $i | sed "s/[\/\.]/_/g;s/^/HEADER_SUPERTUX_/" | tr [a-z] [A-Z]) + sed -i "s/^#ifndef .*_H_\$/#ifndef $NAME/" $i; + sed -i "s/^#define .*_H_\$/#define $NAME/" $i; +done + +# EOF # diff --git a/tools/include_optimize.rb b/tools/include_optimize.rb new file mode 100755 index 000000000..5183da9ab --- /dev/null +++ b/tools/include_optimize.rb @@ -0,0 +1,49 @@ +#!/usr/bin/ruby -w + +def write_file_without_lines(source, lines, without_lines) + out = File.new(source, 'w') + lines.each_with_index { |v, i| + if without_lines.member? i then + out.print "//", v + else + out.print v + end + } + out.close() +end + +def optimize(source, target) + lines = File.new(source).readlines() + includes = [] + lines.each_with_index { |v, i| + if v =~ /^#include/ then + # puts v + includes << i + end + } + + unneeded_includes = [] + + includes.each{|i| + # puts i + write_file_without_lines(source, lines, [i]) + + ret = system("scons", "-u", target) + if ret then + puts "INCUNNEEDED #{source} #{lines[i].chop}" + unneeded_includes << i + end + } + + write_file_without_lines(source, lines, unneeded_includes) +end + +ARGV.each{ |filename| + source = filename + target = "build/#{filename.gsub(/\..pp$/, '.o')}" + puts "#{source} => #{target}" + + optimize(source, target) +} + +# EOF #