Mercurial > projects > dwt2
diff rakefile @ 28:69b1fa94a4a8
Added SWT snippets
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 22 Mar 2009 15:17:04 +0100 |
parents | 1bf55a6eb092 |
children | 4e5843b771cc |
line wrap: on
line diff
--- a/rakefile Sat Mar 21 11:33:57 2009 +0100 +++ b/rakefile Sun Mar 22 15:17:04 2009 +0100 @@ -8,20 +8,29 @@ #DMD="c:\\project\\dmd-2.026\\dmd\\windows\\bin\\dmd.exe" DMD="dmd" -LOCALOBJDIR="obj" -OBJDIR="obj" -DIMPDIR="imp" -RSPNAME="rsp" +OBJDIR =File.expand_path("obj") +DIMPDIR =File.expand_path("imp") +LIBDIR =File.expand_path("lib") +RSPNAME =File.expand_path("rsp") ALL_RESDIRS= [ "base/res", "res" ] +LOG_STDOUT = File.expand_path("olog.txt") +LOG_STDERR = File.expand_path("elog.txt") + def isWindows Config::CONFIG['host_os'] =~ /mswin/ end if isWindows ALL_RESDIRS << "org.eclipse.swt.win32.win32.x86/res" + LIBEXT = ".lib" + OBJEXT = ".obj" + EXEEXT = ".exe" else ALL_RESDIRS << "org.eclipse.swt.gtk.linux.x86/res" + LIBEXT = ".a" + OBJEXT = ".o" + EXEEXT = "" end class String @@ -34,22 +43,19 @@ end end -def buildTree( basedir, srcdir, resdir, dcargs="" ) +def buildTree( basedir, srcdir, resdir, dcargs="", libname="" ) puts "Building #{basedir}/#{srcdir}" - 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 + FileUtils.mkdir_p DIMPDIR + FileUtils.mkdir_p OBJDIR - rsp = File.new( rspfile_abs, "w+" ) + rsp = File.new( RSPNAME, "w+" ) rsp.puts "-H" rsp.puts "-I#{srcdir_abs.to_path}" - rsp.puts "-I#{dimpdir_abs.to_path}" + rsp.puts "-I#{DIMPDIR.to_path}" rsp.puts "-J#{resdir_abs.to_path}" if dcargs.size > 0 then rsp.puts dcargs @@ -68,9 +74,9 @@ Dir.chdir(basedir) do if isWindows - cmd = "#{DMD} @#{rspfile_abs.to_path}" + cmd = "#{DMD} @#{RSPNAME.to_path}" else - cmd = "cat #{rspfile_abs.to_path} | xargs #{DMD}" + cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" end sh cmd, :verbose => false do |ok, res| if !ok then @@ -87,17 +93,40 @@ Find.find( srcdir_abs ) do |path| if FileTest.file?(path) && path =~ /\.di$/ then - trgfile = File.join( dimpdir_abs, path[ srcdir_abs.length+1 .. -1 ]) + trgfile = File.join( DIMPDIR, path[ srcdir_abs.length+1 .. -1 ]) FileUtils.mkdir_p File.dirname(trgfile) FileUtils.mv path, trgfile end end + libobjs = Array.new 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 ) + FileUtils.mv path, File.join( OBJDIR, trgfile ) + libobjs << File.join( OBJDIR, trgfile ) + end + end + + if libname.size == 0 + libname = basedir + end + createLib( libobjs, libname ) +end + +def createLib( libobjs, name ) + FileUtils.mkdir_p LIBDIR.to_path + rsp = File.new( RSPNAME, "w+" ) + rsp.puts "-p512 -n -c #{LIBDIR}/#{name}#{LIBEXT}" + libobjs.each do |obj| + rsp.puts obj.to_path + end + rsp.close + cmd = "lib @#{RSPNAME} > #{LOG_STDOUT}" + sh cmd, :verbose => false do |ok, res| + if !ok then + raise "librarian error" end end @@ -108,12 +137,15 @@ puts "Cleaning" FileUtils.rm_rf DIMPDIR FileUtils.rm_rf OBJDIR - FileUtils.rm_rf RSPNAME + FileUtils.rm_rf LIBDIR + FileUtils.rm RSPNAME + FileUtils.rm LOG_STDOUT + FileUtils.rm LOG_STDERR end desc "Build Base (Java Environment and Helpers)" task :base do - buildTree( "base", "src", "res" ) + buildTree( "base", "src", "res", "", "dwt-base" ) end desc "Build SWT" @@ -147,7 +179,7 @@ desc "Build JFace.Text" task :jfacetext do buildTree( "org.eclipse.text", "src", "res" ) - buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc" ) + buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc", "org.eclipse.jface.text.projection" ) buildTree( "org.eclipse.jface.text", "src", "res" ) end