Difference between revisions of "Development:Building:Mozilla 1.9.0 Branch"
(→Development: make the changes I talked about the other day) |
(→Appendix: add stub for page ilya asked about) |
||
Line 242: | Line 242: | ||
* [[Development:Building:Build Errors|Common Build Errors]] | * [[Development:Building:Build Errors|Common Build Errors]] | ||
+ | * [[Development:Building:Common make Targets|Common <tt>make</tt> Targets]] | ||
* [[Development:Building:Mozilla 1.8.* Branches|Building on the Mozilla 1.8.* branches]] (Camino 1.6.x, Camino 1.5.x, Camino 1.0.x) ''(in progress)'' | * [[Development:Building:Mozilla 1.8.* Branches|Building on the Mozilla 1.8.* branches]] (Camino 1.6.x, Camino 1.5.x, Camino 1.0.x) ''(in progress)'' | ||
* [[Development:Building:Building_Dependencies_from_Source|Building Dependencies from Source]] ''(in progress)'' | * [[Development:Building:Building_Dependencies_from_Source|Building Dependencies from Source]] ''(in progress)'' |
Revision as of 12:08, 24 January 2009
If you have comments or suggestions, please add them to the Discussion page.
The purpose of this page is to guide you through building and running Camino®. Camino is a stand-alone web browser powered by the Gecko rendering engine. It shouldn't be confused with CHBrowserView, which is just one piece of Camino. If you are new to Camino development, please see our developer introduction for an overview of project conventions and the tools you'll need.
These instructions assume that you are familiar with basic UNIX command-line functionality, such as cd
and mkdir
. For an introduction to the UNIX command line, please see this tutorial.
Contents
- 1 Preparing to build: Xcode
- 2 Choosing the correct compiler version on Mac OS X 10.4
- 3 libIDL and glib
- 4 Setting up your CVS Environment
- 5 Pulling Source and Building Gecko and Camino
- 6 Development
- 7 FAQ
- 7.1 Q. What versions of Mac OS X, Xcode, development SDK, and gcc are supported for building Camino?
- 7.2 Q. Can I build on Case-Sensitive HFS or UFS?
- 7.3 Q. How do I build a release version of Camino or build Camino from a specific branch?
- 7.4 Q. What are the cvs tags for recent branches, releases, and milestones?
- 7.5 Q. Why can't I get a fresh copy of Camino to build?
- 7.6 Q. I get an error from the Terminal or from Xcode when trying to build Camino; what's wrong?
- 7.7 Q. My Camino build crashes at startup; what's wrong?
- 7.8 Q. What if I still can't get Camino to build?
- 8 Appendix
Preparing to build: Xcode
Mac OS X 10.4.10 and Xcode 2.4.1 or later are now required for building Camino (Xcode 2.5 on Mac OS X 10.4.11 or Xcode 3 on Mac OS X 10.5.1 are recommended). Xcode is included on a separate disk with the purchase of a new Mac, and the latest version is alwsys available as a free download from Apple Developer Connection.
In addition to disk space required by developer tools and build prerequisites, you will need approximately 4 GB of free disk space for a single debug tree.
Installing Mac OS X Cross Development SDKs
Camino requires a custom Xcode installation to build properly: during installation, click the "Customize" button and turn on the "Cross Development" section. If you have previously installed Xcode without this option, run the installer again to add Cross Development before attempting to build Camino. Trunk versions of currently Camino require the 10.4u SDK for PPC, Intel, and Universal builds. If you are building other versions of Camino, other SDKs are required; see the Appendix for details.
Regardless of which version of Mac OS X you are using, we recommend you always upgrade to the latest "point" release of the OS (e.g., Mac OS X 10.4.11 and Mac OS X 10.5.1 as of December 2007) and the latest Xcode version available for that version of Mac OS X (Xcode 2.5 on 10.4.11, Xcode 3 on 10.5.1).
Upgrading Xcode
When you upgrade to a newer version of Xcode, even a minor-point release, be sure to re-install the Cross Development SDKs from the new version. In addition, delete the Xcode header cache in /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders
(where 501
is your user ID) before building Camino.
Choosing the correct compiler version on Mac OS X 10.4
Building Camino on the trunk now requires gcc 4.0.1 as the compiler (this is the default on Mac OS X 10.4, unless you have previously changed it).
If you are on a PowerPC Mac and have previously built Camino, you must change the default complier back to gcc 4 and then distclean
your existing tree before attempting to build with gcc4. Use the following commands to fix your gcc version and tree:
$ sudo gcc_select 4.0
$ cd /path/to/mozilla; make -f client.mk distclean
- If you are using an OBJDIR, instead use
$ cd /path/to/$OBJDIR; make distclean
libIDL
and glib
Follow the instructions on the Mozilla Mac OS X Build Prerequisites page for installing Fink or DarwinPorts (MacPorts) and using them to install libIDL
and glib
. DarwinPorts is recommended for Intel-based Macs. If you are using Fink, be sure to remove the /sw
directory entirely and reinstall Fink if you upgrade to a new major version of Mac OS X.
Setting up your CVS Environment
If you are building from the source tarball and never plan to update your Camino source code except by downloading a new source tarball, you can skip this section. Most users should perform these steps, however.
Prepare your CVS client using the following parameters:
server: cvs-mirror.mozilla.org
root directory: cvsroot
username: anonymous
password: anonymous
If you are using Terminal.app (recommended) and the bash shell (the default for user accounts created under Mac OS X 10.3 or later), the following command will set up and save the above CVS configuration information:
$ export CVSROOT=:pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot
If you are using another shell, you will have to use a different command to save the CVS configuration, but all subsequent commands in the checkout and build process are the same. (You can get to a bash shell at any time by typing "bash" at the command line and hitting "return.")
For more information on Mozilla CVS, see Mozilla Source Code Via CVS.
Pulling Source and Building Gecko and Camino
N.B. These instructions will build the “trunk” by default. If you want to build a specific branch (or a release or milestone from cvs rather than from the source tarball), please see the FAQ for changes you will need to make to some of these commands.
If you are building from the source tarball, skip to step 4 of this section.
cd
into the directory where you would like to keep your copy of the Camino source code (e.g.,cd ~/lizard
).- Pull the main build makefile and configuration directory:
$ cvs co mozilla/client.mk
$ cvs co mozilla/camino/config/mozconfig
$ cvs co mozilla/build/macosx/universal/mozconfig
The last file is needed only if you are building a Universal Camino. Please note that if you only want to compile Camino for use on an Intel Mac, you do not need to build a Universal Camino. cd
into themozilla
directory that was just created:
$ cd mozilla
- In your
mozilla
directory, create a plain text file called.mozconfig
(note the leading period). This file is where you will set up the options for your Camino build. To begin, add the following line to your.mozconfig
file (note the leading dot and space):
. $topsrcdir/camino/config/mozconfig
- Universal builds will need to add the following line immediately after the above line:
. $topsrcdir/build/macosx/universal/mozconfig
- Universal builds must also be built using an OBJDIR; be sure to add an OBJDIR line to your
.mozconfig
:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../CaminoUni
.mozconfig
optionsIn addition to specifying ("sourcing") the default Camino (and Universal)
.mozconfig
files and specifying an OBJDIR, your.mozconfig
should also contain settings to configure the type of build, and optionally to speed up builds on multi-processor or dual-core Macs.Optimized or Debug Mode Build
The default settings will create an optimized build of Camino. To build in debug mode (for easier troubleshooting during development), add the following two lines:
ac_add_options --disable-optimize
ac_add_options --enable-debugPlease Note: It's important to be aware of whether you've set up
.mozconfig
for a debug or optimized build, because you must match that setting when building Camino from Xcode. If the settings are not matched, key build variables won't get set correctly and vtables will be out of alignment. The net result is that either you won't link, or you'll crash at startup.If you are doing a Universal build, you must do an optimized (non-debug) build, as the Mozilla build system will fail towards the end of an attempt to make a Universal debug build.
Static or Dynamic Build
By default, Camino is built dynamically. To do a static build of Camino (which means that most of the components are compiled directly into the Camino binary), you can add the following lines to your
.mozconfig
file:
ac_add_options --disable-shared
ac_add_options --enable-staticStatic builds are used for distribution but are not recommended for development.
Building More Quickly on Dual Core or Dual-CPU Machines
If your machine has two CPUs or a dual core processor (like the Core Duo), you can take advantage of that while building Camino. Add the following to your
.mozconfig
file:
mk_add_options MOZ_MAKE_FLAGS=-j4
Sample
.mozconfig
Below are some sample
.mozconfig
files, pre-configured for typical usages.Development:
. $topsrcdir/camino/config/mozconfig ac_add_options --disable-optimize ac_add_options --enable-debug mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../CaminoTrunk
N.B. It is not necessary to build a Universal Camino for development (unless you plan on doing evil things that only work with gcc 4 and you need failed builds as a reminder). In fact, the Mozilla build system will fail towards the end of an attempt to make a Universal debug build.
Single-Architecture Distribution:
. $topsrcdir/camino/config/mozconfig ac_add_options --disable-shared ac_add_options --enable-static
Universal Distribution on a Dual-CPU Mac:
. $topsrcdir/camino/config/mozconfig . $topsrcdir/build/macosx/universal/mozconfig ac_add_options --disable-shared ac_add_options --enable-static mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../CaminoUni mk_add_options MOZ_MAKE_FLAGS=-j4
If you experience errors when using a -j flag, you might need to use a lower value with -j. Camino’s dual core, dual processor Xserve uses -j4 while Camino’s dual processor G5 tinderbox uses -j2.
- Universal builds will need to add the following line immediately after the above line:
- Pull source and build:
- To pull the source and build in one step, use:
$ make -f client.mk
This will automatically pull the source code from the CVS server and build Camino (including various components of Mozilla that Camino requires). The final Camino build ends up inmozilla/dist
(or$OBJDIR/dist
).
- To pull the source without building, use this command:
$ make -f client.mk checkout MOZ_CO_PROJECT=macbrowser
You can then build at any time by runningmake -f client.mk alldep
from themozilla
directory.
- If you're using the source tarball, use the following instead of the above commands:
$ cd mozilla
(if you are not already inmozilla
)
$ make -f client.mk alldep
- To pull the source and build in one step, use:
For more information on the build process, see Mac OS X Build Prerequisites and Mac OS X Universal Binaries in the Mozilla Developer Center.
If your build fails, consult the FAQ section below as well as the Common Build Errors page.
Development
To work on Camino application code, open up the Camino.xcodeproj
project (from the camino
directory of your OBJDIR) in Xcode. You can edit code, build, and run from inside of Xcode. (You can, of course, use an editor of your choice and rebuild either from Xcode or from the command line.)
When building with Xcode, make sure your build settings match those in your .mozconfig
file: from the "Active Build Style" item in the toolbar, choose "Development" for a debug build, or "Deployment" for an optimized build. If you do not match your settings to your .mozconfig
, your build will fail.
Camino code
If you've changed code only within the camino
directory, you can usually rebuild using Xcode. (Again, make sure your build settings match your .mozconfig
file).
.in
and generated files
However, if you’ve edited the source files for certain files that are generated during the build process (e.g., the .in
files for .strings
files, all-camino.js
, or the Makefile
) or any of the embed.jar
overrides, you will need to rebuild using the command line: cd $OBJDIR/camino; make
Widget code
If you've edited the Cocoa widget code, you can make
in $OBJDIR/widget/src/cocoa
to rebuild the widget library with your changes and then copy the new version of the widget library into your build.
The easiest way to get the new version of the library into Camino to test it is to use cp
to copy it into the Camino application package (into $OBJDIR/camino/build/Development/Camino.app/Contents/MacOS/components
). (This tactic does not work for static builds, which is why they are not recommended for development.) As an alternative, you can make
in $OBJDIR/embedding/config
and $OBJDIR/camino
again.
Other changes
If you've changed anything outside the camino
directory (aside from widget code — see above), you cannot build from inside Xcode, and will need to make -f client.mk
from the mozilla
directory (or make
from the root of your OBJDIR, if you're using an OBJDIR as recommended by the sample development .mozconfig
above).
Updating the source and rebuilding
Since the Mozilla core (Gecko) and Camino code are always under constant development, you will periodically want to update your source tree to stay current and to make sure your code will not conflict with any changes that have happened since you began working. (You will always want to make sure your tree is current before beginning work on the code and before submitting a patch for review.)
Before updating your tree, visit the Tinderbox and make sure that the columns whose headings end in “Cm2-M1.9” and “CmTrunk” are green (these are the Camino trunk builds). Then cd
to your mozilla
directory and run the following commands to update and rebuild your entire tree:
$ make -f client.mk
(To pull updated source files for the entire tree without rebuilding, substitute $ make -f client.mk checkout
for the second command, and then make
as usual when you are ready to build.)
It's possible in most cases to update only Camino code (unless Gecko changes have made changes to Camino code), but it is still recommended that you update your entire tree regularly. To update only the Camino code, cd
to your mozilla/camino
directory and run the following commands:
$ cvs update -dP
$ make
For OBJDIR builds used by most developers, replace make
with cd ../../{OBJDIR}/camino; make
(the sample development .mozconfig
above specifies an OBJDIR by default). Note that in OBJDIR builds, you must run make
from the command line after a cvs update
that pulls certain types of changes, including project changes and changes to any .strings
file, since updated versions of these files are copied into the OBJDIR or regenerated by Makefile targets.
Hacking configure
Sometimes you need to hack a configure
script to make Camino build a new Gecko extension (mozilla/extensions/foo
) or some other configurable part of the build. To do this, you have to patch configure.in
and then regenerate your local configure
to test the build with your changes.
To do this, you need autoconf-2.13
(the version of autoconf
that ships with all Mac OS X developer tools will not work). After you install autoconf
, you regenerate configure
simply by cd mozilla
and autoconf-2.13
. Then rebuild your tree as usual.
Packaging a build for testing
Sometimes you'll want to create a custom build to allow a large new feature to receive wider testing from the community before review or landing. In order to do this, you need to build with a “distribution” .mozconfig
. Then, when your build is complete, run make
in $OBJDIR/camino/installer
to produce a disk image for distribution. You can use your existing source tree but “swap in” a deployment .mozconfig
that defines a new OBJDIR to provide a clean build.
Cleaning your tree
Sometimes your build will fail because there are stale build products somewhere in the tree and new ones that conflict, or for other reasons related to the state of your tree. This can be fixed by cleaning your tree. To clean your tree, cd
to mozilla
and try make -f client.mk clean
. If that doesn't work, you need to make -f client.mk distclean
.
FAQ
Q. What versions of Mac OS X, Xcode, development SDK, and gcc are supported for building Camino?
A. There is a constantly-updated matrix of working build configurations on the Mozilla Wiki.
However, Camino officially supports building with Xcode 2.4.1 or higher, 10.4u SDK, and gcc 4 on Mac OS X 10.4.11 or 10.5.1 (Xcode 2.5 recommended for Mac OS X 10.4.11, and Xcode 3.0 recommended for Mac OS X 10.5.x), and these build instructions and the default .mozconfig
settings expect build environments to conform to these requirements. Your build will fail if you do not adhere to these requirements or make all the configuration changes required for another working configuration.
Q. Can I build on Case-Sensitive HFS or UFS?
A. Yes, on the trunk, the MOZILLA_1_8_BRANCH, and the CAMINO_1_5_BRANCH.
Q. How do I build a release version of Camino or build Camino from a specific branch?
A. These build instructions will build the “trunk” code for Camino, the site of ongoing development. If you want to build the latest Camino release, download and unpack the source tarball for that release instead of checking out source from cvs.
For release builds of Camino, be sure to add the following lines to your .mozconfig
file:
ac_add_options --disable-shared
ac_add_options --enable-static
After editing your .mozconfig
, start your build by running make -f client.mk
from your mozilla
directory.
If you wish to build the Camino code that exists on a certain branch, you should follow the main instructions for checking out the source code but modify the two cvs co
commands to include the appropriate branch tag. To build Camino code on the Mozilla 1.8 branch (Camino 1.6.x), the appropriate commands are as follows:
$ cvs co -r MOZILLA_1_8_BRANCH mozilla/client.mk
$ cvs co -r MOZILLA_1_8_BRANCH mozilla/camino/config/mozconfig
Note that all Camino development is done on the trunk and back-ported to the branches if needed, so those wishing to become involved in Camino development should follow the main instructions.
Note that Camino 1.6.x/MOZILLA_1_8_BRANCH, Camino 1.5.x/CAMINO_1_5_BRANCH, and Camino 1.0.x/MOZILLA_1_8_0_BRANCH all require different SDK and compiler configurations from the trunk, as well as changes to the Shared Menus Framework, in order to build; see the Appendix for more information.
Q. What are the cvs tags for recent branches, releases, and milestones?
A. Use the following cvs tags in your cvs co -r
commands above in order to build these versions of Camino:
CAMINO_2_0_B1_RELEASE
- Camino 2.0 Beta 1 milestone releaseMOZILLA_1_8_BRANCH
- Camino 1.6.x security releasesCAMINO_1_6_6_RELEASE
- Camino 1.6.6 releaseCAMINO_1_5_5_RELEASE
- Camino 1.5.5 legacy release (for 10.3.0-10.3.8 users)CAMINO_1_0_6_RELEASE
- Camino 1.0.6 legacy release (for 10.2.8 users)
Q. Why can't I get a fresh copy of Camino to build?
A. Despite our best efforts, sometimes the Mozilla or Camino tree is "red," meaning that the source code won't build properly in its current state. Before you pull, you can check the status on Camino's tinderbox. If the Camino tinderbox or the Mac builds in the SeaMonkey or Firefox tinderboxes are red, you probably should avoid checking out.
If your build fails, just wait until things go green again and re-pull Camino.
If the tree was green when you pulled your source, consult the list of common build errors and see if your error is listed. If so, follow the steps listed there to fix your build.
Q. I get an error from the Terminal or from Xcode when trying to build Camino; what's wrong?
A. Consult the list of common build errors and see if your error is listed. If so, follow the steps listed there to fix your build.
Q. My Camino build crashes at startup; what's wrong?
A. This has most likely occurred because you are building from within Xcode and have set up your .mozconfig
for an optimized build and Xcode for a debug build, or the other way around. Follow the instructions above to set your build mode in both the .mozconfig
and Xcode, or just build from the command line using make -f client.mk
.
Q. What if I still can't get Camino to build?
A. First check the Build Errors page to see if you've run in to any of the common errors. If not, there are two places to go for help building Camino:
- The #camino IRC channel at irc.mozilla.org is a good place to find some Mac weenies in real time who, if you ask nicely and don't be a pest, will happily get you on your way.
- For non-real-time build help, the Camino forum at MozillaZine has a number of regulars who can usually solve your build woes.
Appendix
- Common Build Errors
- Common make Targets
- Building on the Mozilla 1.8.* branches (Camino 1.6.x, Camino 1.5.x, Camino 1.0.x) (in progress)
- Building Dependencies from Source (in progress)