Wednesday, September 26, 2007

Reading Mozilla Source Code

What can I say? Reading the Mozilla source code seemed to pose as a large scale challenge. Before I ever looked at the source code I was pretty confident with my programming knowledge. However, after looking at the source code (cpp files in particular) I was in awe. All the use of defines, typedef pointers (i think?), and extern C? made me run around in circles to understand just one method which to me seemed would be easy. The javascript and XUL was pretty straight foward and easily understandable so I was able to grasp some of what was happening. For those of you who really want to get involved with the code I would suggest reading the Mozilla structure and Styles in our weekly course schedule.

All in all, the basic idea that I could acquire after checking out the source code is that Mozilla works on 3 parts. The C++ code does all the actual work for most of the part, the javascript is called by different interactions with the UI, and the XUL files are basically used to display what you see on the screen. Please don't misunderstand me, not every process requires all 3 sections to do something however some actions cannot be done by javascript alone.

Here are the links to some of the information listed there:
Mozilla Source Code Directory Structure
A good way to understand the directory structure, however I like to use it as an index to navigate around MDC

Mozilla Style Guide
Portability Rules for C++
These two links were probably the most useful for me by giving me sample code to enforce the information

Monday, September 24, 2007

What Linux distro are you?

Have you ever wanted to try a new OS? Ever since I started getting into programming I've always wanted to try using Linux but never got around to it or have been a bit intimidated by the idea of not using Windows because it ran all the programs that I use. The only real contact that I've had with linux was probably using the school's servers for my assignments or playing with a thing or two on my own webhost. However, recently I've decided that I will never be able to experience what Linux is like until I install it and use it as my own platform. After doing some research, I realized that the choice wasn't so easy and that so many different distributions of Linux existed. So when I finally sat down I asked myself a question, "Which distribution is for me?" Seeking an answer I went to my good old friend, the Internet, and came up with this interesting site

>> Linux distribution chooser <<

Tuesday, September 18, 2007

Firefox 3

For those looking to work on Firefox 1.9 Trunk, you can use CVS to download the source code in the same fashion as my post on "Building Firefox in Windows".
Basically, you just run the start-msvc8.bat located in the c:\mozilla-build directory (this directory is installed when you run the Mozilla Build setup package 1.1).
Then when the MSYS console window opens you just need to:

Create a new directory in c:\
mkdir ff3project


Navigate into the directory
cd ff3project


Login to the Mozilla CVS mirror and get the make file
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r HEAD mozilla/client.mk



Download the source code using the make file
make -f client.mk checkout MOZ_CO_PROJECT=browser



I personally chose to keep the project in a seperate directory from my project. However, the choice is really yours.

Fore more information on CVS tags check out CVS Tags at developer.mozilla.org.

Building Firefox in Windows

I don't know if I was doing anything wrong or maybe if I had chosen the wrong set of build options, but building Firefox from source code does take pretty long on my pc. The whole build process took about 90 minutes of my life and 1.2GBs of hard drive space. I never thought that the files would be so large, so I had to start deleting stuff while it was compiling. Well, here is what I did to get it built. I was able to do this with cygwin and msys.

**NOTE: You will need about 2GBs of HD space before you begin. 250MBs for the cvs source, about 100MB for the tools (could be less but I had cygwin pre-installed), and 1.2GBs for the code?


STEP 1.
Download and install Visual Studios 2005 (referred to as VC8 on Mozilla sites).
Seneca students should be able to download and install this from our ACS site.
Click here for ACS
Then download and install the Mozilla Build Package 1.1
Download Mozilla Build Package 1.1
The package should install everything into c:\mozilla-build directory by default.
Once these two things are done, run the start-msvc8.bat in the c:\mozilla-build directory which will open up an application window with MINGW32 (referred to as MSYS).

STEP 2.
Now that the MSYS window is open (it will look something like command prompt), navigate your way back to the root c:\ - by default the application root for me was somewhere in my c:\document and settings\user\ which isn't allowed for the build procedure because of the spaces between the directory name.
Once you are in c:\ do the following in the MSYS console:

Make a new directory called proj.

mkdir proj


Navigate into proj directory.
cd proj


Open a connection with mozilla cvs server.
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk


Navigate into the new mozilla directory that was created by the cvs.
cd mozilla


Download the source code from CVS. This might take a little while so be patient. It took me about 5-10 minutes.
make -f client.mk checkout MOZ_CO_PROJECT=browser


*** You can easily change the MOZ_CO_PROJECT tag to download different projects or versions. Check out the mozilla dev site for more info or Click Here


STEP 3.
Once all the source code is downloaded. Create a ".mozconfig" file in the c:\proj\mozilla directory and fill it with your build options. Mine looked something like this:

# Options for client.mk.
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@

# Options for 'configure' (same as command-line options).
ac_add_options --enable-application=browser
ac_add_options --enable-debug
ac_add_options --disable-static
ac_add_options --disable-optimize


Once that is done type:
make -f client.mk build MOZ_CO_PROJECT=browser
This will build the source code. I would suggest you go do something else unless you have one of them top of the line PCs - this process took my about 90mins.

STEP 5.
Once the source code is built, hopefully with no errors, you should have a directory called "obj-i686-pc-mingw32" or something similar. Make sure any Firefox browsers are closed before continuing.
To run Minefield (Firefox 2 or 3?), run firefox located in c:\proj\mozilla\obj-i686-pc-mingw32\dist\bin

After a minute or two you should have a working build of Minefield.



If you would like to make an installer, you can type make installer in the c:\proj\mozilla\obj-i686-pc-mingw32 directory.

**NOTE: If Firefox is already running on your desktop running Minefield will only open a new window, so please close Firefox before running the application.

You are now COMPLETE!

Wednesday, September 12, 2007

The Cathedral and the Bazaar by Eric S. Raymond

I am impressed! The ideology behind open source (referred to as a "babbling bazaar") allows users around the world to take part in the development of software. Why does this method work so well? Just as Eric S. Raymond suggests, I believe that allowing others to contribute in more ways than filling a comment card gives them a sense of ownership; not in a literal sense that they own the software but that they are co-developers in the process. This model makes it more personal on the users and in return gets them more committed to seeing its success. The power of community also allows people from all around the world with many different expertise to work together and solve bugs; Eric S. Raymond's quote could not have said it any better - "Given a large enough beta-tester and co-developer base, almost every problem will be characterized quickly and the fix obvious to someone."

Furthermore, giving the users the ability to control where the software is headed by releasing it bit-by-bit is a great way to give the users what they want. Releasing software only at its final stage like the Cathedral model that Eric S. Raymond describes does not allow users to have much say in anything that they will be using. I am not saying that the Cathedral model is bad, however open source allows me to add some flavour.