Mercurial > projects > dwt2
changeset 1:0e8eed4cac02
add rakefile
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 02 Mar 2009 14:44:56 +0100 |
parents | 6dd524f61e62 |
children | 712ffca654f3 |
files | rakefile |
diffstat | 1 files changed, 84 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rakefile Mon Mar 02 14:44:56 2009 +0100 @@ -0,0 +1,84 @@ +# +# RSP : Create a response file for the compiler, which lists all files from the packages +# Compile and create Headers +# Move objects to unique names +# +require 'find' +require 'fileutils' + +DMD="dmd.exe" +LOCALOBJDIR="obj" +OBJDIR="obj" +DIMPDIR="imp" +RSPNAME="rsp" + +class String + def to_path + self.gsub( '/', '\\' ); + end +end + +def buildTree( basedir, srcdir, resdir ) + + objdir_abs = File.expand_path( OBJDIR ) + dimpdir_abs = File.expand_path( DIMPDIR ) + resdir_abs = File.expand_path( File.join( basedir, resdir )) + srcdir_abs = File.expand_path( File.join( basedir, srcdir )) + rspfile_abs = File.expand_path( RSPNAME ) + + FileUtils.mkdir_p dimpdir_abs + FileUtils.mkdir_p objdir_abs + + puts "Create response file" + rsp = File.new( rspfile_abs, "w+" ) + rsp.puts "-H" + rsp.puts "-I#{srcdir_abs.to_path}" + rsp.puts "-I#{dimpdir_abs.to_path}" + rsp.puts "-J#{resdir_abs.to_path}" + rsp.puts "-c" + rsp.puts "-op" + rsp.puts "-version=TANGOSVN" + Find.find( srcdir_abs ) do |path| + if path =~ /\.d$/ then + rsp.puts path.to_path + end + end + rsp.close + + Dir.chdir(basedir) do + puts "Compile" + sh "#{DMD} @#{rspfile_abs.to_path}" do |ok, res| + raise "compile error" unless ok + end + end + + puts "Move D Headers" + Find.find( srcdir_abs ) do |path| + if FileTest.file?(path) && path =~ /\.di$/ then + trgfile = File.join( dimpdir_abs, path[ srcdir_abs.length+1 .. -1 ]) + FileUtils.mkdir_p File.dirname(trgfile) + FileUtils.mv path, trgfile + end + end + + puts "Move Objects" + srcdirparts = split_all( srcdir_abs ).length + Find.find( srcdir_abs ) do |path| + if FileTest.file?(path) && path =~ /\.o(bj)?$/ then + trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" ) + FileUtils.mv path, File.join( objdir_abs, trgfile ) + end + end + +end + +desc "Build Java" +task :java do + buildTree( "java", "src", "res" ) +end + +desc "Build SWT" +task :swt do + buildTree( "org.eclipse.swt.win32.win32.x86", "src", "res" ) +end +