1
|
1 #
|
|
2 # RSP : Create a response file for the compiler, which lists all files from the packages
|
|
3 # Compile and create Headers
|
|
4 # Move objects to unique names
|
|
5 #
|
|
6 require 'find'
|
|
7 require 'fileutils'
|
|
8
|
|
9 DMD="dmd.exe"
|
|
10 LOCALOBJDIR="obj"
|
|
11 OBJDIR="obj"
|
|
12 DIMPDIR="imp"
|
|
13 RSPNAME="rsp"
|
|
14
|
|
15 class String
|
|
16 def to_path
|
|
17 self.gsub( '/', '\\' );
|
|
18 end
|
|
19 end
|
|
20
|
|
21 def buildTree( basedir, srcdir, resdir )
|
|
22
|
|
23 objdir_abs = File.expand_path( OBJDIR )
|
|
24 dimpdir_abs = File.expand_path( DIMPDIR )
|
|
25 resdir_abs = File.expand_path( File.join( basedir, resdir ))
|
|
26 srcdir_abs = File.expand_path( File.join( basedir, srcdir ))
|
|
27 rspfile_abs = File.expand_path( RSPNAME )
|
|
28
|
|
29 FileUtils.mkdir_p dimpdir_abs
|
|
30 FileUtils.mkdir_p objdir_abs
|
|
31
|
|
32 puts "Create response file"
|
|
33 rsp = File.new( rspfile_abs, "w+" )
|
|
34 rsp.puts "-H"
|
|
35 rsp.puts "-I#{srcdir_abs.to_path}"
|
|
36 rsp.puts "-I#{dimpdir_abs.to_path}"
|
|
37 rsp.puts "-J#{resdir_abs.to_path}"
|
|
38 rsp.puts "-c"
|
|
39 rsp.puts "-op"
|
|
40 rsp.puts "-version=TANGOSVN"
|
|
41 Find.find( srcdir_abs ) do |path|
|
|
42 if path =~ /\.d$/ then
|
|
43 rsp.puts path.to_path
|
|
44 end
|
|
45 end
|
|
46 rsp.close
|
|
47
|
|
48 Dir.chdir(basedir) do
|
|
49 puts "Compile"
|
|
50 sh "#{DMD} @#{rspfile_abs.to_path}" do |ok, res|
|
|
51 raise "compile error" unless ok
|
|
52 end
|
|
53 end
|
|
54
|
|
55 puts "Move D Headers"
|
|
56 Find.find( srcdir_abs ) do |path|
|
|
57 if FileTest.file?(path) && path =~ /\.di$/ then
|
|
58 trgfile = File.join( dimpdir_abs, path[ srcdir_abs.length+1 .. -1 ])
|
|
59 FileUtils.mkdir_p File.dirname(trgfile)
|
|
60 FileUtils.mv path, trgfile
|
|
61 end
|
|
62 end
|
|
63
|
|
64 puts "Move Objects"
|
|
65 srcdirparts = split_all( srcdir_abs ).length
|
|
66 Find.find( srcdir_abs ) do |path|
|
|
67 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then
|
|
68 trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" )
|
|
69 FileUtils.mv path, File.join( objdir_abs, trgfile )
|
|
70 end
|
|
71 end
|
|
72
|
|
73 end
|
|
74
|
|
75 desc "Build Java"
|
|
76 task :java do
|
|
77 buildTree( "java", "src", "res" )
|
|
78 end
|
|
79
|
|
80 desc "Build SWT"
|
|
81 task :swt do
|
|
82 buildTree( "org.eclipse.swt.win32.win32.x86", "src", "res" )
|
|
83 end
|
|
84
|