diff rakefile @ 36:d46287db17ed

rakefile reorg, swt win phobosification
author Frank Benoit <benoit@tionex.de>
date Tue, 24 Mar 2009 08:48:41 +0100
parents a8a838017920
children 9f32c409fe27
line wrap: on
line diff
--- a/rakefile	Mon Mar 23 18:28:04 2009 +0100
+++ b/rakefile	Tue Mar 24 08:48:41 2009 +0100
@@ -1,39 +1,12 @@
-#
-# RSP : Create a response file for the compiler, which lists all files from the packages
-# Compile and create Headers
-# Move objects to unique names
+##########################################################################
+# DWT2
 #
 require 'find'
 require 'fileutils'
 
-#DMD="c:\\project\\dmd-2.026\\dmd\\windows\\bin\\dmd.exe"
-DMD="dmd"
-OBJDIR  =File.expand_path("obj")
-DIMPDIR =File.expand_path("imp")
-LIBDIR  =File.expand_path("lib")
-BINDIR  =File.expand_path("bin")
-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
-
+##########################################################################
+# Helpers
+#
 class String
     def to_path
         if isWindows
@@ -44,8 +17,83 @@
     end
 end
 
+def isWindows
+    Config::CONFIG['host_os'] =~ /mswin/
+end
+
+##########################################################################
+# Constants
+#
+DMD         = "dmd"
+OBJDIR      = File.expand_path("obj")
+DIMPDIR     = File.expand_path("imp")
+LIBDIR      = File.expand_path("lib")
+BINDIR      = File.expand_path("bin")
+RSPNAME     = File.expand_path("rsp")
+ALL_RESDIRS = [ "base/res", "res" ]
+
+LOG_STDOUT  = File.expand_path("olog.txt")
+LOG_STDERR  = File.expand_path("elog.txt")
+
+
+if isWindows
+    BASEDIR_SWT = "org.eclipse.swt.win32.win32.x86"
+    LIBEXT = ".lib"
+    OBJEXT = ".obj"
+    EXEEXT = ".exe"
+else
+    BASEDIR_SWT = "org.eclipse.swt.gtk.linux.x86"
+    LIBEXT = ".a"
+    OBJEXT = ".o"
+    EXEEXT = ""
+end
+
+ALL_RESDIRS << File.join(BASEDIR_SWT, "res" )
+
+if isWindows
+    LIBNAMES_BASIC  = [ "advapi32", "comctl32", "comdlg32", "gdi32", "kernel32",
+                        "shell32", "ole32", "oleaut32", "olepro32", "oleacc",
+                        "user32", "usp10", "msimg32", "opengl32", "shlwapi",
+                        "dwt-base" ]
+
+else
+    LIBNAMES_BASIC  = [ "gtk-x11-2.0", "gdk-x11-2.0", "atk-1.0", "gdk_pixbuf-2.0",
+                        "gthread-2.0", "pangocairo-1.0", "fontconfig", "Xtst",
+                        "Xext", "Xrender", "Xinerama", "Xi", "Xrandr", "Xcursor",
+                        "Xcomposite", "Xdamage", "X11", "Xfixes", "pango-1.0",
+                        "gobject-2.0", "gmodule-2.0", "dl", "glib-2.0", "cairo",
+                        "dwt-base" ]
+
+end
+LIBNAMES_SWT        = [ BASEDIR_SWT ]
+LIBNAMES_EQUINOX    = [ "org.eclipse.osgi",
+                        "org.eclipse.osgi.supplement",
+                        "org.eclipse.equinox.common" ]
+
+LIBNAMES_CORE       = [ "org.eclipse.core.runtime",
+                        "org.eclipse.core.commands",
+                        "org.eclipse.core.jobs" ]
+
+LIBNAMES_JFACE      = [ "org.eclipse.jface" ]
+
+LIBNAMES_JFACETEXT  = [ "org.eclipse.text",
+                        "org.eclipse.jface.text.projection",
+                        "org.eclipse.jface.text", ]
+
+LIBNAMES_UIFORMS    = [ "org.eclipse.ui.forms" ]
+
+LIBNAMES_DRAW2D     = [ "org.eclipse.draw2d" ]
+
+
+##########################################################################
+# Routines
+#
+
 def buildTree( basedir, srcdir, resdir, dcargs=nil, libname=nil )
