Changeset 251
- Timestamp:
- 04/01/07 08:29:46 (1 year ago)
- Files:
-
- trunk/docs/build.html (modified) (4 diffs)
- trunk/docs/derelictify.html (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docs/build.html
r233 r251 11 11 <hr> 12 12 <h3>Introduction</h3> 13 In the top-level Derelict directory ($DERELICT_HOME) you will find a D module 14 named <tt>buildme.d</tt>. It can, and is intended to, be run as a script. Executing 15 this file will create one or more libraries from the Derelict packages. At the 16 end of execution, all of the libraries that were created will be found in the 17 $DERELICT_HOME/lib directory. 13 While it is possible to compile any or all of the Derelict packages into static 14 libraries, it is not recommended that you do so. The provided build script exists 15 solely as a convenience for those who absolutely need it. The recommended way of 16 using Derelict in your applications is to make use of a build tool, such as 17 <a href="http://www.dsource.org/projects/build">Bud</a> or 18 <a href="http://www.dsource.org/projects/dsss/wiki/Rebuild">Rebuild</a>. Given 19 a single D source module, these tools can automatically compile and link all 20 imported modules to create an executable. So unless you absolutely must use the 21 static libraries, please consider using the recommended approach instead. 22 <p> 23 For those who do need the libraries, in the top-level Derelict directory 24 ($DERELICT_HOME) you will find a D module named <tt>buildme.d</tt>. It can be, 25 and is intended to be, run as a script. Executing this file will create one or 26 more libraries from the Derelict packages. At the end of execution, all of the 27 libraries that were created will be found in the $DERELICT_HOME/lib directory. 28 </p> 18 29 19 <div class="note">You may be tempted to compile buildme.d into an executable. It 20 is strongly recommended that you do not. The script is intended to be run from 21 the command line of a console window, as a script, so that you may see any 22 error text that is output. Should you compile an executable and launch from the 23 desktop, or any other non-console window, you will not see the error text.</div> 30 <div class="important">Derelict has built-in support for 31 <a href="http://www.dsource.org/projects/tango">Tango</a>. but currently the 32 build script cannot be executed in a Tango-enabled environment. If you need to 33 use Derelict with Tango, you must do so using the method recommended above (with 34 Bud or Rebuild).</div> 35 36 <h3>Requirements</h3> 37 Currently, the build script requires that <a href="http://www.dsource.org/projects/build"> 38 Bud</a> be on your PATH. If it is not, the script will fail. 39 40 <h3>Execution</h3> 41 To execute the build script, cd to $DERELICT_HOME and use one of the following 42 command lines: 43 44 <pre> 45 dmd -run buildme.d 46 gdmd -run buildme.d 47 </pre> 48 49 The first is the command line to use with DMD. The second is for GDC. In the rest 50 of this document, 'dmd' will be used for example command lines. Anytime you see 51 'dmd', you can replace it with 'gdmd' to use the same command line with GDC. 24 52 25 53 <h3>Options</h3> 26 54 Before executing the build script, you need to decide which libraries you want 27 55 to build and how you want to build them. There are a few command line options 28 you can pass along. When reading the options below, keep in mind that they 29 can be specified in any order. 30 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> 41 The script supports compiling directly 42 with DMD and GDC (gdmd), or indirectly with <a href="#bud">Derek Parnell's Bud</a>. Executing the script 43 with no arguments will compile all libraries with the compiler used to execute 44 the script: 45 46 <pre> 47 cd $DERELICT_HOME 48 dmd -run buildme.d <-- This will compile with DMD 49 gdmd -run buildme.d <-- This will compile with GDC 50 </pre> 51 52 If you have Bud installed, you can use it to build the libraries by passing 53 "bud" on the command line: 54 55 <pre> 56 cd $DERELICT_HOME 57 dmd -run buildme.d bud 58 </pre> 59 60 This should work whether you execute the script with dmd or gdmd. Bud will 61 use the compiler for which it is configured. 62 </p> 56 you can pass along. With the exception of the 'cleanlib' option, all options 57 may be passed in any order. 63 58 64 59 <h4>Debug or Release?</h4> … … 67 62 68 63 <pre> 69 cd $DERELICT_HOME70 64 dmd -run buildme.d debug 71 65 </pre> … … 73 67 The script also accepts 'release' as a command line argument. 74 68 75 <p> 76 If you are using Bud, you can find the configuration options in the following 77 files: 78 </p> 69 <h4>Options for Bud</h4> 70 71 The build script generates a temporary Bud Response File that is deleted at the 72 end of execution. Sometimes, when debugging problems with the build script, it 73 is necessary to see the contents of this file. You can prevent the script from 74 deleting the file by passing 'nodelbrf' on the command line: 79 75 80 76 <pre> 81 $(DERELICT_HOME)/build_common.txt 82 $(DERELICT_HOME)/build_release.txt 83 $(DERELICT_HOME)/build_debug.txt 77 dmd -run buildme.d nodelbrf 84 78 </pre> 85 79 86 87 <tt>build_common.txt</tt>, <tt>build_debug.txt</tt>, and <tt>build_release.txt</tt> 88 may all be edited to your preference. The rules for editing these files are the 89 same as those for editing <a href="http://build.dsource.org/response_file.html">Bud 90 Response Files</a>, but there are some caveats. Because <tt>buildme.d</tt> automates 91 the build process, some assumptions are made. The first is that the output directory 92 will be the <tt>$DERELICT_HOME/lib</tt> subdirectory. Adding -TsomeDir to any of 93 the three files will have no effect. Second, the import paths for building each 94 package are set automatically. Third, the DerelictUtil package and other dependencies 95 are excluded from the compilation automatically via the -X Bud option, so you 96 need not do so yourself. 97 98 99 <p> 100 If you are not using Bud, you can find configuration options in the script itself. 101 The following variables are what you should look for: 102 </p> 80 You can also pass options to both Bud and the compiler, though not via the command 81 line. This is done through the following three options files: 103 82 104 83 <pre> 105 COMPILE_FLAGS_DEBUG 106 COMPILE_FLAGS_RELEASE 107 COMPILE_FLAGS_COMMON 84 $(DERELICT_HOME)/buildopts/bud_common.txt 85 $(DERELICT_HOME)/buildopts/bud_release.txt 86 $(DERELICT_HOME)/buildopts/bud_debug.txt 108 87 </pre> 109 88 110 The options in COMPILE_FLAGS_COMMON are used in both Debug and Release builds. 111 112 For most users, there is no need to edit any of the options. But feel free to 113 do so if you need to. 89 Options in <tt>bud_common.txt</tt> are used in both Debug and Release builds. The other 90 two are self-explanatory. 91 <p> 92 The rules for editing these files are the same as those for editing 93 <a href="http://build.dsource.org/response_file.html">Bud Response Files</a>, 94 but there are some caveats. Because <tt>buildme.d</tt> automates the build process, 95 some assumptions are made. The first is that the output directory will be the 96 <tt>$DERELICT_HOME/lib</tt> subdirectory. Adding -TsomeDir to any of the three 97 files will have no effect. Second, the import paths for building each package 98 are set automatically so that you don't need to. Third, the DerelictUtil package 99 and other dependencies are excluded from the compilation automatically via the 100 -X Bud option (except, of course, when DerelictUtil itself is being compiled). 101 </p><p> 102 For most users, the default configuration should suffice. 103 </p> 114 104 115 105 <h4>Which Packages?</h4> … … 133 123 </pre> 134 124 135 This will delete the libraries in $(DERELICT_HOME/lib). Unlike the other command 136 line options, this option must be specified first. Any options following it will 125 This will delete the libraries in $(DERELICT_HOME/lib). Unlike the other command 126 line options, this option must be specified first. Any options following it will 137 127 be ignored. If it is not first, it will be ignored. 138 128 139 < div class=Note>140 On windows, executing the cleanlib option with DMD will cause the script to delete141 files with the .lib extension, while doing so with GDC (gdmd) will cause the 142 script to delete files with the .a extension. 143 </div> 129 <h3>Troubleshooting</h3> 130 If you have any problems building Derelict with Bud, you may direct them to the 131 <a href="http://www.dsource.org/forums/viewforum.php?f=19&sid=d6f86cfb804d7c8727af1f58cd327d2c">Derelict Forums</a> 132 and someone will try to help you. Please don't post problems on the Bud forums 133 unless you are absolutely certain the problem is with Bud and not with Derelict. 144 134 145 <a name="bud"><h3>Derelict Parnell's Bud</h3></a>146 Bud, created and maintained by Derek Parnell, is an incredibly147 useful tool. Feed it one D source module on the command line and it will automatically148 spit out a library or an executable. It follows the import tree, and passes149 each imported module to the D compiler and linker or librarian. Several command150 line options can give you fine-tuned control over how the compilation process151 goes. You can put special pragmas directly in your code to further control how152 Bud processes your source modules.153 <p>154 Bud entirely eliminates the need for Makefiles. If you have ever maintained155 project Makefiles for multiple platforms, you will appreciate what that means.156 Replacing Derelict's old Makefiles with a build system designed around Bud157 has had an amazing impact on package maintenance. If you want to compile Derelict158 out of the box, separate from your project, you will need to have Bud installed.159 Anyone who insists on maintaining their own Makefiles instead is free to do so -160 just don't bother submitting them to the Derelict maintainers.161 </p>162 163 <h4>Getting Your Hands on Bud</h4>164 The latest version of Bud may always be found at the165 <a href="http://www.dsource.org/projects/build">166 Build Project Home Page</a>. You can read about the latest changes in the167 <a href="http://www.dsource.org/forums/viewforum.php?f=52">Bud Forum</a>168 (always the first post in the thread titled "Release Announcements" at the top169 of the topic list).170 171 172 <h3>Troubleshooting</h3>173 If you have any problems building Derelict with the Bud, you may direct174 them to the175 <a href="http://www.dsource.org/forums/viewforum.php?f=19&sid=d6f86cfb804d7c8727af1f58cd327d2c">Derelict Forums</a>176 and someone will try to help you. Please don't post problems on the Build forums177 unless you are absolutely certain the problem is with Build and not Derelict's178 scripts.179 135 </body> 180 136 </html> trunk/docs/derelictify.html
r203 r251 18 18 <p> 19 19 Bugfixes and enhancements to existing code or documentation will almost always 20 be folded in. New packages, however, often will not be. If we were to accept 21 any and all packages submitted, Derelict would quickly become bloated, unwieldy, 20 be folded in. New packages, however, often will not be. If we were to accept 21 any and all packages submitted, Derelict would quickly become bloated, unwieldy, 22 22 and difficult to maintain. New packages will most definitely be added over time, 23 but they must meet some loose criteria, as explained on the 23 but they must meet some loose criteria, as explained on the 24 24 <a href="index_a.html#criteria">front page</a>. 25 25 </p><p> 26 Whether you are making a package for inclusion in the trunk, distributing it 27 separately, or using it privately, there are a few guidelines that should be 26 Whether you are making a package for inclusion in the trunk, distributing it 27 separately, or using it privately, there are a few guidelines that should be 28 28 followed when creating the package. 29 29 </p> … … 31 31 <h3>The Bindings</h3> 32 32 At a very minimum, the bindings you create must be designed to allow manual loading 33 of a shared library. If the library to which you are binding cannot be compiled 34 in shared library form, then the binding cannot be Derelictified. Creating a 33 of a shared library. If the library to which you are binding cannot be compiled 34 in shared library form, then the binding cannot be Derelictified. Creating a 35 35 shared library binding involves several steps, which this document attempts to 36 36 clarify. … … 38 38 <h4>typedefs, constants and #defined values</h4> 39 39 C typedefs can translate to either alias or typedef statements. Derelict 40 modules should use the alias form. Constants must be declared as publicly available 41 const variables at the module scope (meaning, they should not be wrapped in 42 structs or classes). #defined values, depending on the intention, should either 43 be declared as aliases or publicly available const variables at the module 44 scope. 40 modules should use the alias form. Constants should be declared in anonymous 41 enums. #defined values, depending on the intention, should either 42 be declared as aliases or anonymous enums. 43 44 <div class="note">Derelict packages originally declared constants as publicly 45 available constant values. In order to help reduce the size of the resultant 46 binaries, a process was begun to convert all such values to anonymous enums. 47 Currently, the conversion is not complete so you will see examples of both usages 48 in the packages. New packages should all use the enum form. Example: 49 50 <pre> 51 enum 52 { 53 CONSTANT_ONE = 10, 54 CONSTANT_TWO = 22, 55 CONSTANT_THREE = 25, 56 } 57 </pre> 58 </div> 59 45 60 <p> 46 61 Where to put these declarations depends entirely upon the size of the library … … 48 63 that all types are declared in context-specific modules along with function 49 64 declarations and converted macros. Because of the number of headers in SDL, this 50 approach makes sense. DerelictAL (and most of the other Derelict packages), on 51 the other hand, declares all types in a special types module, while functions 65 approach makes sense. DerelictAL (and most of the other Derelict packages), on 66 the other hand, declares all types in a special types module, while functions 52 67 are declared separately. Generally, this is the approach you should take when 53 68 the size of the binding is not so large to make this approach difficult to … … 67 82 All Derelict packages must provide function pointer declarations. When a shared 68 83 library is manually loaded, the function pointers will be initialized to point 69 to the proper memory locations in the shared library's address space. The 70 declarations of the function pointers should be typedefed and should have the 84 to the proper memory locations in the shared library's address space. The 85 declarations of the function pointers should be typedefed and should have the 71 86 following syntax: 72 87 </p> … … 88 103 <p> 89 104 Following the function declarations should be global variables of the type 90 <span class="bold">pfFunctionName</span> (for each function), and named 105 <span class="bold">pfFunctionName</span> (for each function), and named 91 106 <span class="bold">FunctionName</span>. Expanding the above example: 92 107 </p> … … 94 109 <pre> 95 110 typedef void function(int) pfMyFunction; 96 typedef int function() pfMyOtherFunction; 111 typedef int function() pfMyOtherFunction; 97 112 typedef int function(float, char*, void*) pfyetAnotherMyFunction; 98 113 pfMyFunction MyFunction; // pointer to C function named MyFunction … … 112 127 <pre> 113 128 typedef void function(int) pfMyFunction; 114 typedef int function() prMyOtherFunction; 129 typedef int function() prMyOtherFunction; 115 130 typedef int function(float, char*, void*) pfyetAnotherMyFunction; 116 131 pfMyFunction MyFunction; … … 136 151 137 152 <p> 138 The binding of a function is done via the <span class="bold">bindFunc</span> 139 template. First, you must implement a function that will handle all of the 140 loading. This function should be private to your module. The function should 153 The binding of a function is done via the <span class="bold">bindFunc</span> 154 template. First, you must implement a function that will handle all of the 155 loading. This function should be private to your module. The function should 141 156 accept a <span class="bold">SharedLib</span> as the only argument. 142 157 </p> … … 145 160 private void loadFoo(SharedLib lib) 146 161 { 147 148 } 149 </pre> 150 151 <p> 152 If you are unfamiliar with the mechanics of D templates, the call syntax of 153 <span class="bold">bindFunc</span> may be quite strange to you. In this case, 154 there are two sets of parantheses. In the first set of parentheses, you need to 162 163 } 164 </pre> 165 166 <p> 167 If you are unfamiliar with the mechanics of D templates, the call syntax of 168 <span class="bold">bindFunc</span> may be quite strange to you. In this case, 169 there are two sets of parantheses. In the first set of parentheses, you need to 155 170 pass the function pointer to which you are binding the function. The second set of 156 171 parentheses is where, in this particluar case, you provide the arguments to an 157 172 <span class="bold">opCall</span> implementation internal to 158 173 <span class="bold">bindFunc</span>. Here, you should pass the name of the 159 function as a string and the <span class="bold">SharedLib</span> reference 174 function as a string and the <span class="bold">SharedLib</span> reference 160 175 passed to your load function. It's easier to understand seeing it in action than 161 176 reading a description of it. The following example expands on the previous … … 167 182 168 183 typedef void function(int) pfMyFunction; 169 typedef int function() prMyOtherFunction; 184 typedef int function() prMyOtherFunction; 170 185 typedef int function(float, char*, void*) pfyetAnotherMyFunction; 171 186 pfMyFunction MyFunction; … … 176 191 typedef double function(int) pfAnotherFooFunction; 177 192 pfFooFunction FooFunction; 178 pfAnotherFooFunction AnotherFooFunction; 193 pfAnotherFooFunction AnotherFooFunction; 179 194 180 195 private void loadFoo(SharedLib lib) … … 193 208 method: 194 209 195 <p class="bold">GenericLoader.setup(char[] windowsNames, char[] linuxName, 196 char[] macNames, void function(SharedLib) loadFunc)</p> 210 <p class="bold">GenericLoader.setup(char[] windowsNames, char[] linuxName, 211 char[] macNames, void function(SharedLib) loadFunc)</p> 197 212 198 213 <p>Each of the name parameters are either a single library name or a comma-separated … … 200 215 when the <span class="bold">load</span> method is called with no arguments. When 201 216 multiple names are supplied, they will be loaded in the order given. As an example, 202 here is the implementation for DerelictAL: 217 here is the implementation for DerelictAL: 203 218 </p> 204 219 <pre> 205 220 GenericLoader DerelictAL; 206 static this() 221 static this() 207 222 { 208 223 DerelictAL.setup( … … 240 255 <h4>Use the Source, Luke</h4> 241 256 If you find this documentation confusing (I do, and I wrote it), then the source 242 is your best recourse. It's fairly self-explanatory. I recommend that you use 257 is your best recourse. It's fairly self-explanatory. I recommend that you use 243 258 DerelictAL and DerelictSDL as examples, for consistency. 244 259 </body>
