Here are some pretty straight forward steps to quickly get a development environment based on the Eclipse IDE. The tools in this environment are
- Eclipse with the Eclipse-CDT platform
- Distcc – a distributed C/C++ compiler
- Mozilla Framework – the base framework used for Mozilla projects
Note: Mozilla has great documentation to help building any of their application. Please have a look there before posting any question. The #developers irc.mozilla.org channel is also a good start.
This tutorial assumes you’re using Ubuntu or a similar distro.
Build and configure Firefox
1. Install required tools and Firefox dependencies
sudo apt-get install cvs distcc eclipse eclipse-cdt libcurl4-openssl-dev distccmon-gnome
sudo apt-get build-dep firefox
2. Get the Firefox source
TAR :
wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/3.0b5/source/firefox-3.0b5-source.tar.bz2
tar -xjf firefox-3.0b5-source.tar
CVS :
export CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
cvs login
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk
cd mozilla
make -f client.mk checkout
Note: Mozilla MXR offers a quick web search engine for source code
3. Create the Mozilla config file to build firefox
cd mozilla
echo “mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obj-@CONFIG_GUESS@” >> .mozconfig
echo “ac_add_options –enable-application=browser” >> .mozconfig
echo “mk_add_options MOZ_CO_PROJECT=browser” >> .mozconfig
echo “ac_add_options –enable-debug” >> .mozconfig
echo “ac_add_options –disable-optimize” >> .mozconfig
echo “mk_add_options MOZ_MAKE_FLAGS=\”CC=’distcc gcc’ CXX=’distcc g++’ -j4\”" >> .mozconfig
Note: Add the last line only if you plan to use distcc. Also, replace the ‘j4′ parameter by the number of available processors (or cores) +2. Ex: if you have a total of 4 cores connected to your distcc server, use j6.
Install and configure distcc
1. Edit /etc/default/distcc
STARTDISTCC=”true”
ALLOWEDNETS=”10.145.0.0/16″
LISTENER=”0.0.0.0″
2. Add distcc hosts
mkdir ~/.distcc
echo “localhost build-machine” > ~/distcc/hosts
chmod 666 ~/.distcc/hosts
3. Restart the service
sudo /etc/init.d/distcc restart
Build Firefox
make -f client.mk build
Configure the Eclipse project
1. Create the project
File->New->Project…
C/C++ Project->Standard Make C++ Project
Project Name: Firefox
Location : (select the extracted mozilla folder)
Click “Finish”
2. Configure the project
Right-click on the new Firefox project in Eclipse’s left column
Click “Properties”
Select “Make C++ Project”
Change “Build command” to “make -f client.mk”
Change “Build (incremental build)” from “all” to “build”
3. Build Firefox from Eclipse
You should remove the “Build automatically” option from the Project menu and build the application by right-clicking on the Firefox project and selecting “Build Project”
If you do not see the “Build Project” option, make sure you are using the C/C++ perspective.
This operation always takes a while since all subfolders and files need to be parsed (around 30k files)
Debugging Firefox
1. Create the Debug/Run configuration
Select Run->Debug… from the Eclipse menu
Right-click on C/C++ Local Application and select New
Project: firefox
C/C++ Application: (select browse and choose mozilla/../obj-i686-pc-linux-gnu/dist/bin/firefox-bin)
2. Add specific configuration
In the Arguments tab, change the working directory to mozilla/../obj-i686-pc-linux-gnu/dist/bin/
In the Environment tab, create two variables,
one with name LD_LIBRARY_PATH and value .:./plugins:.
one with name LIBRARY_PATH and value .:./components:.In the Debugger tab, remove the checkbox on “Stop on startup at:”
3. Click Apply and hit Debug to start debugging Firefox. If you face any issue, you can try to switch the debugger from gdb/mi to gdb Debugger.
Now time to read Introduction to Mozilla Source Code. I might one day create a similar tutorial for a Visual Studio environment. Enjoy !
The perfect companion to distcc is ccache:
http://ccache.samba.org
It speeds up compilation by making sure that only files that need to be recompiled will be sent to distcc and gcc. For example, if you do a “make clean” followed by another make, it will not need to recompile anything if the source files haven’t changed, since everything will be in cache already.
On Debian/Ubuntu, install it using apt-get:
sudo apt-get install ccache
Then, replace “distcc gcc” in your makefile with “ccache gcc” and put this in your shell (e.g. ~/.bashrc):
export CCACHE_PREFIX=distcc
(See the ccache manpage at http://ccache.samba.org/ccache-man.html for more info on how to run both at the same time.)
I’ll try that out. Thanks for the hint !
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
I have been looking everywhere for some of this information. I also found a free resourse that helped me when writing my resume. It explained why I dont need a cover letter for resume its free so I thought ok to post it here
I feel a lot more folks need to read this, very very good info.
Window Glass Replacement
Followers these tips and manual on how to remove and set split pane provide can meliorate foreclose you instant, money and endeavour. Privileged this credit you give reason information roughly: * Preparing for the New Window Container * Installing New Provide * Adding the Closing Touches * Substitution Glassware on Doors