Calendar:Build: Difference between revisions

Jump to navigation Jump to search
no edit summary
mNo edit summary
No edit summary
Line 1: Line 1:
<p>Written on 26 Nov 07 and last updated on 27 Nov 07.</p>
This guide gives you all the information you need to get started with calendar development. While this guide might be quite long, I assume you will need 20-30 minutes ( + time to build the app) to set up everything and have a running development environment.
<p>Specs: MacBook Pro, 2.2Ghz, 2GB ram, 8600M GT 128MB, Mac OS X 10.4.11</p>
<p>Purpose: This guide is meant to serve as a quickstart on compiling Sunbird 0.7 for the Intel Mac, in under an hour. It is not intended to be comprehensive.</p>
<p>Why Sunbird: Sunbird is an application that can be compiled in under half an hour on my machine. (Firefox definitely takes much longer)</p>


<p>Documentation used:
Note this guide is written for use directly from the console. There is no known documentation to set up a build environment inside IDE's like eclipse. If you manage to set up eclipse for calendar, it would be great if you could contribute documentation!
http://developer.mozilla.org/en/docs/Build_Documentation
http://developer.mozilla.org/en/docs/Mac_OS_X_Build_Prerequisites
http://developer.mozilla.org/en/docs/Configuring_Build_Options
http://developer.mozilla.org/en/docs/Build_and_Install
</p>
<p><strong>1. Install the prerequisites</strong> (20 - 25 minutes, your mileage may vary)</p>
<p>Xcode 2.4.1 came with my Tiger restore DVD, and I installed it with the default options. (ten minutes)</p>
<p>Having a choice of Fink and MacPorts, I went with MacPorts. You can download it here:
http://svn.macosforge.org/repository/macports/downloads/MacPorts-1.5.0/ Installing MacPorts is as simple as running the installer found in the mounted .dmg. (five minutes)</p>


