Development Guidelines: Difference between revisions

From coreboot
Jump to navigation Jump to search
m (Test.)
(→‎Sign-off Procedure: Use the verbatim Developer's Certificate of Origin 1.1 from http://osdlab.org/newsroom/press_releases/2004/2004_05_24_dco.html, but rename it.)
Line 94: Line 94:
== Sign-off Procedure ==
== Sign-off Procedure ==


Verbatim copy from the Linux kernel (we might modify this a bit):
We employ a similar sign-off procedure for LinuxBIOS [http://osdlab.org/newsroom/press_releases/2004/2004_05_24_dco.html as the Linux developers] do.
Please add a note such as
Signed-off-by: Random J Developer <random@developer.example.org>
to your email/patch if you agree with the following LinuxBIOS Developer's Certificate of Origin 1.1.


To improve tracking of who did what, especially with patches that can
=== LinuxBIOS Developer's Certificate of Origin 1.1 ===
percolate to their final resting place in the kernel through several
 
layers of maintainers, we've introduced a "sign-off" procedure on
By making a contribution to this project, I certify that:<br />
patches that are being emailed around.<br />
(a) The contribution was created in whole or in part by me and I have
The sign-off is a simple line at the end of the explanation for the
the right to submit it under the open source license indicated in the file; or<br />
patch, which certifies that you wrote it or otherwise have the right to
(b) The contribution is based upon previous work that, to the best of my
pass it on as a open-source patch.  The rules are pretty simple: if you
knowledge, is covered under an appropriate open source license and I have the
can certify the below:<br />
right under that license to submit that work with modifications, whether created
        Developer's Certificate of Origin 1.1<br />
in whole or in part by me, under the same open source license (unless I am
        By making a contribution to this project, I certify that:<br />
permitted to submit under a different license), as indicated in the file; or<br />
        (a) The contribution was created in whole or in part by me and I
(c) The contribution was provided directly to me by some other person who
            have the right to submit it under the open source license
certified (a), (b) or (c) and I have not modified it; and<br />
            indicated in the file; or<br />
(d) In the case of each of (a), (b), or (c), I understand and agree that
        (b) The contribution is based upon previous work that, to the best
this project and the contribution are public and that a record of the contribution
            of my knowledge, is covered under an appropriate open source
(including all personal information I submit with it, including my sign-off) is
            license and I have the right under that license to submit that
maintained indefinitely and may be redistributed consistent with this project or the
            work with modifications, whether created in whole or in part
open source license indicated in the file.
            by me, under the same open source license (unless I am
 
            permitted to submit under a different license), as indicated
<small>Note: this is basically the same as the Linux [http://osdlab.org/newsroom/press_releases/2004/2004_05_24_dco.html Developer's Certificate of Origin 1.1], which is licensed under the terms of the [http://creativecommons.org/licenses/by-sa/2.5/ Creative Commons Attribution-ShareAlike 2.5 License].</small>
            in the file; or<br />
        (c) The contribution was provided directly to me by some other
            person who certified (a), (b) or (c) and I have not modified
            it.<br />
        (d) I understand and agree that this project and the contribution
            are public and that a record of the contribution (including all
            personal information I submit with it, including my sign-off) is
            maintained indefinitely and may be redistributed consistent with
            this project or the open source license(s) involved.<br />
then you just add a line saying<br />
        Signed-off-by: Random J Developer <random@developer.example.org><br />
Some people also put extra tags at the end. They'll just be ignored for
now, but you can do this to mark internal company procedures or just
point out some special detail about the sign-off.


== Reviews ==
== Reviews ==

Revision as of 00:50, 8 February 2007

This page is work in progress!

Development Environment

Required Toolchain

Coding Guidelines

General Guidelines

  • Encapsulate and isolate assembly language
  • Code shall not be "commented out"
  • No use of floating-point arithmetics
  • No hiding of identifiers defined in outer scopes
  • Typedefs are unique (device_t?)
  • Functions shall have prototype declarations
  • Local functions should be declared static
  • No definitions in header files
  • All variables are assigned before use
  • All objects should have fully qualified types (unsigned int instead of unsigned)
  • We suggest trying to import more such rules, such as additional ones described in MISRA-C 2004 (Guidelines for the use of C in critical systems)

Comments

References

If you are referencing a data sheet or other documentation in the code, please add the name or document number in addition to the URL. Vendors just love to rearrange their websites (and some remove documentation on their old products altogether)! If we have the name/number (or even just the filename of the PDF) at least there's a chance to google for it again (either on the vendor's site or on some archive).

Coding Style

Documentation Guidelines

General Guidelines and Tips

  • Documentation should be put into the wiki or made available as PDF
  • Avoid using different styles and looks of documentation
  • There's a documentation directory in the source tree ;-)
  • Document what, not how (No comments like // add one to i)
  • Document assumptions, stipulations etc...
  • Document design and concepts!
  • Not lots of documentation but good documentation
  • Structured documentation
  • Focus: Whom are you addressing in your documentation? Write documentation for users, developers, vendors, ...

Automatic documentation

  • Doxygen-generated API- and code documentation is available at http://qa.linuxbios.org/docs/. This documentation is updated on every 10th checkin.
  • To create a Doxygen comment, write
/**
  * This is a sample comment.
  */
or
/** Sample comment. */
  • There are a few commands that describe what kind of comment you are adding:
@brief – short description of a function
@param – input parameters of a function
@return – return value of a function

Testing

Every commit will be processed by the autobuild and autotest system available at http://qa.linuxbios.org/. In addition please run autobuild yourself before submitting patches.

autobuild

Autobuild can be found at LinuxBIOSv2/util/abuild.

Please run abuild before you commit.

Autobuild is also running on every check-in to the repository and sending result mails to the LinuxBIOS mailing list. The results of this build are also available at http://qa.linuxbios.org/ in the build section of each revision.

autotest

Each revision is also tested with an automated test system: http://qa.linuxbios.org/overview.php?tested=1. If you developed LinuxBIOS for a certain mainboard or wish to help improving LinuxBIOS' quality by running the testsuite on one of your mainboards, please contact info@coresystems.de.

How to contribute

Adding Features

  • Changes that impact a lot of code must be documented in the issue tracker.
  • Please convince another developer to approve such changes before doing a commit.

Creating Patches

  • Always use a checkout of the latest svn revision of the code. Patches that do not apply on the latest svn revision will be rejected!
  • Make sure all new and modified files contain the proper license headers (see below).
  • If your patch is supposed to add new files, please add them to your local repository before creating a diff. Use
svn add path/to/file
  • Create your patches by executing the following command in the top-level LinuxBIOSv2 directory:
svn diff > ~/some_descriptive_name.patch
  • Open the patch in a text-editor and double-check that your changes are correct, and that the patch only contains what you think it contains.

Sign-off Procedure

We employ a similar sign-off procedure for LinuxBIOS as the Linux developers do. Please add a note such as

Signed-off-by: Random J Developer <random@developer.example.org>

to your email/patch if you agree with the following LinuxBIOS Developer's Certificate of Origin 1.1.

LinuxBIOS Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it; and
(d) In the case of each of (a), (b), or (c), I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license indicated in the file.

Note: this is basically the same as the Linux Developer's Certificate of Origin 1.1, which is licensed under the terms of the Creative Commons Attribution-ShareAlike 2.5 License.

Reviews

No significant check-in may be made without getting your code reviewed. If your code is reviewed, you may add a line saying

Acked-by: Random J Developer <random@developer.example.org>

to your commit.

If you are fixing trivial things like a typo in a comment, you may specify your own email address in the Acked-by: field, and noting the word "trivial" in the commit description (in addition to the commit description).

  • Send your patch to the mailing list for review.
    • Start the email with a detailed description of what the patch does and why. This text will usually end up in the commit logs so don't clutter it with useless stuff which should not go into the commit message.
    • Add a single line containing your "sign-off" after the description of the patch.
      • Example: Signed-off-by: John Doe <john@example.com>
    • Add a single line which only contains "---". Everything which comes after that line will not be included in the commit message.
  • The developers on the mailing list will review and/or test your patch and send comments or suggestions. Please post updated patches to the mailing list again.
  • If the patch looks ok to one or more developers, they will reply to your mail with an Acked-by: line.
    • Example: Acked-by: John Doe <john@example.com>
  • Every non-trivial patch must get at least one Acked-by: to allow it to be commited.

Repository Commits

Commits to the LinuxBIOS subversion repository have to be done with a commit comment. This may be short, but descriptive:

  • If anyone involved in LinuxBIOS reads your comment in a year, she/he shall still be able to understand what your commit is about, without analyzing the code.
  • Double-check that you're really committing what you think you are, e.g. by typing the following in the top-level LinuxBIOSv2 directory:
svn diff | less
  • Include the following information in the svn commit message:
    • The description from the email containing the patch.
    • All Signed-off-by: and Acked-by: lines your patch received.
    • Reference or close bugs which are fixed by the commit, or are related to it. See below for details.
  • Examples:
    • Code cleanup
    • File/feature xy added (refs #54)
    • Bugfix: broken DRAM init on k8 (tracker #1234)
    • Patch from John Doe <john@doe.gov>

Bug-Tracker

Where is the LinuxBIOS bug tracker

It is available at http://tracker.linuxbios.org/. Log in with your svn username and password if you have one.

Why do we use a bug tracker

We want a standardized interface for keeping track of open issues. The mailing list is fine for discussion, but long standing issues, plans, goals, milestones can not be tracked there in a sufficient manner. There is no means of quality control via the mailing list.

Therefore changes that impact a lot of code must be documented in the bug tracker. Also, please document bugs in the tracker.

How to close Trac issues automatically via svn commits

It searches commit messages for text in the form of:

  • command #1
  • command #1, #2
  • command #1 & #2
  • command #1 and #2

You can have more then one command in a message. The following commands are supported. There is more then one spelling for each command, to make this as user-friendly as possible.

  • closes, fixes
  The specified issue numbers are closed with the contents of this
  commit message being added to it.
  • references, refs, addresses, re
  The specified issue numbers are left in their current status, but
  the contents of this commit message are added to their notes.

A fairly complicated example of what you can do is with a commit message of:

   Changed blah and foo to do this or that. Fixes #10 and #12, and refs #12.

This will close #10 and #12, and add a note to #12.

License Issues

  • Contributed code must be GPL'd (preferrably GPLv2 or any later version), or at least have a GPL-compatible license.

Common License Header

Please quote the full GPL license header text in every file, as shown below. It should contain:

  • The year(s) when the code was written or modified and a copyright note of you (or your company, if you are contributing as part of your employment, and thus the copyright belongs to your company). Also, please provide an email address so that you can be contacted if questions arise.
    • Example:
Copyright (C) 2006 John Doe <john@example.com>
Copyright (C) 2004-2006 Company, Inc.
  • An extra line which lists the author of the code, if the copyright holder is not the same as the author (e.g. if you work for a company and the company owns the copyright).
    • Example:
Copyright (C) 2004-2006 Company, Inc.
Written by Janet Doe <janet@example.com> for Company, Inc.
  • The full GPL header as shown below.

Complete example for *.c and *.h files:

/*
 * This file is part of the LinuxBIOS project.
 *
 * Copyright (C) 2003-2005 John Doe <john@example.com>
 * Copyright (C) 2005 Jane Doe <jane@example.com>
 *
 * Copyright (C) 2006 Company, Inc.
 * Written by Janet Doe <janet@example.com> for Company, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

Complete example for Makefiles, config files, Python files, shell scripts etc.:

##
## This file is part of the LinuxBIOS project.
##
## Copyright (C) 2003-2005 John Doe <john@example.com>
## Copyright (C) 2005 Jane Doe <jane@example.com>
##
## Copyright (C) 2006 Company, Inc.
## Written by Janet Doe <janet@example.com> for Company, Inc.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
##