Mercurial > projects > dwt2
comparison rakefile @ 112:9f4c18c268b2
Update to compile and execute with dmd 2.052.
author | kntroh |
---|---|
date | Wed, 16 Mar 2011 21:53:53 +0900 |
parents | 8ae65ae167f5 |
children | fb3aa8075988 |
comparison
equal
deleted
inserted
replaced
111:b6e9904989ed | 112:9f4c18c268b2 |
---|---|
5 require 'fileutils' | 5 require 'fileutils' |
6 | 6 |
7 ########################################################################## | 7 ########################################################################## |
8 # Helpers | 8 # Helpers |
9 # | 9 # |
10 class String | 10 def win_path(path) |
11 def to_path | 11 if isWindows |
12 if isWindows | 12 return path.gsub( '/', '\\' ); |
13 #self.gsub( '/', '\\' ); # don't know why this doesn't work | 13 else |
14 self | 14 return path |
15 else | |
16 self | |
17 end | |
18 end | 15 end |
19 end | 16 end |
20 | 17 |
21 def isWindows | 18 def isWindows |
22 Config::CONFIG['host_os'] =~ /mswin/ || Config::CONFIG['host_os'] =~ /mingw/ | 19 Config::CONFIG['host_os'] =~ /mswin/ || Config::CONFIG['host_os'] =~ /mingw/ |
116 | 113 |
117 resdir_abs = File.expand_path( File.join( basedir, resdir )) | 114 resdir_abs = File.expand_path( File.join( basedir, resdir )) |
118 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) | 115 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) |
119 | 116 |
120 STDERR.puts "#{dbg_str}Building #{libname}" | 117 STDERR.puts "#{dbg_str}Building #{libname}" |
121 STDERR.puts "workdir=>#{srcdir_abs.to_path}" | 118 STDERR.puts "workdir=>#{win_path(srcdir_abs)}" |
122 | 119 |
123 FileUtils.mkdir_p DIR_IMP | 120 FileUtils.mkdir_p DIR_IMP |
124 FileUtils.mkdir_p DIR_OBJ | 121 FileUtils.mkdir_p DIR_OBJ |
125 FileUtils.mkdir_p DIR_RES | 122 FileUtils.mkdir_p DIR_RES |
126 FileUtils.cp FileList[ File.join(resdir_abs, "*" )], DIR_RES | 123 FileUtils.cp FileList[ File.join(resdir_abs, "*" )], DIR_RES |
127 | 124 |
128 rsp = File.new( FILE_RSP, "w+" ) | 125 rsp = File.new( FILE_RSP, "w+" ) |
129 rsp.puts "-H" | 126 rsp.puts "-H" |
130 #rsp.puts "-Hd#{DIR_IMP.to_path}" | 127 #rsp.puts "-Hd#{win_path(DIR_IMP)}" |
131 rsp.puts "-I#{srcdir_abs.to_path}" | 128 rsp.puts "-I#{win_path(srcdir_abs)}" |
132 rsp.puts "-I#{DIR_IMP.to_path}" | 129 rsp.puts "-I#{win_path(DIR_IMP)}" |
133 rsp.puts "-J#{DIR_RES.to_path}" | 130 rsp.puts "-J#{win_path(DIR_RES)}" |
134 if dcargs != nil | 131 if dcargs != nil |
135 rsp.puts dcargs | 132 rsp.puts dcargs |
136 end | 133 end |
137 rsp.puts "-c" | 134 rsp.puts "-c" |
138 rsp.puts "-op" | 135 rsp.puts "-op" |
140 rsp.puts "-debug" | 137 rsp.puts "-debug" |
141 rsp.puts "-g" | 138 rsp.puts "-g" |
142 end | 139 end |
143 Find.find( srcdir_abs ) do |path| | 140 Find.find( srcdir_abs ) do |path| |
144 if path =~ /\.d$/ then | 141 if path =~ /\.d$/ then |
145 rsp.puts path.to_path[ srcdir_abs.size+1 .. -1 ] | 142 rsp.puts win_path(path)[ srcdir_abs.size+1 .. -1 ] |
146 end | 143 end |
147 end | 144 end |
148 rsp.close | 145 rsp.close |
149 | 146 |
150 Dir.chdir(srcdir_abs) do | 147 Dir.chdir(srcdir_abs) do |
151 if isWindows | 148 if isWindows |
152 cmd = "#{PROG_DMD} @#{FILE_RSP.to_path}" | 149 cmd = "#{PROG_DMD} @#{win_path(FILE_RSP)}" |
153 else | 150 else |
154 cmd = "cat #{FILE_RSP.to_path} | xargs #{PROG_DMD}" | 151 cmd = "cat #{win_path(FILE_RSP)} | xargs #{PROG_DMD}" |
155 end | 152 end |
156 sh cmd, :verbose => false do |ok, res| | 153 sh cmd, :verbose => false do |ok, res| |
157 if !ok then | 154 if !ok then |
158 Find.find( srcdir_abs ) do |path| | 155 Find.find( srcdir_abs ) do |path| |
159 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then | 156 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then |
189 | 186 |
190 createLib( libobjs, libname ) | 187 createLib( libobjs, libname ) |
191 end | 188 end |
192 | 189 |
193 def createLib( libobjs, name ) | 190 def createLib( libobjs, name ) |
194 FileUtils.mkdir_p DIR_LIB.to_path | 191 FileUtils.mkdir_p win_path(DIR_LIB) |
195 file_lib = File.join(DIR_LIB, name + LIBEXT) | 192 file_lib = File.join(DIR_LIB, name + LIBEXT) |
196 FileUtils.rm_f file_lib | 193 FileUtils.rm_f file_lib |
197 rsp = File.new( FILE_RSP, "w+" ) | 194 rsp = File.new( FILE_RSP, "w+" ) |
198 if isWindows | 195 if isWindows |
199 rsp.puts "-p512" | 196 rsp.puts "-p512" |
200 rsp.puts "-n" | 197 rsp.puts "-n" |
201 rsp.puts "-c #{file_lib.to_path}" | 198 rsp.puts "-c #{win_path(file_lib)}" |
202 libobjs.each do |obj| | 199 libobjs.each do |obj| |
203 rsp.puts obj.to_path | 200 rsp.puts win_path(obj) |
204 end | 201 end |
205 else | 202 else |
206 rsp.puts "-r" | 203 rsp.puts "-r" |
207 rsp.puts "-c #{file_lib.to_path}" | 204 rsp.puts "-c #{win_path(file_lib)}" |
208 libobjs.each do |obj| | 205 libobjs.each do |obj| |
209 rsp.puts obj.to_path | 206 rsp.puts win_path(obj) |
210 end | 207 end |
211 end | 208 end |
212 rsp.close | 209 rsp.close |
213 cmd = "#{PROG_LIB} @#{FILE_RSP} > #{LOG_STDOUT}" | 210 cmd = "#{PROG_LIB} @#{FILE_RSP} > #{LOG_STDOUT}" |
214 sh cmd, :verbose => false do |ok, res| | 211 sh cmd, :verbose => false do |ok, res| |
227 | 224 |
228 srcdir_abs = File.expand_path( File.join( basedir, srcdir)) | 225 srcdir_abs = File.expand_path( File.join( basedir, srcdir)) |
229 resdir_abs = File.expand_path( File.join( basedir, resdir)) | 226 resdir_abs = File.expand_path( File.join( basedir, resdir)) |
230 | 227 |
231 rsp = File.new( FILE_RSP, "w+" ) | 228 rsp = File.new( FILE_RSP, "w+" ) |
232 rsp.puts "-I#{srcdir_abs.to_path}" | 229 rsp.puts "-I#{win_path(srcdir_abs)}" |
233 rsp.puts "-I#{DIR_IMP.to_path}" | 230 rsp.puts "-I#{win_path(DIR_IMP)}" |
234 rsp.puts "-J#{resdir_abs.to_path}" | 231 rsp.puts "-J#{win_path(resdir_abs)}" |
235 rsp.puts "-J#{DIR_RES.to_path}" | 232 rsp.puts "-J#{win_path(DIR_RES)}" |
236 if isDebug | 233 if isDebug |
237 rsp.puts "-debug" | 234 rsp.puts "-debug" |
238 rsp.puts "-g" | 235 rsp.puts "-g" |
239 end | 236 end |
240 if dflags.size > 0 then | 237 if dflags.size > 0 then |
241 rsp.puts dflags | 238 rsp.puts dflags |
242 end | 239 end |
243 | 240 |
244 rsp.puts "-op" | 241 rsp.puts "-op" |
245 rsp.puts "-od#{DIR_OBJ.to_path}" | 242 rsp.puts "-od#{win_path(DIR_OBJ)}" |
246 applfile = File.join(DIR_BIN ,appnameprefix+appname+EXEEXT) | 243 applfile = File.join(DIR_BIN ,appnameprefix+appname+EXEEXT) |
247 rsp.puts "-of#{applfile.to_path}" | 244 rsp.puts "-of#{win_path(applfile)}" |
248 filelist.each do |path| | 245 filelist.each do |path| |
249 rsp.puts File.expand_path(path).to_path[ srcdir_abs.size+1 .. -1 ] | 246 rsp.puts win_path(File.expand_path(path))[ srcdir_abs.size+1 .. -1 ] |
250 end | 247 end |
251 | 248 |
252 if isWindows | 249 if isWindows |
253 rsp.puts "-L/NOM" | 250 rsp.puts "-L/NOM" |
254 libnames.each do | libname | | 251 libnames.each do | libname | |
255 rsp.puts "-L+#{libname}#{LIBEXT}" | 252 rsp.puts "-L+#{libname}#{LIBEXT}" |
256 end | 253 end |
257 rsp.puts "-L+#{DIR_LIB.to_path}\\" | 254 rsp.puts "-L+#{win_path(DIR_LIB)}\\" |
258 else | 255 else |
259 rsp.puts "-L-L#{DIR_LIB.to_path}" | 256 rsp.puts "-L-L#{win_path(DIR_LIB)}" |
260 libnames.reverse.each do | libname | | 257 libnames.reverse.each do | libname | |
261 absname = File.join( DIR_LIB, "#{libname}#{LIBEXT}" ); | 258 absname = File.join( DIR_LIB, "#{libname}#{LIBEXT}" ); |
262 rsp.puts absname | 259 rsp.puts absname |
263 end | 260 end |
264 SONAMES_BASIC.reverse.each do | soname | | 261 SONAMES_BASIC.reverse.each do | soname | |
268 | 265 |
269 rsp.close | 266 rsp.close |
270 | 267 |
271 Dir.chdir(srcdir_abs) do | 268 Dir.chdir(srcdir_abs) do |
272 if isWindows | 269 if isWindows |
273 cmd = "#{PROG_DMD} @#{FILE_RSP.to_path}" | 270 cmd = "#{PROG_DMD} @#{win_path(FILE_RSP)}" |
274 else | 271 else |
275 cmd = "cat #{FILE_RSP.to_path} | xargs #{PROG_DMD}" | 272 cmd = "cat #{win_path(FILE_RSP)} | xargs #{PROG_DMD}" |
276 end | 273 end |
277 sh cmd, :verbose => false do |ok, res| | 274 sh cmd, :verbose => false do |ok, res| |
278 if !ok then | 275 if !ok then |
279 raise "compile error" | 276 raise "compile error" |
280 end | 277 end |