blob: 15babbf3809c19de1f636f056a5af28df0613bc4 [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
20Maintainer tools
21----------------
22
23The source tree for upstart uses the GNU Build System (sometimes known
24as the GNU Autotools). You will need the following versions
25installed.
26
Scott James Remnanta86d3982007-10-15 17:55:09 +010027 * GNU Autoconf 2.61
Scott James Remnant0c3bef32007-10-08 13:20:56 +010028 * GNU Automake 1.10
Scott James Remnant32804e82009-01-26 15:25:57 +000029 * GNU Libtool 2.2.4
Scott James Remnante16d32c2007-10-08 13:37:44 +010030 * GNU Gettext 0.16.1
Scott James Remnant8a0cd072006-05-14 18:28:58 +010031
Scott James Remnantb598eba2008-03-08 18:17:38 +000032After checking out upstart from Bazaar you will need to use these
Scott James Remnant8a0cd072006-05-14 18:28:58 +010033tools to generate the build files. The correct way to do this is to
34simply run ‘autoreconf -i’ from the top-level source directory.
35
36
Scott James Remnantd2350362010-02-03 19:42:29 -080037libnih
38------
39
40Upstart normally uses the pre-installed version of libnih, however it's
41possible to use a version from a source tree alongside Upstart by
42passing the path of that tree to the configure script using the
43--with-local-libnih option.
44
45
Scott James Remnant8a0cd072006-05-14 18:28:58 +010046Configure options
47-----------------
48
49There are some configure script options that you may find useful when
50hacking 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
66Coding style
67------------
68
69The coding style for upstart is roughly K&R with function names in
70column 0, and variable names aligned in declarations.
71
Scott James Remnant3b4b2272006-12-14 11:39:05 +000072The right results can be almost achieved by doing the following.
Scott James Remnant8a0cd072006-05-14 18:28:58 +010073
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 Remnantc16a9b42006-10-11 17:08:58 +010090
Scott James Remnant44828472007-01-30 11:53:33 +000091
92Documentation
93-------------
94
Scott James Remnantc16a9b42006-10-11 17:08:58 +010095All functions, typedefs, structures and file-level variables, whether
Scott James Remnant3b4b2272006-12-14 11:39:05 +000096exported or not, must be preceded by a documentation comment
Scott James Remnantc16a9b42006-10-11 17:08:58 +010097detailing their usage and behaviour. The format of that command is as
98follows:
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
116Structures should detail their members instead of function parameters.
Scott James Remnantb7983062006-12-12 11:34:49 +0000117
Scott James Remnant44828472007-01-30 11:53:33 +0000118
119Function Attributes
120-------------------
121
122Functions that allocate a structure and return it should use the
123"warn_unused_result" and "malloc" attributes, even if the structure is
124placed in a linked list. The former ensures a failure to allocate
125memory is checked by the caller, and the latter allows some
126optimisation.
127
128Functions that raise errors, or call other functions that raise
129errors, must indicate that an error has been raised in their return
130value and also use the "warn_unused_result" attribute to ensure that
131the caller doesn't ignore the error.
132
133Functions that can return to indicate insufficient memory, even if
134they don't return a pointer, should also use the "warn_unused_result"
135attribute; unless it would be common to ignore this (e.g. shrinking a
136buffer).
137
138
139Test Cases
140----------
141
Scott James Remnantb7983062006-12-12 11:34:49 +0000142Where possible, all code should be covered by test cases checking the
143behaviour of that code. It's particularly important that any bug
144fixes be accompanied by a test case which fails without the fix and
145succeeds with it.
146
147Tests should be placed in C files under the tests/ directory, and use
148the macros defined in the nih/test.h header. See the existing test
149examples to see how.
Scott James Remnant44828472007-01-30 11:53:33 +0000150
151Any functions that allocate memory, or call any functions that
152allocate memory (those marked with the "malloc" attribute) should be
153tested using the TEST_ALLOC_FAIL macro to ensure that the case of
154insufficient memory is handled properly.