Scott James Remnant | b598eba | 2008-03-08 18:17:38 +0000 | [diff] [blame] | 1 | The upstart source tree is available using Bazaar with the following |
| 2 | URL, if you plan to hack on upstart please work off this branch. |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 3 | |
Scott James Remnant | 50677e0 | 2008-05-24 13:09:50 +0200 | [diff] [blame] | 4 | http://bazaar.launchpad.net/~scott/upstart/trunk |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 5 | |
Scott James Remnant | b6270dd | 2006-07-13 02:16:38 +0100 | [diff] [blame] | 6 | Releases are available from: |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 7 | |
Scott James Remnant | b798306 | 2006-12-12 11:34:49 +0000 | [diff] [blame] | 8 | http://upstart.ubuntu.com/download/ |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 9 | |
Scott James Remnant | b598eba | 2008-03-08 18:17:38 +0000 | [diff] [blame] | 10 | upstart uses Launchpad's bug tracking system: |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 11 | |
Scott James Remnant | b598eba | 2008-03-08 18:17:38 +0000 | [diff] [blame] | 12 | http://bugs.launchpad.net/upstart/ |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 13 | |
| 14 | If you want to contribute code or bug fixes, please either provide the |
Scott James Remnant | b598eba | 2008-03-08 18:17:38 +0000 | [diff] [blame] | 15 | URL to your own Bazaar branch or use the ‘unified’ diff format |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 16 | (diff -pu) and attach the patch to a bug. Please supply a suggested |
| 17 | ChangeLog entry with your patch. |
| 18 | |
| 19 | |
Scott James Remnant | b933bc9 | 2006-08-02 02:29:25 +0100 | [diff] [blame] | 20 | Dependencies |
| 21 | ------------ |
| 22 | |
| 23 | Upstart uses the libnih library to provide a standard set of utility |
| 24 | functions used throughout the source. This library has not yet been |
| 25 | released in a stand-alone fashion and must instead be shipped with the |
| 26 | source. |
| 27 | |
Scott James Remnant | b598eba | 2008-03-08 18:17:38 +0000 | [diff] [blame] | 28 | If you checked upstart out from Bazaar you will also need to check |
Scott James Remnant | 00c8b99 | 2008-06-01 19:27:04 +0100 | [diff] [blame] | 29 | libnih out from the following URL, usually into parent directory of |
| 30 | the Upstart source: |
Scott James Remnant | b933bc9 | 2006-08-02 02:29:25 +0100 | [diff] [blame] | 31 | |
Scott James Remnant | 50677e0 | 2008-05-24 13:09:50 +0200 | [diff] [blame] | 32 | http://bazaar.launchpad.net/~scott/libnih/trunk |
Scott James Remnant | b933bc9 | 2006-08-02 02:29:25 +0100 | [diff] [blame] | 33 | |
Scott James Remnant | 00c8b99 | 2008-06-01 19:27:04 +0100 | [diff] [blame] | 34 | and run ‘autoreconf -i’ and ‘configure’ within that tree before, |
| 35 | from the upstart working directory, running the ‘nihify’ script to |
| 36 | symlink the necessary files across, usually just: |
Scott James Remnant | b933bc9 | 2006-08-02 02:29:25 +0100 | [diff] [blame] | 37 | |
| 38 | ../libnih/nihify |
| 39 | |
| 40 | |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 41 | Maintainer tools |
| 42 | ---------------- |
| 43 | |
| 44 | The source tree for upstart uses the GNU Build System (sometimes known |
| 45 | as the GNU Autotools). You will need the following versions |
| 46 | installed. |
| 47 | |
Scott James Remnant | a86d398 | 2007-10-15 17:55:09 +0100 | [diff] [blame] | 48 | * GNU Autoconf 2.61 |
Scott James Remnant | 0c3bef3 | 2007-10-08 13:20:56 +0100 | [diff] [blame] | 49 | * GNU Automake 1.10 |
Scott James Remnant | 32804e8 | 2009-01-26 15:25:57 +0000 | [diff] [blame] | 50 | * GNU Libtool 2.2.4 |
Scott James Remnant | e16d32c | 2007-10-08 13:37:44 +0100 | [diff] [blame] | 51 | * GNU Gettext 0.16.1 |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 52 | |
Scott James Remnant | b598eba | 2008-03-08 18:17:38 +0000 | [diff] [blame] | 53 | After checking out upstart from Bazaar you will need to use these |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 54 | tools to generate the build files. The correct way to do this is to |
| 55 | simply run ‘autoreconf -i’ from the top-level source directory. |
| 56 | |
| 57 | |
| 58 | Configure options |
| 59 | ----------------- |
| 60 | |
| 61 | There are some configure script options that you may find useful when |
| 62 | hacking on upstart. |
| 63 | |
| 64 | * --enable-compiler-warnings: (GCC only) adds extra CFLAGS to |
| 65 | increase the source checking and treat all warnings as errors. |
| 66 | |
| 67 | * --disable-compiler-optimisations: ensures that no compiler |
| 68 | optimisations are performed during compilation, easing |
| 69 | debugging. |
| 70 | |
| 71 | * --disable-linker-optimisations: disables the usual linker |
| 72 | optimisations, slightly decreasing build time. |
| 73 | |
| 74 | * --enable-compiler-coverage: (GCC only) enables coverage file |
| 75 | generation, useful for test suites. |
| 76 | |
| 77 | |
| 78 | Coding style |
| 79 | ------------ |
| 80 | |
| 81 | The coding style for upstart is roughly K&R with function names in |
| 82 | column 0, and variable names aligned in declarations. |
| 83 | |
Scott James Remnant | 3b4b227 | 2006-12-14 11:39:05 +0000 | [diff] [blame] | 84 | The right results can be almost achieved by doing the following. |
Scott James Remnant | 8a0cd07 | 2006-05-14 18:28:58 +0100 | [diff] [blame] | 85 | |
| 86 | * GNU Emacs: if you're not using auto-newline, the following |
| 87 | should do the right thing: |
| 88 | |
| 89 | (defun upstart-c-mode-common-hook () |
| 90 | (c-set-style "k&r") |
| 91 | (setq indent-tabs-mode t |
| 92 | c-basic-offset 8)) |
| 93 | |
| 94 | * VIM: the default works except for the case labels in switch |
| 95 | statements. Set the following option to fix that: |
| 96 | |
| 97 | setlocal cinoptions=:0 |
| 98 | |
| 99 | * Indent: can be used to reformat code in a different style: |
| 100 | |
| 101 | indent -kr -i8 -psl |
Scott James Remnant | c16a9b4 | 2006-10-11 17:08:58 +0100 | [diff] [blame] | 102 | |
Scott James Remnant | 4482847 | 2007-01-30 11:53:33 +0000 | [diff] [blame] | 103 | |
| 104 | Documentation |
| 105 | ------------- |
| 106 | |
Scott James Remnant | c16a9b4 | 2006-10-11 17:08:58 +0100 | [diff] [blame] | 107 | All functions, typedefs, structures and file-level variables, whether |
Scott James Remnant | 3b4b227 | 2006-12-14 11:39:05 +0000 | [diff] [blame] | 108 | exported or not, must be preceded by a documentation comment |
Scott James Remnant | c16a9b4 | 2006-10-11 17:08:58 +0100 | [diff] [blame] | 109 | detailing their usage and behaviour. The format of that command is as |
| 110 | follows: |
| 111 | |
| 112 | /** |
| 113 | * function_name: |
| 114 | * @foo: first parameter description, |
| 115 | * @bar: second parameter description, |
| 116 | * @baz: third parameter description. |
| 117 | * |
| 118 | * Describe the function here, when you reference parameters |
| 119 | * use the form above, e.g. give @foo or @bar. |
| 120 | * |
| 121 | * Other functions should be referenced by function-call |
| 122 | * syntax, e.g. call other_function() afterwards. |
| 123 | * |
| 124 | * Returns: if there is a return value, include this line and |
| 125 | * give the possible values returned. |
| 126 | **/ |
| 127 | |
| 128 | Structures should detail their members instead of function parameters. |
Scott James Remnant | b798306 | 2006-12-12 11:34:49 +0000 | [diff] [blame] | 129 | |
Scott James Remnant | 4482847 | 2007-01-30 11:53:33 +0000 | [diff] [blame] | 130 | |
| 131 | Function Attributes |
| 132 | ------------------- |
| 133 | |
| 134 | Functions that allocate a structure and return it should use the |
| 135 | "warn_unused_result" and "malloc" attributes, even if the structure is |
| 136 | placed in a linked list. The former ensures a failure to allocate |
| 137 | memory is checked by the caller, and the latter allows some |
| 138 | optimisation. |
| 139 | |
| 140 | Functions that raise errors, or call other functions that raise |
| 141 | errors, must indicate that an error has been raised in their return |
| 142 | value and also use the "warn_unused_result" attribute to ensure that |
| 143 | the caller doesn't ignore the error. |
| 144 | |
| 145 | Functions that can return to indicate insufficient memory, even if |
| 146 | they don't return a pointer, should also use the "warn_unused_result" |
| 147 | attribute; unless it would be common to ignore this (e.g. shrinking a |
| 148 | buffer). |
| 149 | |
| 150 | |
| 151 | Test Cases |
| 152 | ---------- |
| 153 | |
Scott James Remnant | b798306 | 2006-12-12 11:34:49 +0000 | [diff] [blame] | 154 | Where possible, all code should be covered by test cases checking the |
| 155 | behaviour of that code. It's particularly important that any bug |
| 156 | fixes be accompanied by a test case which fails without the fix and |
| 157 | succeeds with it. |
| 158 | |
| 159 | Tests should be placed in C files under the tests/ directory, and use |
| 160 | the macros defined in the nih/test.h header. See the existing test |
| 161 | examples to see how. |
Scott James Remnant | 4482847 | 2007-01-30 11:53:33 +0000 | [diff] [blame] | 162 | |
| 163 | Any functions that allocate memory, or call any functions that |
| 164 | allocate memory (those marked with the "malloc" attribute) should be |
| 165 | tested using the TEST_ALLOC_FAIL macro to ensure that the case of |
| 166 | insufficient memory is handled properly. |