Mercurial > projects > dwt2
comparison 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 |
comparison
equal
deleted
inserted
replaced
35:634e4380db78 | 36:d46287db17ed |
---|---|
1 # | 1 ########################################################################## |
2 # RSP : Create a response file for the compiler, which lists all files from the packages | 2 # DWT2 |
3 # Compile and create Headers | |
4 # Move objects to unique names | |
5 # | 3 # |
6 require 'find' | 4 require 'find' |
7 require 'fileutils' | 5 require 'fileutils' |
8 | 6 |
9 #DMD="c:\\project\\dmd-2.026\\dmd\\windows\\bin\\dmd.exe" | 7 ########################################################################## |
10 DMD="dmd" | 8 # Helpers |
11 OBJDIR =File.expand_path("obj") | 9 # |
12 DIMPDIR =File.expand_path("imp") | |
13 LIBDIR =File.expand_path("lib") | |
14 BINDIR =File.expand_path("bin") | |
15 RSPNAME =File.expand_path("rsp") | |
16 ALL_RESDIRS= [ "base/res", "res" ] | |
17 | |
18 LOG_STDOUT = File.expand_path("olog.txt") | |
19 LOG_STDERR = File.expand_path("elog.txt") | |
20 | |
21 def isWindows | |
22 Config::CONFIG['host_os'] =~ /mswin/ | |
23 end | |
24 | |
25 if isWindows | |
26 ALL_RESDIRS << "org.eclipse.swt.win32.win32.x86/res" | |
27 LIBEXT = ".lib" | |
28 OBJEXT = ".obj" | |
29 EXEEXT = ".exe" | |
30 else | |
31 ALL_RESDIRS << "org.eclipse.swt.gtk.linux.x86/res" | |
32 LIBEXT = ".a" | |
33 OBJEXT = ".o" | |
34 EXEEXT = "" | |
35 end | |
36 | |
37 class String | 10 class String |
38 def to_path | 11 def to_path |
39 if isWindows | 12 if isWindows |
40 self.gsub( '/', '\\' ); | 13 self.gsub( '/', '\\' ); |
41 else | 14 else |
42 self | 15 self |
43 end | 16 end |
44 end | 17 end |
45 end | 18 end |
46 | 19 |
20 def isWindows | |
21 Config::CONFIG['host_os'] =~ /mswin/ | |
22 end | |
23 | |
24 ########################################################################## | |
25 # Constants | |
26 # | |
27 DMD = "dmd" | |
28 OBJDIR = File.expand_path("obj") | |
29 DIMPDIR = File.expand_path("imp") | |
30 LIBDIR = File.expand_path("lib") | |
31 BINDIR = File.expand_path("bin") | |
32 RSPNAME = File.expand_path("rsp") | |
33 ALL_RESDIRS = [ "base/res", "res" ] | |
34 | |
35 LOG_STDOUT = File.expand_path("olog.txt") | |
36 LOG_STDERR = File.expand_path("elog.txt") | |
37 | |
38 | |
39 if isWindows | |
40 BASEDIR_SWT = "org.eclipse.swt.win32.win32.x86" | |
41 LIBEXT = ".lib" | |
42 OBJEXT = ".obj" | |
43 EXEEXT = ".exe" | |
44 else | |
45 BASEDIR_SWT = "org.eclipse.swt.gtk.linux.x86" | |
46 LIBEXT = ".a" | |
47 OBJEXT = ".o" | |
48 EXEEXT = "" | |
49 end | |
50 | |
51 ALL_RESDIRS << File.join(BASEDIR_SWT, "res" ) | |
52 | |
53 if isWindows | |
54 LIBNAMES_BASIC = [ "advapi32", "comctl32", "comdlg32", "gdi32", "kernel32", | |
55 "shell32", "ole32", "oleaut32", "olepro32", "oleacc", | |
56 "user32", "usp10", "msimg32", "opengl32", "shlwapi", | |
57 "dwt-base" ] | |
58 | |
59 else | |
60 LIBNAMES_BASIC = [ "gtk-x11-2.0", "gdk-x11-2.0", "atk-1.0", "gdk_pixbuf-2.0", | |
61 "gthread-2.0", "pangocairo-1.0", "fontconfig", "Xtst", | |
62 "Xext", "Xrender", "Xinerama", "Xi", "Xrandr", "Xcursor", | |
63 "Xcomposite", "Xdamage", "X11", "Xfixes", "pango-1.0", | |
64 "gobject-2.0", "gmodule-2.0", "dl", "glib-2.0", "cairo", | |
65 "dwt-base" ] | |
66 | |
67 end | |
68 LIBNAMES_SWT = [ BASEDIR_SWT ] | |
69 LIBNAMES_EQUINOX = [ "org.eclipse.osgi", | |
70 "org.eclipse.osgi.supplement", | |
71 "org.eclipse.equinox.common" ] | |
72 | |
73 LIBNAMES_CORE = [ "org.eclipse.core.runtime", | |
74 "org.eclipse.core.commands", | |
75 "org.eclipse.core.jobs" ] | |
76 | |
77 LIBNAMES_JFACE = [ "org.eclipse.jface" ] | |
78 | |
79 LIBNAMES_JFACETEXT = [ "org.eclipse.text", | |
80 "org.eclipse.jface.text.projection", | |
81 "org.eclipse.jface.text", ] | |
82 | |
83 LIBNAMES_UIFORMS = [ "org.eclipse.ui.forms" ] | |
84 | |
85 LIBNAMES_DRAW2D = [ "org.eclipse.draw2d" ] | |
86 | |
87 | |
88 ########################################################################## | |
89 # Routines | |
90 # | |
91 | |
47 def buildTree( basedir, srcdir, resdir, dcargs=nil, libname=nil ) | 92 def buildTree( basedir, srcdir, resdir, dcargs=nil, libname=nil ) |
48 puts "Building #{basedir}/#{srcdir}" | 93 if libname == nil |
94 libname = basedir | |
95 end | |
96 puts "Building #{libname}" | |
49 | 97 |
50 resdir_abs = File.expand_path( File.join( basedir, resdir )) | 98 resdir_abs = File.expand_path( File.join( basedir, resdir )) |
51 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) | 99 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) |
52 | 100 |
53 FileUtils.mkdir_p DIMPDIR | 101 FileUtils.mkdir_p DIMPDIR |
108 FileUtils.mv path, File.join( OBJDIR, trgfile ) | 156 FileUtils.mv path, File.join( OBJDIR, trgfile ) |
109 libobjs << File.join( OBJDIR, trgfile ) | 157 libobjs << File.join( OBJDIR, trgfile ) |
110 end | 158 end |
111 end | 159 end |
112 | 160 |
113 if libname == nil | |
114 libname = basedir | |
115 end | |
116 createLib( libobjs, libname ) | 161 createLib( libobjs, libname ) |
117 end | 162 end |
118 | 163 |
119 def createLib( libobjs, name ) | 164 def createLib( libobjs, name ) |
120 FileUtils.mkdir_p LIBDIR.to_path | 165 FileUtils.mkdir_p LIBDIR.to_path |
131 end | 176 end |
132 end | 177 end |
133 | 178 |
134 end | 179 end |
135 | 180 |
181 def buildApp( basedir, srcdir, resdir, dflags, appname, filelist, libnames ) | |
182 puts "Building #{basedir}[#{appname}]" | |
183 if filelist == nil | |
184 filelist = FileList[ "**/#{appname}.d" ] | |
185 end | |
186 | |
187 srcdir_abs = File.expand_path( File.join( basedir, srcdir)) | |
188 resdir_abs = File.expand_path( File.join( basedir, resdir)) | |
189 | |
190 rsp = File.new( RSPNAME, "w+" ) | |
191 rsp.puts "-I#{srcdir_abs.to_path}" | |
192 rsp.puts "-I#{DIMPDIR.to_path}" | |
193 rsp.puts "-J#{resdir_abs.to_path}" | |
194 if dflags.size > 0 then | |
195 rsp.puts dflags | |
196 end | |
197 ALL_RESDIRS.each do | dir | | |
198 rsp.puts "-J#{File.expand_path(dir).to_path}" | |
199 end | |
200 | |
201 rsp.puts "-L/NOM" | |
202 libnames.each do | libname | | |
203 rsp.puts "-L+#{libname}#{LIBEXT}" | |
204 end | |
205 rsp.puts "-L+tango-user-dmd.lib" | |
206 rsp.puts "-L+zlib.lib" | |
207 rsp.puts "-L+dwt-base.lib" | |
208 rsp.puts "-L+#{BASEDIR_SWT}.lib" | |
209 rsp.puts "-L+#{LIBDIR.to_path}\\" | |
210 | |
211 rsp.puts "-op" | |
212 rsp.puts "-od#{OBJDIR.to_path}" | |
213 applfile = File.join(BINDIR,appname+EXEEXT) | |
214 rsp.puts "-of#{applfile.to_path}" | |
215 filelist.each do |path| | |
216 rsp.puts File.expand_path(path).to_path | |
217 end | |
218 rsp.close | |
219 | |
220 Dir.chdir(basedir) do | |
221 if isWindows | |
222 cmd = "#{DMD} @#{RSPNAME.to_path}" | |
223 else | |
224 cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" | |
225 end | |
226 sh cmd, :verbose => false do |ok, res| | |
227 if !ok then | |
228 raise "compile error" | |
229 end | |
230 end | |
231 end | |
232 | |
233 end | |
234 | |
235 ########################################################################## | |
236 # Targets | |
237 # | |
136 desc "Clean" | 238 desc "Clean" |
137 task :clean do | 239 task :clean do |
138 puts "Cleaning" | 240 puts "Cleaning" |
139 FileUtils.rm_rf DIMPDIR | 241 FileUtils.rm_rf DIMPDIR |
140 FileUtils.rm_rf OBJDIR | 242 FileUtils.rm_rf OBJDIR |
149 buildTree( "base", "src", "res", "", "dwt-base" ) | 251 buildTree( "base", "src", "res", "", "dwt-base" ) |
150 end | 252 end |
151 | 253 |
152 desc "Build SWT" | 254 desc "Build SWT" |
153 task :swt do | 255 task :swt do |
154 if isWindows | 256 buildTree( BASEDIR_SWT, "src", "res" ) |
155 buildTree( "org.eclipse.swt.win32.win32.x86", "src", "res" ) | |
156 else | |
157 buildTree( "org.eclipse.swt.gtk.linux.x86", "src", "res" ) | |
158 end | |
159 end | |
160 if isWindows | |
161 LIBNAMES_SWT = [ "org.eclipse.swt.win32.win32.x86" ] | |
162 else | |
163 LIBNAMES_SWT = [ "org.eclipse.swt.gtk.linux.x86" ] | |
164 end | 257 end |
165 | 258 |
166 desc "Build Equinox" | 259 desc "Build Equinox" |
167 task :equinox do | 260 task :equinox do |
168 buildTree( "org.eclipse.osgi", "src", "res" ) | 261 buildTree( "org.eclipse.osgi", "src", "res" ) |
169 buildTree( "org.eclipse.osgi", "supplement/src", "res", nil, "org.eclipse.osgi.supplement") | 262 buildTree( "org.eclipse.osgi", "supplement/src", "res", nil, "org.eclipse.osgi.supplement") |
170 buildTree( "org.eclipse.equinox.common", "src", "res" ) | 263 buildTree( "org.eclipse.equinox.common", "src", "res" ) |
171 end | 264 end |
172 LIBNAMES_EQUINOX = [ "org.eclipse.osgi", "org.eclipse.osgi.supplement", "org.eclipse.equinox.common" ] | |
173 | 265 |
174 desc "Build Eclipse Core" | 266 desc "Build Eclipse Core" |
175 task :core do | 267 task :core do |
176 buildTree( "org.eclipse.core.runtime", "src", "res" ) | 268 buildTree( "org.eclipse.core.runtime", "src", "res" ) |
177 buildTree( "org.eclipse.core.commands", "src", "res" ) | 269 buildTree( "org.eclipse.core.commands", "src", "res" ) |
178 buildTree( "org.eclipse.core.jobs", "src", "res" ) | 270 buildTree( "org.eclipse.core.jobs", "src", "res" ) |
179 end | 271 end |
180 LIBNAMES_CORE = [ "org.eclipse.core.runtime", "org.eclipse.core.commands", "org.eclipse.core.jobs" ] | |
181 | 272 |
182 desc "Build JFace" | 273 desc "Build JFace" |
183 task :jface do | 274 task :jface do |
184 buildTree( "org.eclipse.jface", "src", "res" ) | 275 buildTree( "org.eclipse.jface", "src", "res" ) |
185 end | 276 end |
186 LIBNAMES_JFACE = [ "org.eclipse.jface" ] | |
187 | 277 |
188 desc "Build JFace.Text" | 278 desc "Build JFace.Text" |
189 task :jfacetext do | 279 task :jfacetext do |
190 buildTree( "org.eclipse.text", "src", "res" ) | 280 buildTree( "org.eclipse.text", "src", "res" ) |
191 buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc", "org.eclipse.jface.text.projection" ) | 281 buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc", "org.eclipse.jface.text.projection" ) |
192 buildTree( "org.eclipse.jface.text", "src", "res" ) | 282 buildTree( "org.eclipse.jface.text", "src", "res" ) |
193 end | 283 end |
194 LIBNAMES_JFACETEXT = [ "org.eclipse.text", "org.eclipse.jface.text.projection", "org.eclipse.jface.text", ] | |
195 | 284 |
196 desc "Build UI Forms" | 285 desc "Build UI Forms" |
197 task :uiforms do | 286 task :uiforms do |
198 buildTree( "org.eclipse.ui.forms", "src", "res" ) | 287 buildTree( "org.eclipse.ui.forms", "src", "res" ) |
199 end | 288 end |
200 LIBNAMES_UIFORMS = [ "org.eclipse.ui.forms" ] | |
201 | 289 |
202 desc "Build Draw2D" | 290 desc "Build Draw2D" |
203 task :draw2d do | 291 task :draw2d do |
204 buildTree( "org.eclipse.draw2d", "src", "res" ) | 292 buildTree( "org.eclipse.draw2d", "src", "res" ) |
205 end | 293 end |
206 LIBNAMES_DRAW2D = [ "org.eclipse.draw2d" ] | |
207 | 294 |
208 desc "Build ALL" | 295 desc "Build ALL" |
209 task :all => [ :base, :swt, :equinox, :core, :jface, :jfacetext, :uiforms, | 296 task :all => [ :base, :swt, :equinox, :core, :jface, :jfacetext, :uiforms, |
210 :draw2d ] | 297 :draw2d, :swtsnippets, :jfacesnippets ] |
211 | 298 |
212 desc "Clean, then build ALL" | 299 desc "Clean, then build ALL" |
213 task :default => [ :clean, :all ] | 300 task :default => [ :clean, :all ] |
214 | 301 |
215 | 302 |
264 end | 351 end |
265 end | 352 end |
266 end | 353 end |
267 end | 354 end |
268 | 355 |
269 LIBNAMES_BASIC = [ "advapi32", "comctl32", "comdlg32", "gdi32", "kernel32", | 356 |
270 "shell32", "ole32", "oleaut32", "olepro32", "oleacc", "user32", "usp10", | 357 |
271 "msimg32", "opengl32", "shlwapi", "dwt-base" ] | |
272 | |
273 def buildApp( basedir, srcdir, resdir, dflags, appname, filelist, libnames ) | |
274 if filelist == nil | |
275 filelist = FileList[ "**/#{appname}.d" ] | |
276 end | |
277 | |
278 srcdir_abs = File.expand_path( File.join( basedir, srcdir)) | |
279 resdir_abs = File.expand_path( File.join( basedir, resdir)) | |
280 | |
281 rsp = File.new( RSPNAME, "w+" ) | |
282 rsp.puts "-I#{srcdir_abs.to_path}" | |
283 rsp.puts "-I#{DIMPDIR.to_path}" | |
284 rsp.puts "-J#{resdir_abs.to_path}" | |
285 if dflags.size > 0 then | |
286 rsp.puts dflags | |
287 end | |
288 ALL_RESDIRS.each do | dir | | |
289 rsp.puts "-J#{File.expand_path(dir).to_path}" | |
290 end | |
291 | |
292 rsp.puts "-L/NOM" | |
293 libnames.each do | libname | | |
294 rsp.puts "-L+#{libname}#{LIBEXT}" | |
295 end | |
296 rsp.puts "-L+tango-user-dmd.lib" | |
297 rsp.puts "-L+zlib.lib" | |
298 rsp.puts "-L+dwt-base.lib" | |
299 rsp.puts "-L+org.eclipse.swt.win32.win32.x86.lib" | |
300 rsp.puts "-L+#{LIBDIR.to_path}\\" | |
301 | |
302 rsp.puts "-op" | |
303 rsp.puts "-od#{OBJDIR.to_path}" | |
304 applfile = File.join(BINDIR,appname+EXEEXT) | |
305 rsp.puts "-of#{applfile.to_path}" | |
306 filelist.each do |path| | |
307 rsp.puts File.expand_path(path).to_path | |
308 end | |
309 rsp.close | |
310 | |
311 Dir.chdir(basedir) do | |
312 if isWindows | |
313 cmd = "#{DMD} @#{RSPNAME.to_path}" | |
314 else | |
315 cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" | |
316 end | |
317 sh cmd, :verbose => false do |ok, res| | |
318 if !ok then | |
319 raise "compile error" | |
320 end | |
321 end | |
322 end | |
323 | |
324 end | |
325 | |
326 | |
327 |