-    puts "Building #{basedir}/#{srcdir}"
+    if libname == nil
+        libname = basedir
+    end
+    puts "Building #{libname}"
 
     resdir_abs = File.expand_path( File.join( basedir, resdir ))
     srcdir_abs = File.expand_path( File.join( basedir, srcdir ))
@@ -110,9 +158,6 @@
         end
     end
 
-    if libname == nil
-        libname = basedir
-    end
     createLib( libobjs, libname )
 end
 
@@ -133,6 +178,63 @@
 
 end
 
+def buildApp( basedir, srcdir, resdir, dflags, appname, filelist, libnames )
+    puts "Building #{basedir}[#{appname}]"
+    if filelist == nil
+        filelist = FileList[ "**/#{appname}.d" ]
+    end
+
+    srcdir_abs = File.expand_path( File.join( basedir, srcdir))
+    resdir_abs = File.expand_path( File.join( basedir, resdir))
+
+    rsp = File.new( RSPNAME, "w+" )
+    rsp.puts "-I#{srcdir_abs.to_path}"
+    rsp.puts "-I#{DIMPDIR.to_path}"
+    rsp.puts "-J#{resdir_abs.to_path}"
+    if dflags.size > 0 then
+        rsp.puts dflags
+    end
+    ALL_RESDIRS.each do | dir |
+        rsp.puts "-J#{File.expand_path(dir).to_path}"
+    end
+
+    rsp.puts "-L/NOM"
+    libnames.each do | libname |
+        rsp.puts "-L+#{libname}#{LIBEXT}"
+    end
+    rsp.puts "-L+tango-user-dmd.lib"
+    rsp.puts "-L+zlib.lib"
+    rsp.puts "-L+dwt-base.lib"
+    rsp.puts "-L+#{BASEDIR_SWT}.lib"
+    rsp.puts "-L+#{LIBDIR.to_path}\\"
+
+    rsp.puts "-op"
+    rsp.puts "-od#{OBJDIR.to_path}"
+    applfile = File.join(BINDIR,appname+EXEEXT)
+    rsp.puts "-of#{applfile.to_path}"
+    filelist.each do |path|
+        rsp.puts File.expand_path(path).to_path
+    end
+    rsp.close
+
+    Dir.chdir(basedir) do
+        if isWindows
+            cmd = "#{DMD} @#{RSPNAME.to_path}"
+        else
+            cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}"
+        end
+        sh cmd, :verbose => false do |ok, res|
+            if !ok then
+                raise "compile error"
+            end
+        end
+    end
+
+end
+
+##########################################################################
+# Targets
+#
 desc "Clean"
 task :clean do
     puts "Cleaning"
@@ -151,16 +253,7 @@
 
 desc "Build SWT"
 task :swt do
-    if isWindows
-        buildTree( "org.eclipse.swt.win32.win32.x86", "src", "res" )
-    else
-        buildTree( "org.eclipse.swt.gtk.linux.x86", "src", "res" )
-    end
-end
-if isWindows
-    LIBNAMES_SWT = [ "org.eclipse.swt.win32.win32.x86" ]
-else
-    LIBNAMES_SWT = [ "org.eclipse.swt.gtk.linux.x86" ]
+    buildTree( BASEDIR_SWT, "src", "res" )
 end
 
 desc "Build Equinox"
@@ -169,7 +262,6 @@
     buildTree( "org.eclipse.osgi", "supplement/src", "res", nil, "org.eclipse.osgi.supplement")
     buildTree( "org.eclipse.equinox.common", "src", "res" )
 end
-LIBNAMES_EQUINOX = [ "org.eclipse.osgi", "org.eclipse.osgi.supplement", "org.eclipse.equinox.common" ]
 
 desc "Build Eclipse Core"
 task :core do
