Changeset 221
- Timestamp:
- 02/01/07 10:41:54 (2 years ago)
- Files:
-
- trunk/buildme.d (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/buildme.d
r220 r221 5 5 import std.stdio; 6 6 import std.string; 7 import std.c.string; 7 8 import std.c.process; 8 9 import std.file; … … 17 18 else version(linux) 18 19 { 19 private static const char[] libPre = "lib";20 private static const char[] delCmd = "rm -f "; 20 21 21 22 } 22 23 else version(Unix) 23 24 { 24 private static const char[] libPre = "lib";25 private static const char[] delCmd = "rm -f "; 25 26 26 27 } … … 58 59 private static const char[] objExt = ".obj"; 59 60 private static const char[] libExt = ".lib"; 60 private static const char[] libCmd = "@lib -c -n "; 61 private static const char[] libNewCmd = "@lib -p512 -c -n "; 62 private static const char[] libCmd = "@lib -p1024 -n "; 61 63 private static const char[] libPre = ""; 62 64 } … … 203 205 //============================================================================== 204 206 // DMD & GDMD 205 private char[] processPackage(char[] dir)207 private void processPackage(char[] dir, inout char[][] buffer) 206 208 { 207 209 writefln("Processing %s", dir); … … 222 224 if(isdir(c)) 223 225 { 224 fileList ~= processPackage(c);226 processPackage(c, buffer); 225 227 } 226 228 // otherwise, if it is a D source file, append it to the return string … … 229 231 if(c[$-2 .. $].cmp(".d") == 0) 230 232 { 233 writefln("Found source file %s", c); 231 234 fileList = fileList ~ " " ~ c; 232 235 } 233 236 } 234 237 } 235 return fileList; 238 239 buffer ~= fileList; 236 240 } 237 241 … … 239 243 { 240 244 // build a list of source files 241 char[] fileList = processPackage(packageName); 242 char[][] files = fileList.split(); 243 245 char[][] fileList; 246 processPackage(packageName, fileList); 247 foreach(c; fileList) 248 writefln(c); 249 244 250 // build up an import list from forBuild.txt 245 251 char[] importList = "-IDerelictUtil -I" ~ packageName; … … 256 262 auto flags = importList ~ COMPILE_FLAGS_COMMON; 257 263 flags ~= (mode == Mode.Debug) ? COMPILE_FLAGS_DEBUG : COMPILE_FLAGS_RELEASE; 258 foreach(c; files) 259 { 260 writefln("Compiling source file %s", c); 261 auto cmdline = compilerCmd ~ flags ~ c; 262 if(system(toStringz(cmdline)) != 0) 263 { 264 throw new Exception("Failed to compile " ~ c); 265 } 266 } 267 268 // replace each .d extension with the proper object file extension for the linker 269 fileList = fileList.replace(".d", objExt); 270 writefln(fileList); 264 foreach(i,cc; fileList) 265 { 266 auto files = fileList[i].split(); 267 foreach(c;files) 268 { 269 if(c is null || c.cmp("") == 0 || strlen(c.ptr) < 3) 270 continue; 271 272 writefln("Compiling source file %s", c); 273 auto cmdline = compilerCmd ~ flags ~ c; 274 if(system(toStringz(cmdline)) != 0) 275 { 276 throw new Exception("Failed to compile " ~ c); 277 } 278 } 279 } 271 280 272 281 // create the library 273 282 auto libName = libPre ~ packageName ~ libExt; 274 writefln("Creating library %s...", libName); 275 if(system(toStringz(libCmd ~ "lib" ~ sep ~ libName ~ " " ~ fileList)) != 0) 276 { 277 throw new Exception("Failed to create library " ~ libName); 278 } 279 280 // delete the object files 281 writefln("Deleting object files..."); 282 system(toStringz(delCmd ~ " " ~ fileList)); 283 foreach(i,c; fileList) 284 { 285 if(c is null || c.cmp("") == 0 || strlen(c.ptr) < 3) 286 continue; 287 288 auto a = c.replace(".d", objExt); 289 auto cmd = libCmd; 290 if(i == 0) 291 { 292 cmd = libNewCmd; 293 writefln("Creating library %s...", libName); 294 } 295 296 // add the object files to the library 297 writefln("Adding object files %s...", a); 298 if(system(toStringz(cmd ~ "lib" ~ sep ~ libName ~ " " ~ a)) != 0) 299 { 300 throw new Exception("Failed to create library " ~ libName); 301 } 302 303 // delete the object files 304 writefln("Deleting object files %s...", a); 305 system(toStringz(delCmd ~ a)); 306 } 283 307 284 308 // strip the library on unices
