Mercurial > projects > dwt2
comparison rakefile @ 28:69b1fa94a4a8
Added SWT snippets
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 22 Mar 2009 15:17:04 +0100 |
parents | 1bf55a6eb092 |
children | 4e5843b771cc |
comparison
equal
deleted
inserted
replaced
27:1bf55a6eb092 | 28:69b1fa94a4a8 |
---|---|
6 require 'find' | 6 require 'find' |
7 require 'fileutils' | 7 require 'fileutils' |
8 | 8 |
9 #DMD="c:\\project\\dmd-2.026\\dmd\\windows\\bin\\dmd.exe" | 9 #DMD="c:\\project\\dmd-2.026\\dmd\\windows\\bin\\dmd.exe" |
10 DMD="dmd" | 10 DMD="dmd" |
11 LOCALOBJDIR="obj" | 11 OBJDIR =File.expand_path("obj") |
12 OBJDIR="obj" | 12 DIMPDIR =File.expand_path("imp") |
13 DIMPDIR="imp" | 13 LIBDIR =File.expand_path("lib") |
14 RSPNAME="rsp" | 14 RSPNAME =File.expand_path("rsp") |
15 ALL_RESDIRS= [ "base/res", "res" ] | 15 ALL_RESDIRS= [ "base/res", "res" ] |
16 | |
17 LOG_STDOUT = File.expand_path("olog.txt") | |
18 LOG_STDERR = File.expand_path("elog.txt") | |
16 | 19 |
17 def isWindows | 20 def isWindows |
18 Config::CONFIG['host_os'] =~ /mswin/ | 21 Config::CONFIG['host_os'] =~ /mswin/ |
19 end | 22 end |
20 | 23 |
21 if isWindows | 24 if isWindows |
22 ALL_RESDIRS << "org.eclipse.swt.win32.win32.x86/res" | 25 ALL_RESDIRS << "org.eclipse.swt.win32.win32.x86/res" |
26 LIBEXT = ".lib" | |
27 OBJEXT = ".obj" | |
28 EXEEXT = ".exe" | |
23 else | 29 else |
24 ALL_RESDIRS << "org.eclipse.swt.gtk.linux.x86/res" | 30 ALL_RESDIRS << "org.eclipse.swt.gtk.linux.x86/res" |
31 LIBEXT = ".a" | |
32 OBJEXT = ".o" | |
33 EXEEXT = "" | |
25 end | 34 end |
26 | 35 |
27 class String | 36 class String |
28 def to_path | 37 def to_path |
29 if isWindows | 38 if isWindows |
32 self | 41 self |
33 end | 42 end |
34 end | 43 end |
35 end | 44 end |
36 | 45 |
37 def buildTree( basedir, srcdir, resdir, dcargs="" ) | 46 def buildTree( basedir, srcdir, resdir, dcargs="", libname="" ) |
38 puts "Building #{basedir}/#{srcdir}" | 47 puts "Building #{basedir}/#{srcdir}" |
39 | 48 |
40 objdir_abs = File.expand_path( OBJDIR ) | |
41 dimpdir_abs = File.expand_path( DIMPDIR ) | |
42 resdir_abs = File.expand_path( File.join( basedir, resdir )) | 49 resdir_abs = File.expand_path( File.join( basedir, resdir )) |
43 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) | 50 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) |
44 rspfile_abs = File.expand_path( RSPNAME ) | 51 |
45 | 52 FileUtils.mkdir_p DIMPDIR |
46 FileUtils.mkdir_p dimpdir_abs | 53 FileUtils.mkdir_p OBJDIR |
47 FileUtils.mkdir_p objdir_abs | 54 |
48 | 55 rsp = File.new( RSPNAME, "w+" ) |
49 rsp = File.new( rspfile_abs, "w+" ) | |
50 rsp.puts "-H" | 56 rsp.puts "-H" |
51 rsp.puts "-I#{srcdir_abs.to_path}" | 57 rsp.puts "-I#{srcdir_abs.to_path}" |
52 rsp.puts "-I#{dimpdir_abs.to_path}" | 58 rsp.puts "-I#{DIMPDIR.to_path}" |
53 rsp.puts "-J#{resdir_abs.to_path}" | 59 rsp.puts "-J#{resdir_abs.to_path}" |
54 if dcargs.size > 0 then | 60 if dcargs.size > 0 then |
55 rsp.puts dcargs | 61 rsp.puts dcargs |
56 end | 62 end |
57 ALL_RESDIRS.each do | dir | | 63 ALL_RESDIRS.each do | dir | |
66 end | 72 end |
67 rsp.close | 73 rsp.close |
68 | 74 |
69 Dir.chdir(basedir) do | 75 Dir.chdir(basedir) do |
70 if isWindows | 76 if isWindows |
71 cmd = "#{DMD} @#{rspfile_abs.to_path}" | 77 cmd = "#{DMD} @#{RSPNAME.to_path}" |
72 else | 78 else |
73 cmd = "cat #{rspfile_abs.to_path} | xargs #{DMD}" | 79 cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" |
74 end | 80 end |
75 sh cmd, :verbose => false do |ok, res| | 81 sh cmd, :verbose => false do |ok, res| |
76 if !ok then | 82 if !ok then |
77 Find.find( srcdir_abs ) do |path| | 83 Find.find( srcdir_abs ) do |path| |
78 if FileTest.file?(path) && path =~ /\.di$/ then | 84 if FileTest.file?(path) && path =~ /\.di$/ then |
85 end | 91 end |
86 end | 92 end |
87 | 93 |
88 Find.find( srcdir_abs ) do |path| | 94 Find.find( srcdir_abs ) do |path| |
89 if FileTest.file?(path) && path =~ /\.di$/ then | 95 if FileTest.file?(path) && path =~ /\.di$/ then |
90 trgfile = File.join( dimpdir_abs, path[ srcdir_abs.length+1 .. -1 ]) | 96 trgfile = File.join( DIMPDIR, path[ srcdir_abs.length+1 .. -1 ]) |
91 FileUtils.mkdir_p File.dirname(trgfile) | 97 FileUtils.mkdir_p File.dirname(trgfile) |
92 FileUtils.mv path, trgfile | 98 FileUtils.mv path, trgfile |
93 end | 99 end |
94 end | 100 end |
95 | 101 |
102 libobjs = Array.new | |
96 srcdirparts = split_all( srcdir_abs ).length | 103 srcdirparts = split_all( srcdir_abs ).length |
97 Find.find( srcdir_abs ) do |path| | 104 Find.find( srcdir_abs ) do |path| |
98 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then | 105 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then |
99 trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" ) | 106 trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" ) |
100 FileUtils.mv path, File.join( objdir_abs, trgfile ) | 107 FileUtils.mv path, File.join( OBJDIR, trgfile ) |
108 libobjs << File.join( OBJDIR, trgfile ) | |
109 end | |
110 end | |
111 | |
112 if libname.size == 0 | |
113 libname = basedir | |
114 end | |
115 createLib( libobjs, libname ) | |
116 end | |
117 | |
118 def createLib( libobjs, name ) | |
119 FileUtils.mkdir_p LIBDIR.to_path | |
120 rsp = File.new( RSPNAME, "w+" ) | |
121 rsp.puts "-p512 -n -c #{LIBDIR}/#{name}#{LIBEXT}" | |
122 libobjs.each do |obj| | |
123 rsp.puts obj.to_path | |
124 end | |
125 rsp.close | |
126 cmd = "lib @#{RSPNAME} > #{LOG_STDOUT}" | |
127 sh cmd, :verbose => false do |ok, res| | |
128 if !ok then | |
129 raise "librarian error" | |
101 end | 130 end |
102 end | 131 end |
103 | 132 |
104 end | 133 end |
105 | 134 |
106 desc "Clean" | 135 desc "Clean" |
107 task :clean do | 136 task :clean do |
108 puts "Cleaning" | 137 puts "Cleaning" |
109 FileUtils.rm_rf DIMPDIR | 138 FileUtils.rm_rf DIMPDIR |
110 FileUtils.rm_rf OBJDIR | 139 FileUtils.rm_rf OBJDIR |
111 FileUtils.rm_rf RSPNAME | 140 FileUtils.rm_rf LIBDIR |
141 FileUtils.rm RSPNAME | |
142 FileUtils.rm LOG_STDOUT | |
143 FileUtils.rm LOG_STDERR | |
112 end | 144 end |
113 | 145 |
114 desc "Build Base (Java Environment and Helpers)" | 146 desc "Build Base (Java Environment and Helpers)" |
115 task :base do | 147 task :base do |
116 buildTree( "base", "src", "res" ) | 148 buildTree( "base", "src", "res", "", "dwt-base" ) |
117 end | 149 end |
118 | 150 |
119 desc "Build SWT" | 151 desc "Build SWT" |
120 task :swt do | 152 task :swt do |
121 if isWindows | 153 if isWindows |
145 end | 177 end |
146 | 178 |
147 desc "Build JFace.Text" | 179 desc "Build JFace.Text" |
148 task :jfacetext do | 180 task :jfacetext do |
149 buildTree( "org.eclipse.text", "src", "res" ) | 181 buildTree( "org.eclipse.text", "src", "res" ) |
150 buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc" ) | 182 buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc", "org.eclipse.jface.text.projection" ) |
151 buildTree( "org.eclipse.jface.text", "src", "res" ) | 183 buildTree( "org.eclipse.jface.text", "src", "res" ) |
152 end | 184 end |
153 | 185 |
154 desc "Build UI Forms" | 186 desc "Build UI Forms" |
155 task :uiforms do | 187 task :uiforms do |