comparison buildHelper.d @ 183:190ba98276b3

Several changes to make it build on posix systems. I've only tried to build on Mac OS X but it should build on Linux now as well. This should also fix ticket #9.
author Jacob Carlborg <doob@me.com>
date Mon, 25 Oct 2010 15:36:13 +0200
parents 0622fff7810a
children 1a0c1126bc46
comparison
equal deleted inserted replaced
181:aa70dca07cb0 183:190ba98276b3
8 import std.string: replace, format; 8 import std.string: replace, format;
9 import std.zip; 9 import std.zip;
10 10
11 enum dmdVersionDefault = "2.040"; 11 enum dmdVersionDefault = "2.040";
12 enum dmdArchiveBaseURL = "http://ftp.digitalmars.com/"; 12 enum dmdArchiveBaseURL = "http://ftp.digitalmars.com/";
13 enum dmdLib = "dmd.lib"; 13 enum dmd = "dmd";
14
14 version(Windows) 15 version(Windows)
15 { 16 {
16 enum scriptName = "build.bat"; 17 enum scriptName = "build.bat";
17 enum osSubDir = "windows"; 18 enum osSubDir = "windows";
18 enum configFile = "sc.ini"; 19 enum configFile = "sc.ini";
19 enum execExt = ".exe"; 20 enum execExt = ".exe";
21 enum dmdLib = "dmd.lib";
20 } 22 }
21 else 23 else
22 { 24 {
25 version (OSX)
26 enum osSubDir = "osx";
27
28 else version (linux)
29 enum osSubDir = "linux";
30
23 enum scriptName = "./build.sh"; 31 enum scriptName = "./build.sh";
24 enum osSubDir = "linux";
25 enum configFile = "dmd.conf"; 32 enum configFile = "dmd.conf";
26 enum execExt = ""; 33 enum execExt = "";
34 enum dmdLib = "libdmd.a";
27 } 35 }
28 36
29 string dmdVersion; 37 string dmdVersion;
30 string dmdPackage; 38 string dmdPackage;
31 string dmdArchive; 39 string dmdArchive;
181 doChDir("dmd2/src/dmd"); 189 doChDir("dmd2/src/dmd");
182 version(Windows) 190 version(Windows)
183 enum makefile = "win32.mak"; 191 enum makefile = "win32.mak";
184 else 192 else
185 { 193 {
186 enum makefile = "linux_lib.mak"; 194 version (linux)
195 enum makefile = "linux_lib.mak";
196
197 else version (OSX)
198 enum makefile = "osx_lib.mak";
199
187 doCopy("../../../"~makefile, makefile); 200 doCopy("../../../"~makefile, makefile);
188 } 201 }
189 202
190 version(Windows) 203 version(Windows)
191 copyAndPatch(makefile, makefile, (ref string data) { 204 copyAndPatch(makefile, makefile, (ref string data) {
202 // Build dmd.lib 215 // Build dmd.lib
203 version(Windows) 216 version(Windows)
204 doSystem("make deblib -f"~makefile); 217 doSystem("make deblib -f"~makefile);
205 else 218 else
206 doSystem("make -f"~makefile); 219 doSystem("make -f"~makefile);
207 doCopy("dmd.lib", "../../../dmd.lib"); 220 doCopy(dmdLib, "../../../" ~ dmdLib);
208 221
209 // Copy and patch config file 222 // Copy and patch config file
210 doChDir("../../.."); 223 doChDir("../../..");
211 copyAndPatch( 224 copyAndPatch(
212 normFilePath("dmd2/"~osSubDir~"/bin/"~configFile), 225 normFilePath("dmd2/"~osSubDir~"/bin/"~configFile),
213 normFilePath("bin/"~configFile), 226 normFilePath("bin/"~configFile),
214 (ref string data) { 227 (ref string data) {
215 data = data.replace(normDirPath("../.."), normDirPath("../dmd2")); 228 data = data.replace(normDirPath("../.."), normDirPath("../dmd2"));
216 data = data.replace(normDirPath("../lib"), normDirPath("../dmd2/"~osSubDir~"/lib")); 229 data = data.replace(normDirPath("../lib")[0 .. $ - 1], normDirPath("../dmd2/"~osSubDir~"/lib")[0 .. $ - 1]);
217 } 230 }
218 ); 231 );
219 232
220 // Copy linker 233 // Copy linker
221 doCopy("dmd2/"~osSubDir~"/bin/link"~execExt, "bin/link"~execExt); 234 version (Windows)
235 doCopy("dmd2/"~osSubDir~"/bin/link"~execExt, "bin/link"~execExt);
222 236
223 return true; 237 return true;
224 } 238 }
225 239
226 int main(string[] args) 240 int main(string[] args)
315 int ret=0; 329 int ret=0;
316 version(Windows) 330 version(Windows)
317 { 331 {
318 system("cls"); 332 system("cls");
319 if(ret == 0) ret = doSystem(r"dmc.exe bridge\bridge.cpp -c"); 333 if(ret == 0) ret = doSystem(r"dmc.exe bridge\bridge.cpp -c");
320 if(!releaseOnly) if(ret == 0) ret = doSystem(r"dmd -debug -g @commands.txt"); 334 if(!releaseOnly) if(ret == 0) ret = doSystem(dmd ~ r" -debug -g @commands.txt");
321 if(!debugOnly) if(ret == 0) ret = doSystem(r"dmd -release -O -inline @commands.txt"); 335 if(!debugOnly) if(ret == 0) ret = doSystem(dmd ~ r" -release -O -inline @commands.txt");
322 } 336 }
323 else 337 else
324 { 338 {
325 if(ret == 0) ret = doSystem("g++ -c bridge/bridge.cpp -obridge.o"); 339 version (linux)
326 if(!releaseOnly) if(ret == 0) ret = doSystem("dmd -debug -gc @commands.linux.txt"); 340 auto commands = "@commands.linux.txt";
327 if(!debugOnly) if(ret == 0) ret = doSystem("dmd -release -O -inline @commands.linux.txt"); 341
342 else version (OSX)
343 auto commands = "@commands.osx.txt";
344
345 if(ret == 0) ret = doSystem("g++ -m32 -c bridge/bridge.cpp -obridge.o");
346 if(!releaseOnly) if(ret == 0) ret = doSystem(dmd ~ " -debug -gc " ~ commands);
347 if(!debugOnly) if(ret == 0) ret = doSystem(dmd ~ " -release -O -inline " ~ commands);
328 } 348 }
329 349
330 return ret; 350 return ret;
331 } 351 }