comparison rakefile @ 47:65761bc28ab2

swt linux again compilable for d1.
author Frank Benoit <benoit@tionex.de>
date Fri, 27 Mar 2009 11:43:53 +0100
parents d5dd1c5b90a9
children e2ca9bdc80f2
comparison
equal deleted inserted replaced
46:17310ba3c1bc 47:65761bc28ab2
22 end 22 end
23 23
24 ########################################################################## 24 ##########################################################################
25 # Constants 25 # Constants
26 # 26 #
27 DMD = "dmd" 27 DIR_OBJ = File.expand_path("obj")
28 OBJDIR = File.expand_path("obj") 28 DIR_IMP = File.expand_path("imp")
29 DIMPDIR = File.expand_path("imp") 29 DIR_LIB = File.expand_path("lib")
30 LIBDIR = File.expand_path("lib")
31 BINDIR = File.expand_path("bin") 30 BINDIR = File.expand_path("bin")
32 RSPNAME = File.expand_path("rsp") 31 FILE_RSP = File.expand_path("rsp")
33 ALL_RESDIRS = [ "base/res", "res" ] 32 ALL_RESDIRS = [ "base/res", "res" ]
34 33
35 LOG_STDOUT = File.expand_path("olog.txt") 34 LOG_STDOUT = File.expand_path("olog.txt")
36 LOG_STDERR = File.expand_path("elog.txt") 35 LOG_STDERR = File.expand_path("elog.txt")
37 36
38 37
39 if isWindows 38 if isWindows
40 BASEDIR_SWT = "org.eclipse.swt.win32.win32.x86" 39 BASEDIR_SWT = "org.eclipse.swt.win32.win32.x86"
41 LIBEXT = ".lib" 40 LIBEXT = ".lib"
42 OBJEXT = ".obj" 41 OBJEXT = ".obj"
43 EXEEXT = ".exe" 42 EXEEXT = ".exe"
44 MAPEXT = ".map" 43 MAPEXT = ".map"
44 PROG_LIB = "lib.exe"
45 else 45 else
46 BASEDIR_SWT = "org.eclipse.swt.gtk.linux.x86" 46 BASEDIR_SWT = "org.eclipse.swt.gtk.linux.x86"
47 LIBEXT = ".a" 47 LIBEXT = ".a"
48 OBJEXT = ".o" 48 OBJEXT = ".o"
49 EXEEXT = "" 49 EXEEXT = ""
50 end 50 PROG_LIB = "ar"
51 end
52 PROG_DMD = "dmd#{EXEEXT}"
51 53
52 ALL_RESDIRS << File.join(BASEDIR_SWT, "res" ) 54 ALL_RESDIRS << File.join(BASEDIR_SWT, "res" )
53 55
54 if isWindows 56 if isWindows
55 LIBNAMES_BASIC = [ "advapi32", "comctl32", "comdlg32", "gdi32", "kernel32", 57 LIBNAMES_BASIC = [ "advapi32", "comctl32", "comdlg32", "gdi32", "kernel32",
97 puts "Building #{libname}" 99 puts "Building #{libname}"
98 100
99 resdir_abs = File.expand_path( File.join( basedir, resdir )) 101 resdir_abs = File.expand_path( File.join( basedir, resdir ))
100 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) 102 srcdir_abs = File.expand_path( File.join( basedir, srcdir ))
101 103
102 FileUtils.mkdir_p DIMPDIR 104 FileUtils.mkdir_p DIR_IMP
103 FileUtils.mkdir_p OBJDIR 105 FileUtils.mkdir_p DIR_OBJ
104 106
105 rsp = File.new( RSPNAME, "w+" ) 107 rsp = File.new( FILE_RSP, "w+" )
106 rsp.puts "-H" 108 rsp.puts "-H"
107 #rsp.puts "-Hd#{DIMPDIR.to_path}" 109 #rsp.puts "-Hd#{DIR_IMP.to_path}"
108 rsp.puts "-I#{srcdir_abs.to_path}" 110 rsp.puts "-I#{srcdir_abs.to_path}"
109 rsp.puts "-I#{DIMPDIR.to_path}" 111 rsp.puts "-I#{DIR_IMP.to_path}"
110 rsp.puts "-J#{resdir_abs.to_path}" 112 rsp.puts "-J#{resdir_abs.to_path}"
111 if dcargs != nil 113 if dcargs != nil
112 rsp.puts dcargs 114 rsp.puts dcargs
113 end 115 end
114 ALL_RESDIRS.each do | dir | 116 ALL_RESDIRS.each do | dir |
123 end 125 end
124 rsp.close 126 rsp.close
125 127
126 Dir.chdir(srcdir_abs) do 128 Dir.chdir(srcdir_abs) do
127 if isWindows 129 if isWindows
128 cmd = "#{DMD} @#{RSPNAME.to_path}" 130 cmd = "#{PROG_DMD} @#{FILE_RSP.to_path}"
129 else 131 else
130 cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" 132 cmd = "cat #{FILE_RSP.to_path} | xargs #{PROG_DMD}"
131 end 133 end
132 sh cmd, :verbose => false do |ok, res| 134 sh cmd, :verbose => false do |ok, res|
133 if !ok then 135 if !ok then
134 Find.find( srcdir_abs ) do |path| 136 Find.find( srcdir_abs ) do |path|
135 if FileTest.file?(path) && path =~ /\.di$/ then 137 if FileTest.file?(path) && path =~ /\.di$/ then
142 end 144 end
143 end 145 end
144 146
145 Find.find( srcdir_abs ) do |path| 147 Find.find( srcdir_abs ) do |path|
146 if FileTest.file?(path) && path =~ /\.di$/ then 148 if FileTest.file?(path) && path =~ /\.di$/ then
147 trgfile = File.join( DIMPDIR, path[ srcdir_abs.length+1 .. -1 ]) 149 trgfile = File.join( DIR_IMP, path[ srcdir_abs.length+1 .. -1 ])
148 FileUtils.mkdir_p File.dirname(trgfile) 150 FileUtils.mkdir_p File.dirname(trgfile)
149 FileUtils.mv path, trgfile 151 FileUtils.mv path, trgfile
150 end 152 end
151 end 153 end
152 154
153 libobjs = FileList.new 155 libobjs = FileList.new
154 srcdirparts = split_all( srcdir_abs ).length 156 srcdirparts = split_all( srcdir_abs ).length
155 Find.find( srcdir_abs ) do |path| 157 Find.find( srcdir_abs ) do |path|
156 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then 158 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then
157 trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" ) 159 trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" )
158 FileUtils.mv path, File.join( OBJDIR, trgfile ) 160 FileUtils.mv path, File.join( DIR_OBJ, trgfile )
159 libobjs << File.join( OBJDIR, trgfile ) 161 libobjs << File.join( DIR_OBJ, trgfile )
160 end 162 end
161 end 163 end
162 164
163 createLib( libobjs, libname ) 165 createLib( libobjs, libname )
164 end 166 end
165 167
166 def createLib( libobjs, name ) 168 def createLib( libobjs, name )
167 FileUtils.mkdir_p LIBDIR.to_path 169 FileUtils.mkdir_p DIR_LIB.to_path
168 rsp = File.new( RSPNAME, "w+" ) 170 rsp = File.new( FILE_RSP, "w+" )
169 rsp.puts "-p512 -n -c #{LIBDIR}/#{name}#{LIBEXT}" 171 if isWindows
170 libobjs.each do |obj| 172 rsp.puts "-p512"
171 rsp.puts obj.to_path 173 rsp.puts "-n"
174 rsp.puts "-c #{DIR_LIB}/#{name}#{LIBEXT}"
175 libobjs.each do |obj|
176 rsp.puts obj.to_path
177 end
178 else
179 rsp.puts "-r"
180 rsp.puts "-c #{DIR_LIB}/#{name}#{LIBEXT}"
181 libobjs.each do |obj|
182 rsp.puts obj.to_path
183 end
172 end 184 end
173 rsp.close 185 rsp.close
174 cmd = "lib @#{RSPNAME} > #{LOG_STDOUT}" 186 cmd = "#{PROG_LIB} @#{FILE_RSP} > #{LOG_STDOUT}"
175 sh cmd, :verbose => false do |ok, res| 187 sh cmd, :verbose => false do |ok, res|
176 if !ok then 188 if !ok then
177 raise "librarian error" 189 raise "librarian error"
178 end 190 end
179 end 191 end
187 end 199 end
188 200
189 srcdir_abs = File.expand_path( File.join( basedir, srcdir)) 201 srcdir_abs = File.expand_path( File.join( basedir, srcdir))
190 resdir_abs = File.expand_path( File.join( basedir, resdir)) 202 resdir_abs = File.expand_path( File.join( basedir, resdir))
191 203
192 rsp = File.new( RSPNAME, "w+" ) 204 rsp = File.new( FILE_RSP, "w+" )
193 rsp.puts "-I#{srcdir_abs.to_path}" 205 rsp.puts "-I#{srcdir_abs.to_path}"
194 rsp.puts "-I#{DIMPDIR.to_path}" 206 rsp.puts "-I#{DIR_IMP.to_path}"
195 rsp.puts "-J#{resdir_abs.to_path}" 207 rsp.puts "-J#{resdir_abs.to_path}"
196 if dflags.size > 0 then 208 if dflags.size > 0 then
197 rsp.puts dflags 209 rsp.puts dflags
198 end 210 end
199 ALL_RESDIRS.each do | dir | 211 ALL_RESDIRS.each do | dir |
204 libnames.each do | libname | 216 libnames.each do | libname |
205 rsp.puts "-L+#{libname}#{LIBEXT}" 217 rsp.puts "-L+#{libname}#{LIBEXT}"
206 end 218 end
207 rsp.puts "-L+dwt-base.lib" 219 rsp.puts "-L+dwt-base.lib"
208 rsp.puts "-L+#{BASEDIR_SWT}.lib" 220 rsp.puts "-L+#{BASEDIR_SWT}.lib"
209 rsp.puts "-L+#{LIBDIR.to_path}\\" 221 rsp.puts "-L+#{DIR_LIB.to_path}\\"
210 222
211 rsp.puts "-op" 223 rsp.puts "-op"
212 rsp.puts "-od#{OBJDIR.to_path}" 224 rsp.puts "-od#{DIR_OBJ.to_path}"
213 applfile = File.join(BINDIR,appname+EXEEXT) 225 applfile = File.join(BINDIR,appname+EXEEXT)
214 rsp.puts "-of#{applfile.to_path}" 226 rsp.puts "-of#{applfile.to_path}"
215 filelist.each do |path| 227 filelist.each do |path|
216 rsp.puts File.expand_path(path).to_path[ srcdir_abs.size+1 .. -1 ] 228 rsp.puts File.expand_path(path).to_path[ srcdir_abs.size+1 .. -1 ]
217 end 229 end
218 rsp.close 230 rsp.close
219 231
220 Dir.chdir(srcdir_abs) do 232 Dir.chdir(srcdir_abs) do
221 if isWindows 233 if isWindows
222 cmd = "#{DMD} @#{RSPNAME.to_path}" 234 cmd = "#{PROG_DMD} @#{FILE_RSP.to_path}"
223 else 235 else
224 cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" 236 cmd = "cat #{FILE_RSP.to_path} | xargs #{PROG_DMD}"
225 end 237 end
226 sh cmd, :verbose => false do |ok, res| 238 sh cmd, :verbose => false do |ok, res|
227 if !ok then 239 if !ok then
228 raise "compile error" 240 raise "compile error"
229 end 241 end
238 # Targets 250 # Targets
239 # 251 #
240 desc "Clean" 252 desc "Clean"
241 task :clean do 253 task :clean do
242 puts "Cleaning" 254 puts "Cleaning"
243 FileUtils.rm_rf DIMPDIR 255 FileUtils.rm_rf DIR_IMP
244 FileUtils.rm_rf OBJDIR 256 FileUtils.rm_rf DIR_OBJ
245 FileUtils.rm_rf LIBDIR 257 FileUtils.rm_rf DIR_LIB
246 FileUtils.rm RSPNAME, :force => true 258 FileUtils.rm FILE_RSP, :force => true
247 FileUtils.rm LOG_STDOUT, :force => true 259 FileUtils.rm LOG_STDOUT, :force => true
248 FileUtils.rm LOG_STDERR, :force => true 260 FileUtils.rm LOG_STDERR, :force => true
249 end 261 end
250 262
251 desc "Build Base (Java Environment and Helpers)" 263 desc "Build Base (Java Environment and Helpers)"