@@ -177,13 +269,11 @@
     buildTree( "org.eclipse.core.commands", "src", "res" )
     buildTree( "org.eclipse.core.jobs", "src", "res" )
 end
-LIBNAMES_CORE = [ "org.eclipse.core.runtime", "org.eclipse.core.commands", "org.eclipse.core.jobs" ]
 
 desc "Build JFace"
 task :jface do
     buildTree( "org.eclipse.jface", "src", "res" )
 end
-LIBNAMES_JFACE = [ "org.eclipse.jface" ]
 
 desc "Build JFace.Text"
 task :jfacetext do
@@ -191,23 +281,20 @@
     buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc", "org.eclipse.jface.text.projection" )
     buildTree( "org.eclipse.jface.text", "src", "res" )
 end
-LIBNAMES_JFACETEXT = [ "org.eclipse.text", "org.eclipse.jface.text.projection", "org.eclipse.jface.text", ]
 
 desc "Build UI Forms"
 task :uiforms do
     buildTree( "org.eclipse.ui.forms", "src", "res" )
 end
-LIBNAMES_UIFORMS = [ "org.eclipse.ui.forms" ]
 
 desc "Build Draw2D"
 task :draw2d do
     buildTree( "org.eclipse.draw2d", "src", "res" )
 end
-LIBNAMES_DRAW2D = [ "org.eclipse.draw2d" ]
 
 desc "Build ALL"
 task :all => [ :base, :swt, :equinox, :core, :jface, :jfacetext, :uiforms,
-    :draw2d ]
+    :draw2d, :swtsnippets, :jfacesnippets ]
 
 desc "Clean, then build ALL"
 task :default => [ :clean, :all ]
@@ -266,62 +353,5 @@
     end
 end
 
-LIBNAMES_BASIC = [ "advapi32", "comctl32", "comdlg32", "gdi32", "kernel32",
-    "shell32", "ole32", "oleaut32", "olepro32", "oleacc", "user32", "usp10",
-    "msimg32", "opengl32", "shlwapi", "dwt-base" ]
-
-def buildApp( basedir, srcdir, resdir, dflags, appname, filelist, libnames )
-    if filelist == nil
-        filelist = FileList[ "**/#{appname}.d" ]
-    end
-
-    srcdir_abs = File.expand_path( File.join( basedir, srcdir))
-    resdir_abs = File.expand_path( File.join( basedir, resdir))
-
-    rsp = File.new( RSPNAME, "w+" )
-    rsp.puts "-I#{srcdir_abs.to_path}"
-    rsp.puts "-I#{DIMPDIR.to_path}"
-    rsp.puts "-J#{resdir_abs.to_path}"
-    if dflags.size > 0 then
-        rsp.puts dflags
-    end
-    ALL_RESDIRS.each do | dir |
-        rsp.puts "-J#{File.expand_path(dir).to_path}"
-    end
-
-    rsp.puts "-L/NOM"
-    libnames.each do | libname |
-        rsp.puts "-L+#{libname}#{LIBEXT}"
-    end
-    rsp.puts "-L+tango-user-dmd.lib"
-    rsp.puts "-L+zlib.lib"
-    rsp.puts "-L+dwt-base.lib"
-    rsp.puts "-L+org.eclipse.swt.win32.win32.x86.lib"
-    rsp.puts "-L+#{LIBDIR.to_path}\\"
-
-    rsp.puts "-op"
-    rsp.puts "-od#{OBJDIR.to_path}"
-    applfile = File.join(BINDIR,appname+EXEEXT)
-    rsp.puts "-of#{applfile.to_path}"
-    filelist.each do |path|
-        rsp.puts File.expand_path(path).to_path
-    end
-    rsp.close
-
-    Dir.chdir(basedir) do
-        if isWindows
-            cmd = "#{DMD} @#{RSPNAME.to_path}"
-        else
-            cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}"
-        end
-        sh cmd, :verbose => false do |ok, res|
-            if !ok then
-                raise "compile error"
-            end
-        end
-    end
-
-end
 
 
-