aboutsummaryrefslogtreecommitdiff
path: root/doc/developer.xml
blob: 010b85064748282a893b5d3d88c78aa422eff55c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
               "docbook/dtd/xml/4.2/docbookx.dtd">
<book>
  <title>The Music Player Daemon - Developer's Manual</title>

  <chapter>
    <title>Introduction</title>

    <para>
      This is a guide for those who wish to hack on the MPD source
      code.  MPD is an open project, and we are always happy about
      contributions.  So far, more than 50 people have contributed
      patches.
    </para>

    <para>
      This document is work in progress.  Most of it may be incomplete
      yet.  Please help!
    </para>
  </chapter>

  <chapter>
    <title>Code Style</title>

    <itemizedlist>
      <listitem>
        <para>
          indent with tabs (width 8)
        </para>
      </listitem>

      <listitem>
        <para>
          don't write CPP when you can write C: use inline functions
          and enums instead of macros
        </para>
      </listitem>

      <listitem>
        <para>
          the code should be C99 compliant, and must compile with
          <application>GCC</application>;
          <application>clang</application> support is highly desirable
        </para>
      </listitem>

      <listitem>
        <para>
          C++ is ok (for integrating C++ only libraries), but it
          should be avoided
        </para>
      </listitem>

      <listitem>
        <para>
          Some example code:
        </para>

        <programlisting lang="C">static inline int
foo(const char *abc, int xyz)
{
        if (abc == NULL) {
                g_warning("Foo happened!\n");
                return -1;
        }

        return xyz;
}
        </programlisting>
      </listitem>
    </itemizedlist>
  </chapter>

  <chapter>
    <title>Hacking The Source</title>

    <para>
      Always write your code against the latest git:
    </para>

    <programlisting>git clone git://git.musicpd.org/master/mpd.git</programlisting>

    <para>
      Configure with the options <option>--enable-debug
      --enable-werror</option>.  Enable as many plugins as possible,
      to be sure that you don't break any disabled code.
    </para>

    <para>
      Don't mix several changes in one single patch.  Create a
      separate patch for every change.  Tools like
      <application>stgit</application> help you with that.
    </para>
  </chapter>

  <chapter>
    <title>Submitting Patches</title>

    <para>
      Send your patches to the mailing list:
      musicpd-dev-team@lists.sourceforge.net
    </para>
  </chapter>
</book>