Changeset 592

Show
Ignore:
Timestamp:
05/09/07 04:08:42 (1 year ago)
Author:
Gregor
Message:

sss/build.d: Tangofied.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/tango/sss/build.d

    r589 r592  
    2929module sss.build; 
    3030 
    31 import std.file; 
    32 import std.process; 
    33 import std.stdio; 
    34 import std.string; 
    35  
    36 import std.c.stdlib; 
     31import tango.io.Console; 
     32import tango.io.File; 
     33import tango.io.FileConst; 
     34import tango.io.FilePath; 
     35import tango.io.FileSystem; 
     36 
     37import tango.text.Ascii; 
     38import tango.text.Util; 
    3739 
    3840import hcf.path; 
     
    8385         
    8486        if (type == "library" && libsSafe()) { 
    85             writefln("Creating imports for %s", target)
     87            Cout("Creating imports for ")(target).newline
    8688             
    8789            // do the predigen 
     
    9597            // generate .di files 
    9698            foreach (file; srcFiles) { 
    97                 char[] ifile = "dsss_imports" ~ std.path.sep ~ file ~ "i"; 
    98                 if (!exists(ifile) || 
     99                char[] ifile = "dsss_imports" ~ FileConst.PathSeparatorChar ~ file ~ "i"; 
     100                if (!(new FilePath(ifile)).exists() || 
    99101                    fileNewer(file, ifile)) { 
    100102                    /* BIG FAT NOTE slash FIXME: 
     
    106108                     
    107109                    // usname = name_with_underscores 
    108                     char[] usname = replace(build, std.path.sep, "_"); 
     110                    char[] usname = replace(build.dup, FileConst.PathSeparatorChar, '_'); 
     111                     
     112                    File iff = new File(ifile); 
    109113                     
    110114                    if (shLibSupport() && 
    111115                        ("shared" in settings)) { 
    112                         std.file.write(ifile, std.file.read(file) ~ ` 
     116                        iff.write(iff.read() ~ ` 
    113117version (build) { 
    114118    version (DSSS_Static_` ~ usname ~ `) { 
     
    120124`); 
    121125                    } else { 
    122                         std.file.write(ifile, std.file.read(file) ~ ` 
     126                        iff.write(iff.read() ~ ` 
    123127version (build) { 
    124128    pragma(link, "S` ~ target ~ `"); 
     
    134138            } 
    135139             
    136             writefln("")
     140            Cout.newline
    137141             
    138142        } 
     
    156160                char[] shlibflag = getShLibFlag(settings); 
    157161                 
    158                 if (exists(shlibname)) continue; 
    159                  
    160                 writefln("Building stub shared library for %s", target)
     162                if ((new FilePath(shlibname)).exists()) continue; 
     163                 
     164                Cout("Building stub shared library for ")(target).newline
    161165                 
    162166                // make the stub 
     
    174178                } 
    175179                 
    176                 writefln("")
     180                Cout.newline
    177181            } 
    178182        } 
     
    188192         
    189193        if (type == "library" || type == "sourcelibrary") { 
    190             char[] dotname = std.string.replace(build, std.path.sep, "."); 
     194            char[] dotname = tango.text.Util.replace(build.dup, FileConst.PathSeparatorChar, '.'); 
    191195             
    192196            // get the list of files 
     
    202206             
    203207            // output what we're building 
    204             writefln("%s => %s", build, target)
     208            Cout(build)(" => ")(target).newline
    205209         
    206210            // prepare for documentation 
    207211            char[] docbl = ""; 
    208212            if (doDocs) { 
    209                 char[] docdir = "dsss_docs" ~ std.path.sep ~ build; 
     213                char[] docdir = "dsss_docs" ~ FileConst.PathSeparatorChar ~ build; 
    210214                mkdirP(docdir); 
    211215                docbl ~= "-Dq" ~ docdir ~ " -candydoc "; 
    212216             
    213217                // now extract candydoc there 
    214                 char[] origcwd = getcwd(); 
    215                 chdir(docdir); 
     218                char[] origcwd = FileSystem.getDirectory(); 
     219                FileSystem.setDirectory(docdir); 
    216220             
    217221                version (Windows) { 
     
    221225                } 
    222226             
    223                 chdir(origcwd); 
     227                FileSystem.setDirectory(origcwd); 
    224228            } 
    225229             
     
    230234             
    231235            // get the file list 
    232             char[] fileList = std.string.join(targetToFiles(build, conf), " "); 
     236            char[] fileList = tango.text.Util.join(targetToFiles(build, conf), " "); 
    233237             
    234238            // if we should, build the library 
     
    238242                if (targetGNUOrPosix()) { 
    239243                    // first do a static library 
    240                     if (exists("libS" ~ target ~ ".a")) std.file.remove("libS" ~ target ~ ".a"); 
     244                    if ((new FilePath("libS" ~ target ~ ".a")).exists()) 
     245                        (new FilePath("libS" ~ target ~ ".a")).remove(); 
     246                     
    241247                    char[] stbl = bl ~ docbl ~ bflags ~ " -explicit -lib -full " ~ fileList ~ " -oflibS" ~ target ~ ".a"; 
    242248                    saySystemRDie(stbl, "-rf", "temp.rf"); 
     
    245251                        ("shared" in settings)) { 
    246252                        // then make the shared library 
    247                         if (exists(shlibname)) std.file.remove(shlibname); 
     253                        if ((new FilePath(shlibname)).exists()) 
     254                            (new FilePath(shlibname)).remove(); 
     255                         
    248256                        char[] shbl = bl ~ bflags ~ " -fPIC -explicit -shlib -full " ~ fileList ~ " -of" ~ shlibname ~ 
    249257                        " " ~ shlibflag; 
     
    255263                } else if (targetVersion("Windows")) { 
    256264                    // for the moment, only do a static library 
    257                     if (exists("S" ~ target ~ ".lib")) std.file.remove("S" ~ target ~ ".lib"); 
     265                    if ((new FilePath("S" ~ target ~ ".lib")).exists()) 
     266                        (new FilePath("S" ~ target ~ ".lib")).remove(); 
     267                     
    258268                    char[] stbl = bl ~ docbl ~ bflags ~ " -explicit -lib -full " ~ fileList ~ " -ofS" ~ target ~ ".lib"; 
    259269                    saySystemRDie(stbl, "-rf", "temp.rf"); 
     
    270280             
    271281            // an extra line for clarity 
    272             writefln("")
     282            Cout.newline
    273283             
    274284        } else if (type == "special") { 
    275285            // special type, do pre/post 
    276             writefln("%s", target)
     286            Cout(target).newline
    277287            if ("prebuild" in settings) { 
    278288                dsssScriptedStep(conf, settings["prebuild"]); 
     
    282292                dsssScriptedStep(conf, settings["postbuild"]); 
    283293            } 
    284             writefln("")
     294            Cout.newline
    285295             
    286296        } else if (type == "subdir") { 
    287297            // recurse 
    288             char[] origcwd = getcwd(); 
    289             chdir(build); 
     298            char[] origcwd = FileSystem.getDirectory(); 
     299            FileSystem.setDirectory(build); 
    290300             
    291301            // the one thing that's passed in is build flags 
     
    296306             
    297307            int buildret = sss.build.build(null); 
    298             chdir(origcwd); 
     308            FileSystem.setDirectory(origcwd); 
    299309             
    300310            dsss_build = orig_dsss_build; 
     
    321331             
    322332            // output what we're building 
    323             writefln("%s => %s", build, target)
     333            Cout(build)(" => ")(target).newline
    324334             
    325335            // do the prebuild 
     
    329339             
    330340            // build a build line 
    331             char[] ext = std.string.tolower(getExt(build)); 
     341            char[] ext = tango.text.Ascii.toLower(getExt(build)); 
    332342            if (ext == "d") { 
    333343                bbl ~= build ~ " -of" ~ target ~ " "; 
     
    335345                bbl ~= "@" ~ getName(build) ~ " "; 
    336346            } else { 
    337                 writefln("ERROR: I don't know how to build something with extension %s", ext)
     347                Cout("ERROR: I don't know how to build something with extension ")(ext).newline
    338348                return 1; 
    339349            } 
     
    348358             
    349359            // an extra line for clarity 
    350             writefln("")
     360            Cout.newline
    351361             
    352362        }