NAME

Bric::Hacker - A guide for Bricolage hackers.

VERSION

$Revision: 1.21 $

DATE

$Date: 2002/08/18 23:50:24 $

DESCRIPTION

This document is designed to provide information useful to Bricolage developers. If you've got questions about hacking Bricolage that aren't answered here please post to the Bricolage developer's mailing-list (see below) and tell us about it.

MAILING LISTS

Bricolage has a number of mailing-lists that are relevant to developers:

bricolage-general@lists.sourceforge.net

This is the mailing-list for normal Bricolage users. This is a good place to go with questions about how the application works and should work. To subscribe go to:

http://lists.sourceforge.net/lists/listinfo/bricolage-general

bricolage-devel@lists.sourceforge.net

This is the place to discuss Bricolage development, propose changes, post patches and penetrate markets. To subscribe go to:

http://lists.sourceforge.net/lists/listinfo/bricolage-devel

bricolage-commits@lists.sourceforge.net

This list gets an email for every commit to the CVS tree (see below for more about CVS). DO NOT POST TO THIS LIST! To subscribe:

http://lists.sourceforge.net/lists/listinfo/bricolage-commits

bricolage-bugs@lists.sourceforge.net

This list gets an email for every bug-report submitted to Bugzilla (see below for Bugzilla details). DO NOT POST TO THIS LIST! To subscribe:

http://lists.sourceforge.net/lists/listinfo/bricolage-bugs

CVS - THE CUTTING EDGE

If you're developing Bricolage then you should be working with the latest code from CVS. You can browse the CVS tree at:

http://sourceforge.net/cvs/?group_id=34789

You'll also find information there on connecting to the repository to checkout a working copy.

BUG TRACKING

Bricolage has a Bugzilla server dedicated to it:

http://bricolage-bugzilla.about.com

You should use this system to report bugs in Bricolage. If you're looking for something to do you can also use the system to find open bug and fix them. For more things to do see Bric::ToDo.

SUBMITTING PATCHES

Patches should be generated using a cvs diff -u command on each of the files modified, from the root directory. For example, if you made changes to lib/Bric/Changes.pod and comp/foo.mc, you would generate a diff by running this command from the root of your CVS checkout:

cvs diff -u lib/Bric/Changes.pod comp/foo.mc > patch.txt

If you created one or more new files in your changes then you'll have to add them to the patch separately using normal diff against /dev/null. For example, if you created the file inst/upgrade/1.9.1/solve_fermat.pl then you would add this to patch.txt with:

diff -u /dev/null inst/upgrade/1.9.1/solve_fermat.pl >> patch.txt

Always create patches using the most recent CVS version if possible. Send your patches to the bricolage-devel list mentioned above.

APPLYING PATCHES

Patches created using the method above can be applied using patch with the -p0 option from the root of your CVS checkout:

patch -p0 < patch.txt

Make sure you check the results with cvs diff before committing.

CODING STANDARDS

Try to follow the style of the existing Bricolage code.

Although historically the Bricolage code has not enforced whitespace rules, in general, we try to encourage 4-space indents (2 spaces for continued lines) and discourage the use of tabs. The following settings for some of the more popular editors are thus recommended while editing Bricolage source code.

Emacs

We strongly recommend that you use cperl-mode while editing Bricolage sources in Emacs. Grab the latest version from the CPAN, install it, and then place the following in your ~/.emacs file:

(custom-set-variables
 '(case-fold-search t)
 '(cperl-indent-level 4)
 '(cperl-continued-statement-offset 2)
 '(cperl-tab-always-indent t)
 '(indent-tabs-mode nil))

Also, if you'd like to take advantage of the full functionality of cperl-mode and have it automatically parse all Perl source files, add these settings, as well:

(defalias 'perl-mode 'cperl-mode)
(setq auto-mode-alist
      (append
       '(("\\.\\([pP]\\([Llm]\\|erl\\)\\|al\\|pod\\)\\'" . cperl-mode))
       auto-mode-alist))
  (setq cperl-hairy t)
  (setq interpreter-mode-alist (append interpreter-mode-alist
     '(("miniperl" . cperl-mode))))

When editing Bricolage Mason components, mmm-mode can help. It's Mason mode will parse Mason component files and use sgml-mode in HTML spaces and cperl-mode in Mason blocks. Grab it from http://mmm-mode.sourceforge.net/, install it, and then add the following to your ~/.emacs file to have it automatically parse your Bricolage Mason component files:

(add-to-list 'load-path "/usr/local/share/emacs/site-lisp")
(require 'mmm-mode)
(require 'mmm-mason)
(setq mmm-global-mode 'maybe)
(add-to-list 'auto-mode-alist '("/usr/local/bricolage/comp" . sgml-mode))
(mmm-add-mode-ext-class 'sgml-mode "/usr/local/bricolage/comp" 'mason)

And if you need to examine the Mason object files created by Bricolage in order to chase down bugs and such, you can use the cperl-mode in those files by adding this to your ~/.emacs file:

(add-to-list 'auto-mode-alist '("/usr/local/bricolage/data/obj" . cperl-mode))

Vim

Rafael Garcia-Suarez has written a Vim indent macro which (for the most part) duplicates the behavior of Emacs perl-mode. It is now, as of Vim 6.0, included in the Vim distribution and should be found in $VIMRUNTIME/indent/perl. The easiest way to use it though is to place the following line in your .vimrc:

source $VIMRUNTIME/indent.vim

You'll also need to add these lines.

set tabstop=8
set softtabstop=4
set shiftwidth=4
set expandtab

The first three lines make Vim duplicate the behavior of Emacs in creating the appearance of 4 space tabs with a mix of tabs and spaces. This is necessary for reading older Bricolage files which were written this way, and haven't yet been re-tabbed.

The expandtab setting does the Right Thing under the new rules, in that it doesn't use tabs at all, only spaces.

DEBUGGING

Bricolage is a complex application and debugging can be difficult. Here are some tips to help you find bugs faster:

PERFORMANCE TUNING

Bricolage has two separate profiling systems that you can use to extract performance data:

CAUTION: Neither of these options is appropriate for a production system.

ACTIONS AND MOVERS

A relatively simple way to contribute to Bricolage is to provide actions and movers. These are plugin modules that can add new functionality to Bricolage without needing to make changes to the existing API.

An "action" is an act that is performed on files before they are distributed. Say you want to clean the HTML of all of your HTML files before they're distributed. You'll need to create an action to do this. Consult Bric::Dist::Action for information on how to create actions.

Say you need to distribute files via a protocol that Bricolage doesn't currently support -- say, an new variant of FTP called "FooTP." You'll need to create a new mover. Consult Bric::Dist::Action::Mover for details on how to do that.

AUTHOR

Sam Tregar <stregar@about-inc.com>

SEE ALSO

Bric::Admin, Bric::ToDo