<p>Next, I used MacPorts to install libIDL (which also installs GLib): [note: ignore the &quot;$&quot;, it's meant to represent a set of commands to be executed]</p>
=Setting up prerequisites=
<p><em>$ sudo port sync<br/>
''General documentation [http://developer.mozilla.org/en/docs/Build_Documentation#Build_requirements here]''
$ sudo port install libidl</em></p>
<p>(You would need to have your administrative password ready; takes around five to ten minutes, depending on your internet connection)</p>
<p><strong>2. Download the source</strong> (5 minutes; depends on your internet connection)</p>
<p>I chose not (yet) to plunge into CVS and instead downloaded the source directly.
http://releases.mozilla.org/pub/mozilla.org/calendar/sunbird/releases/0.7/source/lightning-sunbird-0.7-source.tar.bz2


<p>I created a folder on my desktop called &quot;Test&quot; (or whatever you want to call it), dragged the .tar.bz2 file inside and ran this command from that folder &quot;Test&quot; in Terminal:</p>
The general section on build prerequisites is quite complete and should be used to determine what is needed.
<p><em>$ tar xjfv lightning-sunbird-0.7-source.tar.bz2</em></p>
<p>There will be an extracted &quot;mozilla&quot; folder inside.</p>
<p><strong>3. Configure build options</strong> (5 minutes)</p>


<p>In the mozilla folder, I ran</p>
====Additional, Mac-Specific info====
<p><em>$ echo &quot;# My first mozilla config&quot; &gt; .mozconfig</em></p>
You should install Xcode (i.e 2.4.1). This may be available on your MacOS Tiger restore CD (takes about ten minutes)
<p>in Terminal. This creates a .mozconfig file with the comment &quot;My first mozilla config&quot;.<br />
</p>
<p>I skipped all the Objdir stuff as I am only compiling Sunbird, and entered the .mozconfig below: (the ones with # are comments)</p>
<p><em># My first mozilla config<br />


# v0.1 alpha test</em></p>
Next you need to install either Fink or MacPorts. I went with MacPorts. You can download it [http://svn.macosforge.org/repository/macports/downloads/MacPorts-1.5.0/ here]. Installing MacPorts is as simple as running the installer found in the mounted .dmg. (five minutes)
<p><em> . $topsrcdir/calendar/sunbird/config/mozconfig<br />
  ac_add_options --enable-optimize<br />
  ac_add_options --disable-static --enable-shared<br />
  ac_add_options --disable-debug<br />
  ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk<br />


  ac_add_options --disable-tests</em></p>
Next, use MacPorts to install libIDL (which also installs GLib). You will need to have your administrative password ready; takes around five to ten minutes, depending on your internet connection.
<p>No debugging, no static build, no auxillary tests needed, optimized and Intel-only build configuration. For a more comprehensive documentation on all the switches and options in .mozconfig, please refer to:
<pre>
http://developer.mozilla.org/en/docs/Configuring_Build_Options</p>
sudo port sync<br/>
<p><strong>4. Build the source</strong> (25 minutes)</p>
sudo port install libidl
<p>Having done up everything, I proceeded to compile the source by this Terminal input in the same location as .mozconfig:</p>
</pre>
<p><em>$ make -f client.mk build</em></p>
<p>It took just under half an hour for my hardware configuration. Your mileage may vary though. I had no build problems.</p>


<p><strong>5. Run your program!</strong></p>
=Getting the source=
<p>The compiled Calendar.app (for Intel Mac only; not a universal binary) after completion appears in /mozilla/dist/. It takes up 7.4MB.</p>
''General documentation [http://developer.mozilla.org/en/docs/Mozilla_Source_Code_(CVS) here]''


<p>Due to trademark issues, there is a switch that must be input in .mozconfig to make it compile with official branding. For my case, it didn't matter to me, as I have just compiled my first application on the Mac. (Gentoo Linux experience a few years back was a good help too.)</p>
Source code should be checked out via CVS. To do so you should first create your mozconfig. This is an example mozconfig for calendar whcih can be used:
<p>Endnotes: I hope this guide serves as a decent beginner's guide to building Sunbird. It should be noted that any build questions should go to #calendar or #developers on irc.mozilla.org, where there are lots of other experienced people who are more than willing to answer any of your queries (Please ask nicely). Do read the Mozilla documentation as well.</p>
 
<pre>
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@
mk_add_options MOZ_CO_PROJECT=calendar # We want to checkout calendar
mk_add_options MOZ_CO_USE_MIRROR=1 # use cvs-mirror
# mk_add_options MOZ_CO_LOCALES=de # Can be used to also checkout a language
# mk_add_options MOZ_MAKE_FLAGS="-j3" # Can be used if you have multiple processors
mk_add_options JS_READLINE=1
 
# ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk # Needed on MAC
ac_add_options --enable-application=calendar # We want to build calendar
ac_add_options --disable-installer # Installer not needed for development
ac_add_options --disable-airbag # I have had problems with airbag in the past
ac_add_options --disable-crashreporter # (Optional) Disable if you don't want it
ac_add_options --enable-debugger-info-modules=yes # More debug info
# ac_add_options --enable-debug # (Optional) Lots of debugging. Maybe more than you actually want!
ac_add_options --enable-extensions=default,lightning,inspector,venkman # Some extensions in the /extensions directory
ac_add_options --enable-tests # You should enable tests to make sure everything works before posting a patch
# ac_add_options --enable-system-cairo # I needed this on linux
 
# The following options can be used to reduce/disable debugging.
# ac_add_options --enable-optimize
# ac_add_options --disable-static --enable-shared
# ac_add_options --disable-debug
</pre>
Save this file to your home directory to a file called ".mozconfig".
 
Now you can start checking out code. Use the following commands for the inital checkout. Do this in a folder where you want to have your tree. In general, you should use a directory that does not contain spaces or such, i.e on windows "C:\Documents and Settings\MyUsername\My Documents\mozilla" is not a good choice.
 
<pre>
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot mozilla/client.mk -r MOZILLA_1_8_BRANCH
cd mozilla
make -f client.mk checkout
</pre>
 
=Building the source (first time)=
If you have not previously built the source with the tree you just checked out, you need to do a full compile. Depending on platform and computer specs, this might take a while (Example: MacBook Pro, 2.2Ghz, 2GB ram, ~25-30 Minutes) Go have a beer inbetween or whatever you prefer :-) This will not be needed as often later on.
 
Assuming you are still in the mozilla directory you changed to above, now issue the following command:
<pre>
make -f client.mk build
</pre>
This will build everything needed for calendar. If everything went well, the last output won't contain any errors and you are ready to start your development build of sunbird.
 
=Running Sunbird=
You will find the binary to start Sunbird under the following paths. I assume <code>$MOZILLA</code> is the mozilla directory you changed to above. The <code>obj-</code> part may vary depending on platform, build system, and number of bits. The path on Mac also differs (i.e CalendarDebug.app) if you use <code>--enable-debug</code>
 
<pre>
# Windows
$MOZILLA/obj-i686-pc-cygwin/dist/bin/sunbird.exe
# Linux/Solaris
$MOZILLA/obj-i686-pc-linux-gnu/dist/bin/sunbird
# Mac
$MOZILLA/obj-i386-apple-darwin9.2.2/dist/Calendar.app/Contents/MacOS/sunbird
</pre>
 
Some interesting command line switches:
<pre>
-g              (Mac,Linux) Start using gdb as a debugger
-P <profile>    Start using a specific profile.
                Leave out <profile> to start the profile manager.
-console        (Windows) Open a console for debug messages
</pre>
 
=Running Lightning=
This section assumes you have a working thunderbird (2.0.0.*) installed. The best way to add Lightning to Thunderbird is to follow the [http://developer.mozilla.org/en/docs/Building_an_Extension#Test general steps], but for Lightning and Thunderbird. The id for Lightning is <code>{3550f703-e582-4d05-9a08-453d09bdfdc6}</code>. You should use a separate profile for development, to not destroy your normal profile.
 
The following steps make it easy on Linux, the profile path may be a bit different depending on your system. Remember to replace your profile name. This might also work out in a similar form on Windows and Mac.
<pre>
cd $MOZILLA/obj-*/dist/xpi-stage/lightning
pwd > ~/.mozilla-thunderbird/<development profile path>/extensions/{3550f703-e582-4d05-9a08-453d09bdfdc6}
</pre>
 
Now you can start thunderbird with your development profile.
<pre>
thunderbird -P <development profile name>
</pre>
 
This way, when you change code you will always be able to use the latest code, without reinstalling the extension.
 
=Updating Calendar=
If something has changed in calendar code, you will want to get the latest changes. The general documentation suggests you use client.mk to checkout all changes:
 
<pre>
cd $MOZILLA
cvs up -A -r MOZILLA_1_8_BRANCH client.mk
make -f client.mk checkout
</pre>
 
Fortunately, this is not needed very often, especially on MOZILLA_1_8_BRANCH. All you need to do is update the calendar directory. This is '''much''' faster than doing a full checkout.
 
<pre>
cd $MOZILLA/calendar
cvs up
</pre>
 
Go ahead and do the partial checkouts as long as you are able to compile calendar successfully. If you cannot the program to compile and you think it might have to do with other parts of mozilla (i.e toolkit), you can do a full update and compile.
 
=Building Sunbird and Lightning (after first time)=
After you have done a full build, it is usually not necessary to do the full build again for a while. The only case you might want to do a full build again is if something changed outside of calendar code that seems to affect building calendar (i.e a toolkit change).
 
==Sunbird==
Sunbird is usually much faster to compile, since you can selectively build parts of calendar, depending on what changed:
 
<pre>
cd $MOZILLA/obj-*/calendar
 
# The following command makes a full sunbird.
make && make -C sunbird
 
# If you didn't change anything in the calendar/sunbird directory
make
 
# If you only changed things in base/content or base/themes or prototypes/wcap
make -C base chrome
 
# If you only changed things in base, but the above doesn't seem to be enough:
make -C base
</pre>
 
'''Warning''': Especially if you make chrome, be sure that you don't have sunbird running. You may override your .jar files. If this happens, go into the top-level object directory and type make. This will remake all .jar files for the whole product (i.e including toolkit)
 
==Lightning==
Lightning always needs to be made in one piece, so just issue the following command:
 
<pre>
cd $MOZILLA/obj-*/calendar/lightning
make
</pre>
 
After this you can start thunderbird with your development profile, and you should be up to date.
 
 
=Debugging and Preferences=
You should set up your debugging environment in the same way you would for extension development. A nice guide can be found [http://developer.mozilla.org/en/docs/Setting_up_extension_development_environment here].
 
=Troubleshooting=
If you are having trouble, feel free to ask in #calendar on irc.mozilla.org. If you find no help there, try #developers. Do read the [http://developer.mozilla.org/en/docs/Build_Documentation Mozilla documentation] before asking.
264

edits

Navigation menu