diff builder.d @ 132:bc5baa585b32

Updated to dmd 2.060
author David Bryant <bagnose@gmail.com>
date Thu, 02 Aug 2012 15:32:43 +0930
parents 1da160a2c373
children 9e1a313d8003
line wrap: on
line diff
--- a/builder.d	Thu Jan 12 18:20:58 2012 +1030
+++ b/builder.d	Thu Aug 02 15:32:43 2012 +0930
@@ -125,8 +125,8 @@
     if (!exists(path)) {
         return 0;
     }
-    getTimesPosix(path, fileStatusChangeTime, fileAccessTime, fileModificationTime);
-    return fileStatusChangeTime.stdTime;
+    getTimes(path, fileAccessTime, fileModificationTime);
+    return fileModificationTime.stdTime;
 }
 
 
@@ -191,7 +191,7 @@
     void parseForImport(char[] line) {
         static string[] leaders = ["private ", "public ", "static ", "import "];
         bool found;
-        auto stripped = stripl(line);
+        auto stripped = stripLeft(line);
         if (stripped.length > 8) {
             foreach (i, leader ; leaders) {
                 if (stripped[0..leader.length] == leader) {
@@ -328,7 +328,7 @@
         mTime = mPath.exists ? 1 : 0;
 
         // this directory depends on its parent directory chain
-        string parent_path = path.dirname;
+        string parent_path = path.dirName;
         if (parent_path.length > 0 && parent_path[0] != '.' && parent_path != "/") {
             Item* parent = parent_path in mItems;
             if (parent) {
@@ -387,7 +387,7 @@
             }
 
             // and all other group's higher-level groups until common ancestor
-            string other_parent_path = other.mPath.dirname;
+            string other_parent_path = other.mPath.dirName;
             if (other_parent_path != "." &&
                 other_parent_path.length < mPath.length &&
                 mPath[0..other_parent_path.length] != other_parent_path)
@@ -420,7 +420,7 @@
         group.addMember(this);
 
         // this file depends on on its parent directory
-        string parent_path = path.dirname;
+        string parent_path = path.dirName;
         Item* parent = parent_path in mItems;
         if (parent) {
             assert(cast(DirectoryItem *)parent);
@@ -443,7 +443,7 @@
 
     this(string path, GroupItem group) {
         super("source", path, group);
-        if (!isfile(path)) error(format("source file %s not found", path));
+        if (!isFile(path)) error(format("source file %s not found", path));
     }
 
     // set the object item
@@ -515,13 +515,14 @@
         writefln("Object    %s", mPath);
         scope cmd = new StringFormatter;
 
-        cmd.format("dmd -m32 -c");
+        cmd.format("dmd -m64 -c");
         foreach (path; Global.bundlePaths) {
             cmd.format(" -I%s", path);
         }
-        cmd.format(" -od%s %s", dirname(mPath), mSource.mPath);
+        cmd.format(" -od%s %s", dirName(mPath), mSource.mPath);
         cmd.format(" @%s", Global.optionsPath);
 
+        //writefln("cmd: %s", cmd.str);
         if (std.process.system(cmd.str)) {
             writefln("%s", cmd.str);
             error(format("build of %s failed", mPath));
@@ -552,6 +553,7 @@
                 cmd.format(" %s", obj.mPath);
             }
         }
+        //writefln("cmd: %s", cmd.str);
         if (std.process.system(cmd.str)) {
             writefln("%s", cmd.str);
             error("command failed");
@@ -601,7 +603,7 @@
         writefln("Program   %s", mPath);
         scope cmd = new StringFormatter();
 
-        cmd.format("dmd -m32 -L-L%s", std.path.join(Global.buildPath, "lib"));
+        cmd.format("dmd -m64 -L-L%s", buildPath(Global.buildPath, "lib"));
         cmd.format(" -of%s %s", mPath, mObject.mPath);
 
         // add the libraries we need
@@ -617,6 +619,7 @@
         }
         cmd.format(" @%s", Global.optionsPath);
 
+        //writefln("cmd: %s", cmd.str);
         if (std.process.system(cmd.str)) {
             writefln("%s", cmd.str);
             error("command failed");
@@ -646,6 +649,7 @@
         scope tmpPath = mPath ~ ".failed";
         cmd.format("%s > %s 2>&1", mProgram.mPath, tmpPath);
 
+        //writefln("cmd: %s", cmd.str);
         if (std.process.system(cmd.str)) {
             // failed
             writefln(" failed");
@@ -694,7 +698,7 @@
         mParent = parent;
         if (parent.mName.length) {
             // child of non-root
-            mSlashName = parent.mSlashName ~ sep ~ mName;
+            mSlashName = parent.mSlashName ~ "/" ~ mName;
             mDotName   = parent.mDotName   ~ "." ~ mName;
         }
         else {
@@ -745,7 +749,7 @@
 
     this(string name, string path, Node parent, GroupItem group) {
         super(name, parent);
-        string obj_path = std.path.join(Global.buildPath, "obj", mSlashName ~ ".o");
+        string obj_path = buildPath(Global.buildPath, "obj", mSlashName ~ ".o");
         mSource  = new SourceItem(path, group);
         mObject  = new ObjectItem(obj_path, mSource, group);
         mSource.set_object(mObject);
@@ -812,11 +816,11 @@
     this(string name, string path, Node parent, bool test, GroupItem group) {
         super(name, path, parent, group);
         if (test) {
-            mProgram = new ProgramItem(std.path.join(Global.buildPath, "test", mSlashName), mObject, group);
-            mResult = new ResultItem(std.path.join(Global.buildPath, "test", mSlashName ~ ".result"), mProgram, group);
+            mProgram = new ProgramItem(buildPath(Global.buildPath, "test", mSlashName), mObject, group);
+            mResult = new ResultItem(buildPath(Global.buildPath, "test", mSlashName ~ ".result"), mProgram, group);
         }
         else {
-            mProgram = new ProgramItem(std.path.join(Global.buildPath, "bin", mName), mObject, group);
+            mProgram = new ProgramItem(buildPath(Global.buildPath, "bin", mName), mObject, group);
         }
         setClump(mProgram);
         //writefln("loaded Program %s", mProgram.mPath);
@@ -839,24 +843,25 @@
         string lib_name = replace(mDotName, ".", "_");
 
         // examine all the children of the package's directory
-        foreach (string child; listdir(path)) {
-            string p = std.path.join(path, child);
+        foreach (string child; dirEntries(path, SpanMode.shallow)) {
+            child = baseName(child);
+            string p = buildPath(path, child);
             if (child[0] != '.') {
 
-                if (isfile(p)) {
+                if (isFile(p)) {
 
                     if (child.length > 2 && child[$-2..$] == ".d") {
                         // a library module
                         if (!mLibrary) {
-                            mLibrary = new LibraryItem(std.path.join(Global.buildPath, "lib", "lib" ~ lib_name ~ ".a"),
+                            mLibrary = new LibraryItem(buildPath(Global.buildPath, "lib", "lib" ~ lib_name ~ ".a"),
                                                        lib_name, mGroup);
                         }
-                        Module m = new Module(getName(child), p, this, mGroup);
+                        Module m = new Module(stripExtension(child), p, this, mGroup);
                         m.setClump(mLibrary);
                     }
                 }
 
-                else if (isdir(p)) {
+                else if (isDir(p)) {
 
                     if (child == "build-tool") {
                         // reserved for build-tool
@@ -869,27 +874,29 @@
                     }
                     else if (child == "test") {
                         // test programs
-                        foreach (string grandchild; listdir(p)) {
-                            string p2 = std.path.join(p, grandchild);
+                        foreach (string grandchild; dirEntries(p, SpanMode.shallow)) {
+                            grandchild = baseName(grandchild);
+                            string p2 = buildPath(p, grandchild);
                             if (grandchild[0] != '.' &&
-                                isfile(p2) &&
+                                isFile(p2) &&
                                 grandchild.length > 2 &&
                                 grandchild[$-2..$] == ".d")
                             {
-                                Exe exe = new Exe(getName(grandchild), p2, this, true, mGroup);
+                                Exe exe = new Exe(stripExtension(grandchild), p2, this, true, mGroup);
                             }
                         }
                     }
                     else if (child == "prog") {
                         // deliverable programs
-                        foreach (string grandchild; listdir(p)) {
-                            string p2 = std.path.join(p, grandchild);
+                        foreach (string grandchild; dirEntries(p, SpanMode.shallow)) {
+                            grandchild = baseName(grandchild);
+                            string p2 = buildPath(p, grandchild);
                             if (child[0] != '.' &&
-                                isfile(p2) &&
+                                isFile(p2) &&
                                 grandchild.length > 2 &&
                                 grandchild[$-2..$] == ".d")
                             {
-                                Exe exe = new Exe(getName(grandchild), p2, this, false, mGroup);
+                                Exe exe = new Exe(stripExtension(grandchild), p2, this, false, mGroup);
                             }
                         }
                     }
@@ -950,27 +957,28 @@
 
         // add path to Global for use when compiling
         Global.bundlePaths ~= path;
-        Global.optionsPath = std.path.join(path, "options");
+        Global.optionsPath = buildPath(path, "options");
 
         //
         // load bundles specified in the uses file - lines are bundle paths relative to path
         //
-        string uses_path = std.path.join(path, "uses");
-        if (exists(uses_path) && isfile(uses_path)) {
+        string uses_path = buildPath(path, "uses");
+        if (exists(uses_path) && isFile(uses_path)) {
             //writefln("reading uses file: %s", uses_path);
             scope file = new BufferedFile(uses_path);
             foreach (char[] line; file) {
-                load(std.path.join(path, line.idup));
+                load(buildPath(path, line.idup));
             }
         }
 
         //
         // load local products
         //
-        foreach (string name; listdir(path)) {
+        foreach (string name; dirEntries(path, SpanMode.shallow)) {
+            name = baseName(name);
             if (name[0] != '.' && name != "nobuild") {
-                string p = std.path.join(path, name);
-                if (isdir(p)) {
+                string p = buildPath(path, name);
+                if (isDir(p)) {
                     foreach (node; mChildren) {
                         Product existing = cast(Product)node;
                         if (existing && existing.mName == name) {