Merge pull request #773 from thecodeshop/ppp

Refine pretty printing
This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-01-23 05:20:43 -08:00
4 changed files with 15 additions and 11 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ MRuby.each_target do
mrbc_, *rbfiles = t.prerequisites
FileUtils.mkdir_p File.dirname(t.name)
open(t.name, 'w') do |f|
_pp "GEN *.rb > #{t.name}"
_pp "GEN", "*.rb", "#{t.name}"
f.puts File.read("#{dir}/init_mrblib.c")
mrbc.run f, rbfiles, 'mrblib_irep'
end
+7 -7
View File
@@ -58,7 +58,7 @@ module MRuby
include_path_flags = [include_paths, _include_paths, File.dirname(infile)].flatten.map do |f|
option_include_path % filename(f)
end
_pp "CC #{filename(infile)} > #{filename(outfile)}"
_pp "CC", "#{filename(infile)}", "#{filename(outfile)}"
_run compile_options, { :flags => (flags + define_flags + include_path_flags + _flags).join(' '),
:infile => filename(infile), :outfile => filename(outfile) }
end
@@ -131,7 +131,7 @@ module MRuby
FileUtils.mkdir_p File.dirname(outfile)
library_flags = [libraries, _libraries].flatten.reverse.map{ |d| option_library % d }
library_path_flags = [library_paths, _library_paths].flatten.map{ |f| option_library_path % filename(f) }
_pp "LD #{filename(outfile)}"
_pp "LD", "#{filename(outfile)}"
_run link_options, { :flags => (flags + library_path_flags + _flags).join(' '),
:outfile => filename(outfile) , :objs => filename(objfiles).join(' '),
:libs => library_flags.join(' ') }
@@ -149,7 +149,7 @@ module MRuby
def run(outfile, objfiles)
FileUtils.mkdir_p File.dirname(outfile)
_pp "AR #{filename(outfile)}"
_pp "AR", "#{filename(outfile)}"
_run archive_options, { :outfile => filename(outfile), :objs => filename(objfiles).join(' ') }
end
end
@@ -165,7 +165,7 @@ module MRuby
def run(outfile, infile)
FileUtils.mkdir_p File.dirname(outfile)
_pp "YACC #{filename(infile)} > #{filename(outfile)}"
_pp "YACC", "#{filename(infile)}", "#{filename(outfile)}"
_run compile_options, { :outfile => filename(outfile) , :infile => filename(infile) }
end
end
@@ -181,7 +181,7 @@ module MRuby
def run(outfile, infile)
FileUtils.mkdir_p File.dirname(outfile)
_pp "GPERF #{filename(infile)} > #{filename(outfile)}"
_pp "GPERF", "#{filename(infile)}", "#{filename(outfile)}"
_run compile_options, { :outfile => filename(outfile) , :infile => filename(infile) }
end
end
@@ -198,7 +198,7 @@ module MRuby
end
def run_clone(dir, url, _flags = [])
_pp "GIT #{url} > #{filename(dir)}"
_pp "GIT", "#{url}", "#{filename(dir)}"
_run clone_options, { :flags => [flags, _flags].flatten.join(' '), :url => url, :dir => filename(dir) }
end
end
@@ -214,7 +214,7 @@ module MRuby
@command ||= @build.mrbcfile
IO.popen("#{filename @command} #{@compile_options % {:funcname => funcname}}", 'r+') do |io|
[infiles].flatten.each do |f|
_pp " MRBC #{f}"
_pp "MRBC", "#{f}", nil, :indent => 2
io.write IO.read(f)
end
io.close_write
+6 -2
View File
@@ -57,6 +57,10 @@ else
$pp_show = false if $verbose
end
def _pp(msg)
puts msg if $pp_show
def _pp(cmd, src, tgt=nil, options={})
return unless $pp_show
width = 5
template = options[:indent] ? "%#{width*options[:indent]}s %s %s" : "%-#{width}s %s %s"
puts template % [cmd, src, tgt ? "-> #{tgt}" : nil]
end
+1 -1
View File
@@ -19,7 +19,7 @@ MRuby.each_target do
file mlib => [clib]
file clib => [mrbcfile, init, asslib] + mrbs do |t|
_pp "GEN *.rb > #{clib}"
_pp "GEN", "*.rb", "#{clib}"
open(clib, 'w') do |f|
f.puts IO.read(init)
mrbc.run f, [asslib] + mrbs, 'mrbtest_irep'