Changeset 233
- Timestamp:
- 03/01/07 22:58:42 (2 years ago)
- Files:
-
- trunk/build (deleted)
- trunk/buildme.d (modified) (5 diffs)
- trunk/buildopts (deleted)
- trunk/docs/build.html (modified) (2 diffs)
- trunk/docs/gl.html (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/buildme.d
r229 r233 4 4 version(Tango) 5 5 { 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 } 18 else 19 { 20 private 21 { 22 import std.string; 23 import std.path; 24 import std.file; 25 import std.c.process; 26 } 7 27 } 8 28 … … 56 76 } 57 77 58 // when true, do not delete the temporary Build Response File for Bud /Build78 // when true, do not delete the temporary Build Response File for Bud 59 79 private bool doNotDeleteBRF = false; 60 61 //==============================================================================62 // Utility Functions63 //==============================================================================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 else71 {72 mixin(import("build/phobosUtil.d"));73 }74 75 //==============================================================================76 // Builder Configuration77 //==============================================================================78 mixin(import("build/config.d"));79 80 80 81 //============================================================================== … … 99 100 switch(lower) 100 101 { 102 case "bud": 103 theBuilder = new BudBuilder(); 104 break; 101 105 case "debug": 102 106 mode = Mode.Debug; … … 192 196 193 197 //============================================================================== 198 // BudBuilder -- for building with the Bud tool 199 //============================================================================== 200 class 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 234 private: 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 //============================================================================== 194 304 // Utility functions 195 305 //============================================================================== … … 223 333 } 224 334 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 //============================================================================== 338 char[] toLowerStr(char[] str) 339 { 340 version(Tango) 341 { 342 return toLower(str); 343 } 344 else 345 { 346 return tolower(str); 347 } 348 } 349 350 int 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 363 int 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 376 char[][] 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 395 char *toCString(char[] str) 396 { 397 version(Tango) 398 { 399 return toUtf8z(str); 400 } 401 else 402 { 403 return toStringz(str); 404 } 405 } 406 407 int 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 422 char[] 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 441 void 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 30 30 31 31 <h4>Which Compiler?</h4> 32 <p><div class="important"> 33 This section is currently incorrect. For the time being, the build script requires 34 you to have the <a href="#bud">Bud utility</a> installed. No other build tools or 35 compilers are supported. The instructions to execute the script are valid, you just 36 have only one option. This will change eventually and this section will be updated 37 at that time. 38 </div></p> 39 40 <p> 32 41 The script supports compiling directly 33 42 with DMD and GDC (gdmd), or indirectly with <a href="#bud">Derek Parnell's Bud</a>. Executing the script … … 51 60 This should work whether you execute the script with dmd or gdmd. Bud will 52 61 use the compiler for which it is configured. 62 </p> 53 63 54 64 <h4>Debug or Release?</h4> trunk/docs/gl.html
r165 r233 12 12 <h3>Introduction</h3> 13 13 DerelictGL 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> 14 library. Currently, DerelictGL exposes all core OpenGL functions up to version 2.1. However, 15 in order to use features available in OpenGL versions greater than 1.1, you must load them 16 separately after creating an OpenGL context. See below. 20 17 21 18 <h3>Using</h3> … … 26 23 module.</li> 27 24 <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>25 This will load the shared library and all core OpenGL 1.0 and 1.1 functions.</li> 29 26 </ol> 30 27 … … 67 64 an OpenGL application for general public consumption, there is no way to guarantee 68 65 which 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 66 application is actually run on that system. 67 </p><p> 68 Another issue is presented by 69 Windows operating systems. The default opengl32.dll on Windows systems prior to Vista 70 only provides exports for OpenGL 1.1. It has not been updated since it was first realeased 71 on Windows 95. Furthermore, this DLL is a (rather poor) software implementation. Vista 72 ships with the software implementation, but also includes an OpenGL DLL that supports 73 up to core OpenGL 1.4 and is implemented on top of D3D. This DLL provides hardware 74 acceleration, but all of the calls first go through a translation layer to convert 75 them to D3D calls. The system can load the implementation provided by the 74 76 graphics card driver, but there is no way to know which implementation the 75 application is actually using, or wh atversion a graphics card driver supports,77 application is actually using, or which version a graphics card driver supports, 76 78 until the context is created. 77 78 <p> 79 </p><p> 79 80 Derelict's dynamic loading mechanism helps to work around the first issue. If not 80 81 for the Windows problem, loading OpenGL version 1.2 and later could be accomplished … … 82 83 order to maintain a consistent interface across all platforms, DerelictGL includes 83 84 some additional methods and constants to load and manage different OpenGL versions. 84 85 <p> 85 </p><p> 86 86 <tt>GLVersion</tt><br /> 87 87 This enum defines all OpenGL versions currently loadable by Derelict. At the … … 96 96 <li>GLVersion.Version15</li> 97 97 <li>GLVersion.Version20</li> 98 <li>GLVersion.Version21</li> 98 99 </ul> 99 100 … … 110 111 if a check has been made internally for the latest available version supported 111 112 by the driver. If not, that check is made. Only then are the functions loaded. 112 </p> 113 <p> 113 </p><p> 114 114 When this function returns successfully, a call to 115 115 <span class="bold">DerelictGL.availableVersion</span> will return either a value
