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