| 1 |
require 'fileutils' |
|---|
| 2 |
require 'find' |
|---|
| 3 |
require 'rake/clean' |
|---|
| 4 |
require 'rbconfig' |
|---|
| 5 |
|
|---|
| 6 |
if RUBY_PLATFORM =~ /mswin/i |
|---|
| 7 |
puts "For WIN32" |
|---|
| 8 |
|
|---|
| 9 |
SWT_PLATFORM = "win32" |
|---|
| 10 |
BIN_EXT = ".exe" |
|---|
| 11 |
DSSS_PROFILE = " -dc=dmd-win-tango" |
|---|
| 12 |
def P(path) |
|---|
| 13 |
return path.gsub( /\//, "\\" ) |
|---|
| 14 |
end |
|---|
| 15 |
|
|---|
| 16 |
elsif RUBY_PLATFORM =~ /linux/i |
|---|
| 17 |
puts "For LINUX" |
|---|
| 18 |
|
|---|
| 19 |
SWT_PLATFORM = "linux-gtk" |
|---|
| 20 |
|
|---|
| 21 |
BIN_EXT = "" |
|---|
| 22 |
DSSS_PROFILE = " -dc=dmd-posix-tango" |
|---|
| 23 |
def P(path) |
|---|
| 24 |
return path |
|---|
| 25 |
end |
|---|
| 26 |
|
|---|
| 27 |
elsif RUBY_PLATFORM =~ /darwin/i |
|---|
| 28 |
puts "For MAC OSX" |
|---|
| 29 |
|
|---|
| 30 |
SWT_PLATFORM = "macos" |
|---|
| 31 |
BIN_EXT = "" |
|---|
| 32 |
DSSS_PROFILE = " -dc=dmd-posix-tango" |
|---|
| 33 |
|
|---|
| 34 |
def P(path) |
|---|
| 35 |
return path |
|---|
| 36 |
end |
|---|
| 37 |
|
|---|
| 38 |
else |
|---|
| 39 |
puts "OS not detected" |
|---|
| 40 |
end |
|---|
| 41 |
|
|---|
| 42 |
BIN_DIR = "bin" |
|---|
| 43 |
BINTOD_DIR = "bintod" |
|---|
| 44 |
BINTOD_CMD = File.expand_path( P("bintod/bintod#{BIN_EXT}")) |
|---|
| 45 |
TIOPORT_CMD = File.expand_path( P("tioport/tioport#{BIN_EXT}")) |
|---|
| 46 |
JAVA_CMD = P("/usr/lib/j2sdk1.5-sun/bin/java#{BIN_EXT}") |
|---|
| 47 |
|
|---|
| 48 |
DSSS_PREFIX = if ENV.has_key?('DSSS_PREFIX' ) |
|---|
| 49 |
ENV['DSSS_PREFIX'] |
|---|
| 50 |
else |
|---|
| 51 |
nil |
|---|
| 52 |
end |
|---|
| 53 |
DSSS_BIN = if DSSS_PREFIX == nil |
|---|
| 54 |
"dsss" |
|---|
| 55 |
else |
|---|
| 56 |
P("#{DSSS_PREFIX}/bin/dsss") |
|---|
| 57 |
end |
|---|
| 58 |
DSSS_USE = if DSSS_PREFIX == nil |
|---|
| 59 |
"" |
|---|
| 60 |
else |
|---|
| 61 |
P(" --use=#{DSSS_PREFIX}") |
|---|
| 62 |
end |
|---|
| 63 |
|
|---|
| 64 |
SWT_VERSION = "3.2.1" |
|---|
| 65 |
SWT_PORT = "swt-#{SWT_VERSION}-#{SWT_PLATFORM}" |
|---|
| 66 |
SWT_EXAMPLES = "swt-#{SWT_VERSION}-examples" |
|---|
| 67 |
|
|---|
| 68 |
directory BIN_DIR |
|---|
| 69 |
|
|---|
| 70 |
CLEAN.include( BINTOD_CMD ) |
|---|
| 71 |
|
|---|
| 72 |
desc "build the tioport converter" |
|---|
| 73 |
file TIOPORT_CMD do |
|---|
| 74 |
runDsss "tioport", "build" |
|---|
| 75 |
end |
|---|
| 76 |
|
|---|
| 77 |
desc "build the BinToD tool" |
|---|
| 78 |
file BINTOD_CMD do |
|---|
| 79 |
runDsss "bintod", "build" |
|---|
| 80 |
end |
|---|
| 81 |
|
|---|
| 82 |
def runDsss( path, target ) |
|---|
| 83 |
runInPath( path ) do |
|---|
| 84 |
sh "#{DSSS_BIN} #{target}#{DSSS_USE}#{DSSS_PROFILE}" |
|---|
| 85 |
end |
|---|
| 86 |
end |
|---|
| 87 |
|
|---|
| 88 |
desc "build+install Dejavu" |
|---|
| 89 |
task :dejavu do |
|---|
| 90 |
|
|---|
| 91 |
runDsss "dejavu", "build" |
|---|
| 92 |
runDsss "dejavu", "install" |
|---|
| 93 |
|
|---|
| 94 |
end |
|---|
| 95 |
|
|---|
| 96 |
desc "build+install SWT 3.2.1" |
|---|
| 97 |
task :swt321 => [ BINTOD_CMD ] do |
|---|
| 98 |
|
|---|
| 99 |
runDsss SWT_PORT, "build" |
|---|
| 100 |
runDsss SWT_PORT, "install" |
|---|
| 101 |
|
|---|
| 102 |
end |
|---|
| 103 |
|
|---|
| 104 |
def runInPath( path ) |
|---|
| 105 |
cwd = FileUtils.pwd |
|---|
| 106 |
FileUtils.cd path, :verbose => true |
|---|
| 107 |
yield( path ) |
|---|
| 108 |
ensure |
|---|
| 109 |
FileUtils.cd cwd, :verbose => true |
|---|
| 110 |
end |
|---|
| 111 |
|
|---|
| 112 |
examples = FileList[ |
|---|
| 113 |
"addressbook", |
|---|
| 114 |
#"browser", |
|---|
| 115 |
"clipboard", |
|---|
| 116 |
"control", |
|---|
| 117 |
"dnd", |
|---|
| 118 |
"graphics", |
|---|
| 119 |
"helloworld1", |
|---|
| 120 |
"helloworld2", |
|---|
| 121 |
"helloworld3", |
|---|
| 122 |
"helloworld4", |
|---|
| 123 |
"helloworld5", |
|---|
| 124 |
"hoverhelp", |
|---|
| 125 |
"imageanalyzer", |
|---|
| 126 |
"javaviewer", |
|---|
| 127 |
"layoutexample", |
|---|
| 128 |
"paint", |
|---|
| 129 |
#"texteditor", |
|---|
| 130 |
"wizard", |
|---|
| 131 |
] |
|---|
| 132 |
|
|---|
| 133 |
desc "Build all the examples and everything that it depends on" |
|---|
| 134 |
task :swt321_examples |
|---|
| 135 |
|
|---|
| 136 |
examples.each do |t| |
|---|
| 137 |
binary = P("#{SWT_EXAMPLES}/#{t}#{BIN_EXT}") |
|---|
| 138 |
source = P("#{SWT_EXAMPLES}/#{t}.d") |
|---|
| 139 |
resources = P("#{SWT_EXAMPLES}/resources_#{t}.d") |
|---|
| 140 |
resources_cfg = P("#{SWT_EXAMPLES}/resources_#{t}.xml") |
|---|
| 141 |
file resources => [resources_cfg, BINTOD_CMD] do |
|---|
| 142 |
runInPath SWT_EXAMPLES do |
|---|
| 143 |
sh P("../#{BINTOD_CMD} resources_#{t}.xml") |
|---|
| 144 |
end |
|---|
| 145 |
end |
|---|
| 146 |
desc "build #{binary}" |
|---|
| 147 |
file binary => [ resources, source ] do |
|---|
| 148 |
runDsss SWT_EXAMPLES, "build #{t}.d" |
|---|
| 149 |
end |
|---|
| 150 |
task :swt321_examples => binary |
|---|
| 151 |
CLEAN.include binary |
|---|
| 152 |
end |
|---|
| 153 |
|
|---|
| 154 |
desc "convert SWT 3.2.1 linux-gtk (only working on linux)" |
|---|
| 155 |
task :conv_swt321_linux => [ TIOPORT_CMD ] do |
|---|
| 156 |
swt_zip = P("resources/swt-3.2.1-gtk-linux-x86.zip") |
|---|
| 157 |
examples_zip = P("resources/swt-examples.zip") |
|---|
| 158 |
path = P("ports/swt-3.2.1/swt-3.2.1-linux-gtk") |
|---|
| 159 |
if ! File.exists?( "#{path}/src.orig" ) |
|---|
| 160 |
puts "=== extract source ===" |
|---|
| 161 |
FileUtils.rm_rf P( "#{path}/src.orig" ) |
|---|
| 162 |
|
|---|
| 163 |
FileUtils.mkdir P( "#{path}/src.orig" ) |
|---|
| 164 |
sh "unzip -jq #{swt_zip} swt-M20060921-0945-gtk-linux-x86/src.zip -d #{path}/src.orig" |
|---|
| 165 |
sh "unzip -q #{examples_zip} -d #{path}/src.orig" |
|---|
| 166 |
sh "unzip -q #{path}/src.orig/src.zip -d #{path}/src.orig" |
|---|
| 167 |
FileUtils.rm_rf FileList[ |
|---|
| 168 |
"#{path}/src.orig/*.c", |
|---|
| 169 |
"#{path}/src.orig/*.cpp", |
|---|
| 170 |
"#{path}/src.orig/*.h", |
|---|
| 171 |
"#{path}/src.orig/src.zip", |
|---|
| 172 |
"#{path}/src.orig/make_*.mak", |
|---|
| 173 |
"#{path}/src.orig/*.html", |
|---|
| 174 |
"#{path}/src.orig/mozilla_exports", |
|---|
| 175 |
"#{path}/src.orig/about*", |
|---|
| 176 |
"#{path}/src.orig/build*"] |
|---|
| 177 |
FileUtils.rm_rf P( "#{path}/src.patched" ) |
|---|
| 178 |
end |
|---|
| 179 |
if ! File.exists?( "#{path}/src.patched" ) |
|---|
| 180 |
puts "=== create patched sources ===" |
|---|
| 181 |
FileUtils.rm_rf P( "#{path}/gen.xml" ) |
|---|
| 182 |
|
|---|
| 183 |
FileUtils.cp_r "#{path}/src.orig", "#{path}/src.patched" |
|---|
| 184 |
sh "patch -d #{path}/src.patched -p1 -i ../swt-orig.patch" |
|---|
| 185 |
end |
|---|
| 186 |
puts "=== run convertion ===" |
|---|
| 187 |
FileUtils.rm_rf P( "#{path}/gen.d" ) |
|---|
| 188 |
FileUtils.mkdir "#{path}/gen.d" |
|---|
| 189 |
|
|---|
| 190 |
config = File.expand_path( P("#{path}/swt-3.2.1-linux-gtk.xml")) |
|---|
| 191 |
JXMLCONV = File.expand_path( P("javaxmlconverter/javaxmlconvert.jar" )) |
|---|
| 192 |
runInPath path do |
|---|
| 193 |
sh "#{JAVA_CMD} -cp #{JXMLCONV} javaxmlconvert.JavaXmlConverter #{config}" |
|---|
| 194 |
sh "#{TIOPORT_CMD} #{config}" |
|---|
| 195 |
end |
|---|
| 196 |
|
|---|
| 197 |
# deploy |
|---|
| 198 |
puts "=== deploy ===" |
|---|
| 199 |
FileUtils.rm_rf P( "#{path}/deploy" ) |
|---|
| 200 |
FileUtils.cp_r "#{path}/gen.d", "#{path}/deploy" |
|---|
| 201 |
FileUtils.rm_rf P( "#{path}/deploy/org/eclipse/swt/examples" ) |
|---|
| 202 |
gen_dir = P("#{path}/deploy" ) |
|---|
| 203 |
deploy_dir = P("swt-3.2.1-linux-gtk" ) |
|---|
| 204 |
Find.find( P("#{gen_dir}/org/eclipse/swt") ) do |fpath| |
|---|
| 205 |
relpath = fpath.slice( gen_dir.length, fpath.length ) |
|---|
| 206 |
puts relpath |
|---|
| 207 |
if FileTest.directory?(fpath) |
|---|
| 208 |
newdir = deploy_dir + "/src" + relpath |
|---|
| 209 |
FileUtils.mkdir_p( newdir ) |
|---|
| 210 |
puts "copying to #{newdir}" |
|---|
| 211 |
next |
|---|
| 212 |
else |
|---|
| 213 |
FileUtils.cp( fpath, deploy_dir + "/src" + relpath ) |
|---|
| 214 |
end |
|---|
| 215 |
end |
|---|
| 216 |
|
|---|
| 217 |
FileUtils.cp( FileList.new( P("#{path}/libs/*")).to_ary, deploy_dir + "/lib" ) |
|---|
| 218 |
end |
|---|
| 219 |
|
|---|
| 220 |
desc "convert SWT 3.2.1 win32 (only working on linux)" |
|---|
| 221 |
task :conv_swt321_win32 => [ TIOPORT_CMD ] do |
|---|
| 222 |
swt_zip = P("resources/swt-3.2.1-win32-win32-x86.zip") |
|---|
| 223 |
examples_zip = P("resources/swt-examples.zip") |
|---|
| 224 |
path = P("ports/swt-3.2.1/swt-3.2.1-win32") |
|---|
| 225 |
|
|---|
| 226 |
if ! File.exists?( "#{path}/src.orig" ) |
|---|
| 227 |
puts "=== extract source ===" |
|---|
| 228 |
FileUtils.rm_rf P( "#{path}/src.orig" ) |
|---|
| 229 |
|
|---|
| 230 |
FileUtils.mkdir P( "#{path}/src.orig" ) |
|---|
| 231 |
sh "unzip -jq #{swt_zip} swt-M20060921-0945-win32-win32-x86/src.zip -d #{path}/src.orig" |
|---|
| 232 |
sh "unzip -q #{examples_zip} -d #{path}/src.orig" |
|---|
| 233 |
sh "unzip -q #{path}/src.orig/src.zip -d #{path}/src.orig" |
|---|
| 234 |
FileUtils.rm_rf FileList[ |
|---|
| 235 |
"#{path}/src.orig/*.c", |
|---|
| 236 |
"#{path}/src.orig/*.cpp", |
|---|
| 237 |
"#{path}/src.orig/*.h", |
|---|
| 238 |
"#{path}/src.orig/src.zip", |
|---|
| 239 |
"#{path}/src.orig/make_*.mak", |
|---|
| 240 |
"#{path}/src.orig/*.html", |
|---|
| 241 |
"#{path}/src.orig/about*", |
|---|
| 242 |
"#{path}/src.orig/build*"] |
|---|
| 243 |
FileUtils.rm_rf P( "#{path}/src.patched" ) |
|---|
| 244 |
end |
|---|
| 245 |
if ! File.exists?( "#{path}/src.patched" ) |
|---|
| 246 |
puts "=== create patched sources ===" |
|---|
| 247 |
FileUtils.rm_rf P( "#{path}/gen.xml" ) |
|---|
| 248 |
|
|---|
| 249 |
FileUtils.cp_r "#{path}/src.orig", "#{path}/src.patched" |
|---|
| 250 |
sh "patch -d #{path}/src.patched -p1 -i ../swt-orig.patch" |
|---|
| 251 |
end |
|---|
| 252 |
puts "=== run convertion ===" |
|---|
| 253 |
FileUtils.rm_rf P( "#{path}/gen.d" ) |
|---|
| 254 |
FileUtils.mkdir "#{path}/gen.d" |
|---|
| 255 |
|
|---|
| 256 |
config = File.expand_path( P("#{path}/swt-3.2.1-win32.xml")) |
|---|
| 257 |
JXMLCONV = File.expand_path( P("javaxmlconverter/javaxmlconvert.jar" )) |
|---|
| 258 |
runInPath path do |
|---|
| 259 |
sh "#{JAVA_CMD} -cp #{JXMLCONV} javaxmlconvert.JavaXmlConverter #{config}" |
|---|
| 260 |
sh "#{TIOPORT_CMD} #{config}" |
|---|
| 261 |
end |
|---|
| 262 |
|
|---|
| 263 |
# deploy |
|---|
| 264 |
puts "=== deploy ===" |
|---|
| 265 |
FileUtils.rm_rf P( "#{path}/deploy" ) |
|---|
| 266 |
FileUtils.cp_r "#{path}/gen.d", "#{path}/deploy" |
|---|
| 267 |
FileUtils.rm_rf P( "#{path}/deploy/org/eclipse/swt/examples" ) |
|---|
| 268 |
gen_dir = P("#{path}/deploy" ) |
|---|
| 269 |
deploy_dir = P("swt-3.2.1-win32" ) |
|---|
| 270 |
Find.find( P("#{gen_dir}/org/eclipse/swt") ) do |fpath| |
|---|
| 271 |
relpath = fpath.slice( gen_dir.length, fpath.length ) |
|---|
| 272 |
puts relpath |
|---|
| 273 |
if FileTest.directory?(fpath) |
|---|
| 274 |
FileUtils.mkdir_p( deploy_dir + "/src" + relpath ) |
|---|
| 275 |
next |
|---|
| 276 |
else |
|---|
| 277 |
FileUtils.cp( fpath, deploy_dir + "/src" + relpath ) |
|---|
| 278 |
end |
|---|
| 279 |
end |
|---|
| 280 |
|
|---|
| 281 |
FileUtils.cp( FileList.new( P("#{path}/libs/*")).to_ary, deploy_dir + "/lib" ) |
|---|
| 282 |
end |
|---|