Mercurial > projects > dwt2
annotate 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 |
rev | line source |
---|---|
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 | |
8 | 9 #DMD="c:\\project\\dmd-2.026\\dmd\\windows\\bin\\dmd.exe" |
10 DMD="dmd" | |
28 | 11 OBJDIR =File.expand_path("obj") |
12 DIMPDIR =File.expand_path("imp") | |
13 LIBDIR =File.expand_path("lib") | |
14 RSPNAME =File.expand_path("rsp") | |
27 | 15 ALL_RESDIRS= [ "base/res", "res" ] |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
16 |
28 | 17 LOG_STDOUT = File.expand_path("olog.txt") |
18 LOG_STDERR = File.expand_path("elog.txt") | |
19 | |
25 | 20 def isWindows |
21 Config::CONFIG['host_os'] =~ /mswin/ | |
22 end | |
23 | |
24 if isWindows | |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
25 ALL_RESDIRS << "org.eclipse.swt.win32.win32.x86/res" |
28 | 26 LIBEXT = ".lib" |
27 OBJEXT = ".obj" | |
28 EXEEXT = ".exe" | |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
29 else |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
30 ALL_RESDIRS << "org.eclipse.swt.gtk.linux.x86/res" |
28 | 31 LIBEXT = ".a" |
32 OBJEXT = ".o" | |
33 EXEEXT = "" | |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
34 end |
1 | 35 |
36 class String | |
37 def to_path | |
25 | 38 if isWindows |
39 self.gsub( '/', '\\' ); | |
40 else | |
41 self | |
42 end | |
1 | 43 end |
44 end | |
45 | |
28 | 46 def buildTree( basedir, srcdir, resdir, dcargs="", libname="" ) |
20 | 47 puts "Building #{basedir}/#{srcdir}" |
1 | 48 |
49 resdir_abs = File.expand_path( File.join( basedir, resdir )) | |
50 srcdir_abs = File.expand_path( File.join( basedir, srcdir )) | |
51 | |
28 | 52 FileUtils.mkdir_p DIMPDIR |
53 FileUtils.mkdir_p OBJDIR | |
1 | 54 |
28 | 55 rsp = File.new( RSPNAME, "w+" ) |
1 | 56 rsp.puts "-H" |
57 rsp.puts "-I#{srcdir_abs.to_path}" | |
28 | 58 rsp.puts "-I#{DIMPDIR.to_path}" |
1 | 59 rsp.puts "-J#{resdir_abs.to_path}" |
16
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
60 if dcargs.size > 0 then |
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
61 rsp.puts dcargs |
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
62 end |
3
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
63 ALL_RESDIRS.each do | dir | |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
64 rsp.puts "-J#{File.expand_path(dir).to_path}" |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
65 end |
1 | 66 rsp.puts "-c" |
67 rsp.puts "-op" | |
68 Find.find( srcdir_abs ) do |path| | |
69 if path =~ /\.d$/ then | |
70 rsp.puts path.to_path | |
71 end | |
72 end | |
73 rsp.close | |
74 | |
75 Dir.chdir(basedir) do | |
25 | 76 if isWindows |
28 | 77 cmd = "#{DMD} @#{RSPNAME.to_path}" |
25 | 78 else |
28 | 79 cmd = "cat #{RSPNAME.to_path} | xargs #{DMD}" |
25 | 80 end |
81 sh cmd, :verbose => false do |ok, res| | |
3
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
82 if !ok then |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
83 Find.find( srcdir_abs ) do |path| |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
84 if FileTest.file?(path) && path =~ /\.di$/ then |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
85 FileUtils.rm path |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
86 end |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
87 end |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
88 |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
89 raise "compile error" |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
90 end |
1 | 91 end |
92 end | |
93 | |
94 Find.find( srcdir_abs ) do |path| | |
95 if FileTest.file?(path) && path =~ /\.di$/ then | |
28 | 96 trgfile = File.join( DIMPDIR, path[ srcdir_abs.length+1 .. -1 ]) |
1 | 97 FileUtils.mkdir_p File.dirname(trgfile) |
98 FileUtils.mv path, trgfile | |
99 end | |
100 end | |
101 | |
28 | 102 libobjs = Array.new |
1 | 103 srcdirparts = split_all( srcdir_abs ).length |
104 Find.find( srcdir_abs ) do |path| | |
105 if FileTest.file?(path) && path =~ /\.o(bj)?$/ then | |
106 trgfile = split_all( path )[ srcdirparts .. -1 ].join( "-" ) | |
28 | 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" | |
1 | 130 end |
131 end | |
132 | |
133 end | |
134 | |
3
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
135 desc "Clean" |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
136 task :clean do |
20 | 137 puts "Cleaning" |
3
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
138 FileUtils.rm_rf DIMPDIR |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
139 FileUtils.rm_rf OBJDIR |
28 | 140 FileUtils.rm_rf LIBDIR |
141 FileUtils.rm RSPNAME | |
142 FileUtils.rm LOG_STDOUT | |
143 FileUtils.rm LOG_STDERR | |
3
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
144 end |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
145 |
27 | 146 desc "Build Base (Java Environment and Helpers)" |
147 task :base do | |
28 | 148 buildTree( "base", "src", "res", "", "dwt-base" ) |
1 | 149 end |
150 | |
151 desc "Build SWT" | |
152 task :swt do | |
25 | 153 if isWindows |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
154 buildTree( "org.eclipse.swt.win32.win32.x86", "src", "res" ) |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
155 else |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
156 buildTree( "org.eclipse.swt.gtk.linux.x86", "src", "res" ) |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
157 end |
1 | 158 end |
159 | |
20 | 160 desc "Build Equinox" |
161 task :equinox do | |
16
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
162 buildTree( "org.eclipse.osgi", "src", "res" ) |
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
163 buildTree( "org.eclipse.osgi", "supplement/src", "res" ) |
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
164 buildTree( "org.eclipse.equinox.common", "src", "res" ) |
20 | 165 end |
166 | |
167 desc "Build Eclipse Core" | |
168 task :core do | |
16
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
169 buildTree( "org.eclipse.core.runtime", "src", "res" ) |
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
170 buildTree( "org.eclipse.core.commands", "src", "res" ) |
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
171 buildTree( "org.eclipse.core.jobs", "src", "res" ) |
20 | 172 end |
173 | |
174 desc "Build JFace" | |
175 task :jface do | |
16
dbfb303e8fb0
first complete successful compile (win-only)
Frank Benoit <benoit@tionex.de>
parents:
12
diff
changeset
|
176 buildTree( "org.eclipse.jface", "src", "res" ) |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
177 end |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
178 |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
179 desc "Build JFace.Text" |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
180 task :jfacetext do |
12
bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
8
diff
changeset
|
181 buildTree( "org.eclipse.text", "src", "res" ) |
28 | 182 buildTree( "org.eclipse.jface.text", "projection", "res", "-Isrc", "org.eclipse.jface.text.projection" ) |
12
bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
8
diff
changeset
|
183 buildTree( "org.eclipse.jface.text", "src", "res" ) |
20 | 184 end |
185 | |
186 desc "Build UI Forms" | |
187 task :uiforms do | |
12
bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
8
diff
changeset
|
188 buildTree( "org.eclipse.ui.forms", "src", "res" ) |
20 | 189 end |
190 | |
191 desc "Build Draw2D" | |
192 task :draw2d do | |
12
bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
Frank Benoit <benoit@tionex.de>
parents:
8
diff
changeset
|
193 buildTree( "org.eclipse.draw2d", "src", "res" ) |
3
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
194 end |
4c0057e71936
Made a class for StringBuffer
Frank Benoit <benoit@tionex.de>
parents:
1
diff
changeset
|
195 |
20 | 196 desc "Build ALL" |
27 | 197 task :all => [ :base, :swt, :equinox, :core, :jface, :jfacetext, :uiforms, |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
198 :draw2d ] |
20 | 199 |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
20
diff
changeset
|
200 desc "Clean, then build ALL" |
20 | 201 task :default => [ :clean, :all ] |
202 | |
203 |