|
| 1 | +DRuntime: Runtime Library for the D Programming Language |
| 2 | +======================================================== |
| 3 | + |
| 4 | +This is a collection of things that people hacking on |
| 5 | +DRuntime will want to know. |
| 6 | + |
| 7 | +Code style |
| 8 | +---------- |
| 9 | + |
| 10 | +Please follow the D style guide when writing code for |
| 11 | +DRuntime: http://dlang.org/dstyle.html |
| 12 | + |
| 13 | +The D style guide doesn't cover everything so when in |
| 14 | +doubt, use the code style already used in the module you |
| 15 | +are modifying, or whatever style you prefer if you're |
| 16 | +adding a new module. |
| 17 | + |
| 18 | +Publicity of modules |
| 19 | +-------------------- |
| 20 | + |
| 21 | +In general, only modules in the 'core' package should be |
| 22 | +made public. The single exception is the 'object' module |
| 23 | +which is not in any package. |
| 24 | + |
| 25 | +The convention is to put private modules in the 'rt' or |
| 26 | +'gc' packages depending on what they do and only put |
| 27 | +public modules in 'core'. |
| 28 | + |
| 29 | +Also, always avoid importing private modules in public |
| 30 | +modules. If a public module consists of a header file |
| 31 | +and an implementation file (which are both maintained by |
| 32 | +hand) then it is OK to import private modules in the |
| 33 | +implementation file. |
| 34 | + |
| 35 | +Adding new modules |
| 36 | +------------------ |
| 37 | + |
| 38 | +When adding a new module, remember to update all three |
| 39 | +makefiles as necessary: |
| 40 | + |
| 41 | +* posix.mak |
| 42 | +* win32.mak |
| 43 | +* win64.mak |
| 44 | + |
| 45 | +A number of shared utility makefiles also need to be |
| 46 | +updated: |
| 47 | + |
| 48 | +* mak/COPY |
| 49 | +* mak/DOCS |
| 50 | +* mak/IMPORTS |
| 51 | +* mak/MANIFEST |
| 52 | +* mak/SRCS |
| 53 | + |
| 54 | +Operating system bindings |
| 55 | +------------------------- |
| 56 | + |
| 57 | +The 'core.sys' package provides bindings to most APIs |
| 58 | +provided by supported operating systems. |
| 59 | + |
| 60 | +The convention is to have OS-specific stuff in a |
| 61 | +'core.sys.os' package where 'os' is the canonical name |
| 62 | +for the OS (e.g. 'linux', 'osx', 'windows'). |
| 63 | + |
| 64 | +There is also the 'core.sys.posix' package in which |
| 65 | +bindings to standardized POSIX APIs should be placed. |
| 66 | +In this package, the convention is to put declarations |
| 67 | +in sections based on the OS being compiled for. See |
| 68 | +src/core/sys/posix/pwd.d for an example of how these |
| 69 | +modules are arranged. |
| 70 | + |
| 71 | +For all OS headers, it's a good idea to put a version |
| 72 | +attribute at the top of the file containing the OS |
| 73 | +the header is intended for. For example, in POSIX |
| 74 | +modules, this would be 'version (Posix):' while in |
| 75 | +Windows modules it would be 'version (Windows):' and |
| 76 | +so on. |
| 77 | + |
| 78 | +The convention is to have a D module per C header. |
| 79 | + |
| 80 | +C99 bindings |
| 81 | +------------ |
| 82 | + |
| 83 | +The 'core.stdc' package provides bindings to all C99 |
| 84 | +library types, functions, and macros. Unlike the style |
| 85 | +in operating system bindings, bindings here should be |
| 86 | +kept system-agnostic whenever possible. |
| 87 | + |
| 88 | +Deprecation process |
| 89 | +------------------- |
| 90 | + |
| 91 | +Never remove a symbol without going through the proper |
| 92 | +deprecation process. |
| 93 | + |
| 94 | +When, for whatever reason, a symbol is to be deprecated, |
| 95 | +annotate it as such using the 'deprecated' attribute. It |
| 96 | +is a good idea to also provide a message on the attribute |
| 97 | +so that the user can immediately see what symbol they |
| 98 | +should use instead. |
| 99 | + |
| 100 | +After six months of having been deprecated, a symbol can |
| 101 | +be removed completely. It may also be kept around for |
| 102 | +backwards compatibility if deemed necessary. |
| 103 | + |
| 104 | +ABI breakage |
| 105 | +------------ |
| 106 | + |
| 107 | +We're trying to get to a point where DRuntime's ABI is |
| 108 | +completely stable and different compiler versions can |
| 109 | +use different DRuntime versions. To this end, avoid |
| 110 | +making ABI-breaking changes unless you have a *very* |
| 111 | +good reason to do it. |
| 112 | + |
| 113 | +Remember that renaming a symbol and leaving an alias |
| 114 | +behind for the old symbol name *is* an ABI break. The |
| 115 | +compiled name will be the new symbol, thus breaking old |
| 116 | +binaries. |
| 117 | + |
| 118 | +Updating the change log |
| 119 | +----------------------- |
| 120 | + |
| 121 | +It's a good idea to not update the change log in a pull |
| 122 | +request. It tends to create merge conflicts between |
| 123 | +pull requests more often than not. |
| 124 | + |
| 125 | +That said, an occasional pull request to update the |
| 126 | +change log with recent changes (i.e. in a batch) is OK. |
0 commit comments