Changeset 233

Show
Ignore:
Timestamp:
03/01/07 22:58:42 (1 year ago)
Author:
aldacron
Message:

[Core]
* changed the build script once again into a monolithic script. This changed eliminated the build and buildopts directories. The -J switch is no longer needed to run buildme.d.
[Docs]
* the introduction to gl.html was way outdated and did not reflect Derelict's support for versions beyond 1.1, contradicting a later section in the page.
* GLVersion.Version21 was missing from the GLVersion enum listing.
* added a notice to build.html that parts of the build instructions are out of date and that an update will come eventually.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/buildme.d

    r229 r233  
    44version(Tango) 
    55{    
    6     import tango.stdc.stdio;     
     6    static assert(0, "Tango support for the build script is currently incomplete."); 
     7    private 
     8    {        
     9        import tango.text.Ascii; 
     10        import tango.text.String; 
     11        import tango.io.File; 
     12        import tango.sys.Process; 
     13        import tango.core.Version; 
     14        import tango.stdc.stringz; 
     15        import tango.stdc.stdio; 
     16    } 
     17
     18else 
     19{    
     20    private 
     21    { 
     22        import std.string; 
     23        import std.path; 
     24        import std.file; 
     25        import std.c.process; 
     26    } 
    727} 
    828 
     
    5676} 
    5777 
    58 // when true, do not delete the temporary Build Response File for Bud/Build 
     78// when true, do not delete the temporary Build Response File for Bud 
    5979private bool doNotDeleteBRF = false; 
    60  
    61 //============================================================================== 
    62 // Utility Functions 
    63 //============================================================================== 
    64 version(Tango) 
    65 { 
    66     mixin(import("build/tangoUtil.d")); 
    67      
    68     static assert(0, "The build script currently cannot be run under Tango."); 
    69 } 
    70 else 
    71 { 
    72     mixin(import("build/phobosUtil.d")); 
    73 } 
    74  
    75 //============================================================================== 
    76 // Builder Configuration 
    77 //============================================================================== 
    78 mixin(import("build/config.d")); 
    7980 
    8081//============================================================================== 
     
    99100        switch(lower) 
    100101        { 
     102            case "bud": 
     103                theBuilder = new BudBuilder(); 
     104                break; 
    101105            case "debug": 
    102106                mode = Mode.Debug; 
     
    192196 
    193197//============================================================================== 
     198// BudBuilder -- for building with the Bud tool 
     199//============================================================================== 
     200class BudBuilder : Builder 
     201{ 
     202    static this() 
     203    { 
     204        theBuilder = new BudBuilder(); 
     205    } 
     206     
     207    //========================================================================== 
     208    // Methods 
     209    //========================================================================== 
     210    override void buildPackage(char[] packageName) 
     211    { 
     212        // construct a path to the package's forbud file 
     213        char[] path = packageName ~ pathSep ~ _forBudName; 
     214         
     215        // create the temporary brf 
     216        printf("Preparing to build package %s in %s mode...\n", toCString(packageName), toCString(modeToString())); 
     217        if(!createBRF(packageName, path)) 
     218            return false; 
     219         
     220        // call out to build with the name of the temp brf as an arg 
     221        if(execute(_name ~ " @" ~ _tempBRFName) != 0) 
     222        { 
     223            throw new Exception("Failed to build package " ~ packageName); 
     224        } 
     225         
     226        if(!doNotDeleteBRF) 
     227        { 
     228            // delete the temporary brf 
     229            printf("Deleting temporary Build Response File...\n\n"); 
     230            execute(delCmd ~ _tempBRFName); 
     231        } 
     232    } 
     233     
     234private: 
     235    this() 
     236    { 
     237        _name               = "bud";             
     238        _tempBRFName        = "temp.brf"; 
     239        _forBudName         = "forbud.txt"; 
     240        _brfBuf             = ""; 
     241         
     242        buildBRFBuffer(); 
     243    } 
     244     
     245    void buildBRFBuffer() 
     246    { 
     247        _brfBuf = loadOpts(_name, OptsType.Common) ~ "\n";           
     248        _brfBuf ~= loadOpts(_name, cast(OptsType)mode); 
     249    } 
     250     
     251    bool createBRF(char[] packageName, char[] path) 
     252    { 
     253        printf("Reading build tool arguments...\n"); 
     254         
     255        char[] txt;         // holds the contents of the forbud file 
     256         
     257        // read the forbud.txt in this package       
     258        txt = readFile(path); 
     259         
     260        // make sure the file was found 
     261        if(txt is null) 
     262        { 
     263            printf("Could not find %s\n", toCString(path)); 
     264            return false; 
     265        } 
     266         
     267        // this will store all of the text to be output to the temp brf 
     268        char[] brf = ""; 
     269             
     270        // append the common brf buffer 
     271        brf ~= _brfBuf; 
     272         
     273        // the package directory myst be on the import path 
     274        brf ~= "\n-I" ~ packageName; 
     275         
     276        // if the current package is not DerelictUtil, then DerelictUtil must 
     277        // be on the import path and excluded from compilation 
     278        if(cmpStr(packageName, "DerelictUtil") != 0) 
     279        { 
     280            brf ~= "\n-IDerelictUtil\n-XDerelictUtil" ~ pathSep ~ "derelict" ~ pathSep ~ "util"; 
     281        }    
     282         
     283        // append a switch to set the output path of the library and append the config file 
     284        brf ~= "\n-Tlib" ~ pathSep ~ libPre ~ packageName ~ libExt ~ "\n" ~ txt; 
     285         
     286        // write the temporary brf to disk 
     287        printf("Creating temporary Build Response File...\n"); 
     288         
     289        writeFile(_tempBRFName, brf); 
     290         
     291        return true; 
     292    } 
     293     
     294    //========================================================================== 
     295    // Members 
     296    //========================================================================== 
     297    char[] _name; 
     298    char[] _tempBRFName; 
     299    char[] _forBudName; 
     300    char[] _brfBuf; 
     301} 
     302 
     303//============================================================================== 
    194304// Utility functions 
    195305//============================================================================== 
     
    223333} 
    224334 
    225 char[] generateFileList(char[] directory) 
    226 
    227 /* 
    228     char[] files; 
    229      
    230     version(Tango) 
    231     { 
    232     } 
    233     else 
    234     { 
    235         // get a list of all files in the directory 
    236         auto list = listdir(directory); 
    237             foreach(c; list) 
    238             { 
    239                 // if this filename is a directory, recurse 
    240                 if(isdir(c) && c[0] != '.') 
    241                     files ~= (" " ~ generateFileList(directory ~ pathSep ~ c)); 
    242                 else if( 
    243                  
    244             } 
    245     } 
    246 */ 
    247 return ""; 
    248 
     335//============================================================================== 
     336// Phobos/Tango Wrappers 
     337//============================================================================== 
     338char[] toLowerStr(char[] str) 
     339
     340    version(Tango) 
     341    { 
     342        return toLower(str); 
     343    } 
     344    else 
     345    { 
     346        return tolower(str); 
     347    } 
     348
     349 
     350int cmpStr(char[] a, char[] b) 
     351
     352    version(Tango) 
     353    { 
     354        auto s = new String!(char)(a); 
     355        return s.compare(b); 
     356    } 
     357    else 
     358    { 
     359        return cmp(a,b); 
     360    } 
     361
     362 
     363int findStr(char[] str, char[] match) 
     364
     365    version(Tango) 
     366    { 
     367        int i = locatePattern(str, match); 
     368        return (i == str.length) ? -1 : i; 
     369    } 
     370    else 
     371    { 
     372        return find(str, match); 
     373    } 
     374
     375 
     376char[][] splitString(char[] str, char[] delim) 
     377
     378    version(Tango) 
     379    { 
     380        if(0.95f == Tango) 
     381        { 
     382            return demarcate(str, delim); 
     383        } 
     384        else 
     385        { 
     386            return split(str, delim); 
     387        } 
     388    } 
     389    else 
     390    { 
     391        return split(str, delim); 
     392    } 
     393
     394 
     395char *toCString(char[] str) 
     396
     397    version(Tango) 
     398    { 
     399        return toUtf8z(str); 
     400    } 
     401    else 
     402    { 
     403        return toStringz(str); 
     404    } 
     405
     406 
     407int execute(char[] cmd) 
     408
     409    version(Tango) 
     410    { 
     411        auto p = new Process(cmd, null); 
     412        p.execute(); 
     413        auto r = p.wait(); 
     414        return r.status; 
     415    } 
     416    else 
     417    { 
     418        return system(toStringz(cmd)); 
     419    } 
     420
     421 
     422char[] readFile(char[] name) 
     423
     424    version(Tango) 
     425    { 
     426        auto f = new File(name); 
     427        if(f.isExisting()) 
     428            return cast(char[])f.read(); 
     429        else 
     430            return null; 
     431    } 
     432    else 
     433    { 
     434        if(exists(name)) 
     435            return cast(char[])read(name); 
     436        else 
     437            return null; 
     438    } 
     439
     440 
     441void writeFile(char[] name, char[] contents) 
     442
     443    version(Tango) 
     444    { 
     445        auto f = new File(name); 
     446        f.write(cast(void[])contents); 
     447    } 
     448    else 
     449    { 
     450        write(name, cast(void[])contents); 
     451    } 
     452     
     453
     454 
  • trunk/docs/build.html

    r217 r233  
    3030 
    3131<h4>Which Compiler?</h4> 
     32<p><div class="important"> 
     33This section is currently incorrect. For the time being, the build script requires 
     34you to have the <a href="#bud">Bud utility</a> installed. No other build tools or 
     35compilers are supported. The instructions to execute the script are valid, you just 
     36have only one option. This will change eventually and this section will be updated 
     37at that time. 
     38</div></p> 
     39 
     40<p> 
    3241The script supports compiling directly 
    3342with DMD and GDC (gdmd), or indirectly with <a href="#bud">Derek Parnell's Bud</a>. Executing the script  
     
    5160This should work whether you execute the script with dmd or gdmd. Bud will 
    5261use the compiler for which it is configured. 
     62</p> 
    5363 
    5464<h4>Debug or Release?</h4> 
  • trunk/docs/gl.html

    r165 r233  
    1212<h3>Introduction</h3> 
    1313DerelictGL is a D binding to the <a href="http://www.opengl.org/">OpenGL</a> 
    14 library. Currently, DerelictGL only exposes core OpenGL 1.1 functions. In order 
    15 to use features available in OpenGL versions greater than 1.1, you must use  
    16 OpenGL's extension loading mechanism. 
    17  
    18 <div class="note">I am hoping to find a suitable solution to exposing different 
    19 OpenGL versions in the general case, where available.</div> 
     14library. Currently, DerelictGL exposes all core OpenGL functions up to version 2.1. However, 
     15in order to use features available in OpenGL versions greater than 1.1, you must load them 
     16separately after creating an OpenGL context. See below. 
    2017 
    2118<h3>Using</h3> 
     
    2623module.</li> 
    2724<li>Before calling any OpenGL functions, you need to make a call to <tt>DerelictGL.load()</tt>. 
    28 This will load the shared library.</li> 
     25This will load the shared library and all core OpenGL 1.0 and 1.1 functions.</li> 
    2926</ol> 
    3027 
     
    6764an OpenGL application for general public consumption, there is no way to guarantee 
    6865which version of the API will be available on any user's system until the 
    69 application is actually run on that system. Another issue is presented by 
    70 Windows operating systems. The default opengl32.dll on Windows systems only 
    71 provides exports for OpenGL 1.1. It has not been updated since it was first realeased 
    72 on Windows 95 (this will change with Vista, but even then the new dll will only 
    73 expose OpenGL 1.4). The system dll can load the implementation provided by the 
     66application is actually run on that system.  
     67</p><p> 
     68Another issue is presented by 
     69Windows operating systems. The default opengl32.dll on Windows systems prior to Vista 
     70only provides exports for OpenGL 1.1. It has not been updated since it was first realeased 
     71on Windows 95. Furthermore, this DLL is a (rather poor) software implementation. Vista 
     72ships with the software implementation, but also includes an OpenGL DLL that supports 
     73up to core OpenGL 1.4 and is implemented on top of D3D. This DLL provides hardware 
     74acceleration, but all of the calls first go through a translation layer to convert 
     75them to D3D calls. The system can load the implementation provided by the 
    7476graphics card driver, but there is no way to know which implementation the 
    75 application is actually using, or what version a graphics card driver supports, 
     77application is actually using, or which version a graphics card driver supports, 
    7678until the context is created. 
    77  
    78 <p> 
     79</p><p> 
    7980Derelict's dynamic loading mechanism helps to work around the first issue. If not 
    8081for the Windows problem, loading OpenGL version 1.2 and later could be accomplished 
     
    8283order to maintain a consistent interface across all platforms, DerelictGL includes 
    8384some additional methods and constants to load and manage different OpenGL versions. 
    84  
    85 <p> 
     85</p><p> 
    8686<tt>GLVersion</tt><br /> 
    8787This enum defines all OpenGL versions currently loadable by Derelict. At the 
     
    9696<li>GLVersion.Version15</li> 
    9797<li>GLVersion.Version20</li> 
     98<li>GLVersion.Version21</li> 
    9899</ul> 
    99100 
     
    110111if a check has been made internally for the latest available version supported 
    111112by the driver. If not, that check is made. Only then are the functions loaded. 
    112 </p> 
    113 <p> 
     113</p><p> 
    114114When this function returns successfully, a call to  
    115115<span class="bold">DerelictGL.availableVersion</span> will return either a value