blob: a55cf0cc81b51049975b342f7883f3c330f10b09 [file] [log] [blame]
Scott James Remnantb598eba2008-03-08 18:17:38 +00001The upstart source tree is available using Bazaar with the following
2URL, if you plan to hack on upstart please work off this branch.
Scott James Remnant8a0cd072006-05-14 18:28:58 +01003
Scott James Remnant50677e02008-05-24 13:09:50 +02004 http://bazaar.launchpad.net/~scott/upstart/trunk
Scott James Remnant8a0cd072006-05-14 18:28:58 +01005
Scott James Remnantb6270dd2006-07-13 02:16:38 +01006Releases are available from:
Scott James Remnant8a0cd072006-05-14 18:28:58 +01007
Scott James Remnantb7983062006-12-12 11:34:49 +00008 http://upstart.ubuntu.com/download/
Scott James Remnant8a0cd072006-05-14 18:28:58 +01009
Scott James Remnantb598eba2008-03-08 18:17:38 +000010upstart uses Launchpad's bug tracking system:
Scott James Remnant8a0cd072006-05-14 18:28:58 +010011
Scott James Remnantb598eba2008-03-08 18:17:38 +000012 http://bugs.launchpad.net/upstart/
Scott James Remnant8a0cd072006-05-14 18:28:58 +010013
14If you want to contribute code or bug fixes, please either provide the
Scott James Remnantb598eba2008-03-08 18:17:38 +000015URL to your own Bazaar branch or use the ‘unified’ diff format
Scott James Remnant8a0cd072006-05-14 18:28:58 +010016(diff -pu) and attach the patch to a bug. Please supply a suggested
17ChangeLog entry with your patch.
18
19
Scott James Remnantb933bc92006-08-02 02:29:25 +010020Dependencies
21------------
22
23Upstart uses the libnih library to provide a standard set of utility
24functions used throughout the source. This library has not yet been
25released in a stand-alone fashion and must instead be shipped with the
26source.
27
Scott James Remnantb598eba2008-03-08 18:17:38 +000028If you checked upstart out from Bazaar you will also need to check
Scott James Remnant00c8b992008-06-01 19:27:04 +010029libnih out from the following URL, usually into parent directory of
30the Upstart source:
Scott James Remnantb933bc92006-08-02 02:29:25 +010031
Scott James Remnant50677e02008-05-24 13:09:50 +020032 http://bazaar.launchpad.net/~scott/libnih/trunk
Scott James Remnantb933bc92006-08-02 02:29:25 +010033
Scott James Remnant00c8b992008-06-01 19:27:04 +010034and run ‘autoreconf -i’ and ‘configure’ within that tree before,
35from the upstart working directory, running the ‘nihify’ script to
36symlink the necessary files across, usually just:
Scott James Remnantb933bc92006-08-02 02:29:25 +010037
38 ../libnih/nihify
39
40
Scott James Remnant8a0cd072006-05-14 18:28:58 +010041Maintainer tools
42----------------
43
44The source tree for upstart uses the GNU Build System (sometimes known
45as the GNU Autotools). You will need the following versions
46installed.
47
Scott James Remnanta86d3982007-10-15 17:55:09 +010048 * GNU Autoconf 2.61
Scott James Remnant0c3bef32007-10-08 13:20:56 +010049 * GNU Automake 1.10
Scott James Remnant32804e82009-01-26 15:25:57 +000050 * GNU Libtool 2.2.4
Scott James Remnante16d32c2007-10-08 13:37:44 +010051 * GNU Gettext 0.16.1
Scott James Remnant8a0cd072006-05-14 18:28:58 +010052
Scott James Remnantb598eba2008-03-08 18:17:38 +000053After checking out upstart from Bazaar you will need to use these
Scott James Remnant8a0cd072006-05-14 18:28:58 +010054tools to generate the build files. The correct way to do this is to
55simply run ‘autoreconf -i’ from the top-level source directory.
56
57
58Configure options
59-----------------
60
61There are some configure script options that you may find useful when
62hacking 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
78Coding style
79------------
80
81The coding style for upstart is roughly K&R with function names in
82column 0, and variable names aligned in declarations.
83
Scott James Remnant3b4b2272006-12-14 11:39:05 +000084The right results can be almost achieved by doing the following.
Scott James Remnant8a0cd072006-05-14 18:28:58 +010085
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 Remnantc16a9b42006-10-11 17:08:58 +0100102
Scott James Remnant44828472007-01-30 11:53:33 +0000103
104Documentation
105-------------
106
Scott James Remnantc16a9b42006-10-11 17:08:58 +0100107All functions, typedefs, structures and file-level variables, whether
Scott James Remnant3b4b2272006-12-14 11:39:05 +0000108exported or not, must be preceded by a documentation comment
Scott James Remnantc16a9b42006-10-11 17:08:58 +0100109detailing their usage and behaviour. The format of that command is as
110follows:
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
128Structures should detail their members instead of function parameters.
Scott James Remnantb7983062006-12-12 11:34:49 +0000129
Scott James Remnant44828472007-01-30 11:53:33 +0000130
131Function Attributes
132-------------------
133
134Functions that allocate a structure and return it should use the
135"warn_unused_result" and "malloc" attributes, even if the structure is
136placed in a linked list. The former ensures a failure to allocate
137memory is checked by the caller, and the latter allows some
138optimisation.
139
140Functions that raise errors, or call other functions that raise
141errors, must indicate that an error has been raised in their return
142value and also use the "warn_unused_result" attribute to ensure that
143the caller doesn't ignore the error.
144
145Functions that can return to indicate insufficient memory, even if
146they don't return a pointer, should also use the "warn_unused_result"
147attribute; unless it would be common to ignore this (e.g. shrinking a
148buffer).
149
150
151Test Cases
152----------
153
Scott James Remnantb7983062006-12-12 11:34:49 +0000154Where possible, all code should be covered by test cases checking the
155behaviour of that code. It's particularly important that any bug
156fixes be accompanied by a test case which fails without the fix and
157succeeds with it.
158
159Tests should be placed in C files under the tests/ directory, and use
160the macros defined in the nih/test.h header. See the existing test
161examples to see how.
Scott James Remnant44828472007-01-30 11:53:33 +0000162
163Any functions that allocate memory, or call any functions that
164allocate memory (those marked with the "malloc" attribute) should be
165tested using the TEST_ALLOC_FAIL macro to ensure that the case of
166insufficient memory is handled properly.