Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 22 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
22
Dung lượng
70,15 KB
Nội dung
AppendixA.GettingandBuildingtheMozillaSource
One of the best things about using Mozilla as an application development
framework is that you don't need to get involved with theMozillasource
code to create a Mozilla application. A simple Mozilla binary that you
download and install is the only development platform you need. You can
create and use most procedures and samples described in this book with a
precompiled version of the browser.
The best way to get a working version of Mozilla quickly is to download a
precompiled binary for your platform. If you go to the mozilla.org
homepage, you will find links to Mozilla's most recent stable milestone build
for each platform and a link to the nightly development snapshot builds.
These binaries come as compressed archives or with an installer, and you
can use either to run Mozilla on your computer within a few minutes. These
binaries don't include thesource for Mozilla (unless you count the XUL,
CSS, and JavaScript that made up the front end, which are always available),
so read on if you want to obtain the code.
Under the relevant license terms, theMozillasource code is freely available
to anyone who has an Internet connection and a desire to explore. You may
want to look at this code out of curiosity or dive into the code as you figure
out how it works and can be improved. Whatever your reasons are for
looking at theMozilla source, it is not much more difficult to get the code
and build it yourself than it is to download the precompiled binaries. To get
started, you need to know a few things about how to get and use the source.
A.1. GettingtheSource Code
You can get theMozillasource code in a few different ways. Depending on
what you are interested in doing, one method may work better for you than
another. This appendix provides basic information about how to get the
source, but you can also find information about this topic on theMozilla site
at http://www.mozilla.org/source.html.
If you want to look at thesource code and don't intend to recompile it,
experiment with it, or update it at all, the best way to get at thesource is to
browse theMozilla code base with Mozilla Cross Reference (LXR). As you
can see in Figure A-1
, LXR is a web-based source code browsing tool
located at http://lxr.mozilla.org. LXR is also hooked up to other tools, such
as Bonsai (http://bonsai.mozilla.org) andthe various tinderboxen
(http://tinderbox.mozilla.org/showbuilds.cgi). Together, these tools create a
powerful code maintenance system that is used widely by Mozilla
developers.
Figure A-1. Mozilla Cross Reference code browsing tool
A.1.1. Downloading theSource with FTP
If you would like to get your hands on the code directly, use either File
Transfer Protocol (FTP) or Concurrent Versioning System (CVS) to grab the
source from theMozilla site. Many people prefer to start by grabbing an
archive of thesource code by FTP and then working with CVS as they
modify the code.
If you're sure you won't check your work back into Mozillaand you just
want to get the source, using FTP is the easiest way to do so. The main FTP
server is at ftp://ftp.mozilla.org/ (a list of FTP mirrors is available on the
mozilla.org site). To download a particular version of Mozilla, go to either
/pub/mozilla/nightly/latest/ or
/pub/mozilla/releases/, depending on which build you would like
to have.
When you download thesource from the releases directory, you get the code
for the most recent Mozilla milestone. These releases are versions of Mozilla
that have been tested and approved by developers at mozilla.org. Milestones
come out about once a month and have some implied stability. The code in
the "latest" directory is for the version of Mozilla currently under
development. This code is not tested and stability is not guaranteed. In fact,
the latest code may not even work if something that was checked in recently
breaks Mozilla.
A.1.2. Downloading theSource with CVS
Grabbing thesource with CVS requires additional steps to get things set up
properly, but for many, it's worth the effort. If you would like to contribute
your own changes back to the community, you must understand how CVS
works. Pulling thesource in this manner is a good way to start learning
about Mozilla development.
For a quick understanding of CVS, you can obtain a copy of the CVS Pocket
Reference (O'Reilly). To pick up a binary distribution of CVS if it isn't
already installed, go to http://www.cvshome.org/downloads.html, where
you'll also find links to documentation.
Using CVS requires logging into theMozilla site by using a CVS client,
checking out thesource code, modifying thesource code locally, and then
checking the code back into the tree. Anyone is free to check out the code,
but you need special permission to check in the changes you make to the
source. This chapter discusses only how to check out thesource with CVS.
You first need a CVS client. Free CVS clients are available for most
operating systems, including WinCVS on Windows and MacCVS for the
Mac. Linux has a command-line CVS client that should come standard on
most Linux distributions. Here are instructions for using the Linux
command-line client to check out thesource code:
1. Set the CVSROOT variable:
$ export CVSROOT=:pserver:anonymous@cvs-
mirror.mozilla.org:/cvsroot
1. Log in using the password "anonymous":
$ cvs login
CVS password: anonymous
1. Check out the build Makefile:
$ cvs checkout mozilla/client.mk
U mozilla/client.mk
1. Run the Makefile script to get the files:
$ cd mozilla
$ make -f client.mk checkout
On Windows, the command-line interface used to obtain theMozillasource
is very similar. You just need to make a few small changes to the steps
above for a Windows install. Here are the steps listed for comparison:
1. Set the CVSROOT variable:
> set CVSROOT=:pserver:anonymous@cvs-
mirror.mozilla.org:/cvsroot
1. Log in using the password "anonymous":
> cvs login
CVS password: anonymous
1. Check out the build Makefile:
> cvs checkout mozilla/client.mk
U mozilla/client.mk
1. Run the Makefile script to get the files:
> cd mozilla
> make -f client.mk checkout
In Step 1, set the CVSROOT environment variable using the set command.
Use the GNU make utility (make) on Windows just as you would on Unix.
Building using nmake is no longer supported on theMozilla
development trunk, though there is a document describing this process
for developers using older branches at
http://www.mozilla.org/build/win32-nmake.html.
Before you pull thesource code, check the tree status in the relevant
Tinderbox. Grab thesource only if the tree is green (success) or yellow
(building). Do not pull thesource on red, which indicates that the build is
broken.
To pull theMozillasource code on Macintosh, use a client like MacCVS,
which automates much of the CVS process for you. Mac OSX users can use
the standard command-line CVS client and pull thesource using a method
similar to checking out thesource in a Unix environment. Also be sure to
include the required resources XML Perl modules, MacPerl, or the
CodeWarrior development environment which are all listed later in Table
A-1.
The MacCVS client works with session files, which have all the information
and settings you need to pull Mozilla. The settings are listed on the
mozilla.org Mac build page, which even has a ready-made session file that
you can download into the client. Once you set your tools up and configure
your session file for MacCVS, you can pull theMozillasource by choosing
"Check Out Default Module" from the MacCVS Action menu. Like the
Macintosh build process, pulling thesource on Macintosh involves the
interaction of a series of Perl scripts. The PullMozilla.pl script,
located with the other Macintosh build scripts in
mozilla/build/mac/build_scripts, can drive your MacCVS client starting it
up and pointing to the right source, setting the proper variables, and so on.
For more information on the Macintosh build scripts, see
http://www.mozilla.org/build/mac-build-system.html.
A.1.3. Working with Branching
Branches are distinct Mozillasource code trees that are "cut" to carry out a
specific purpose or used for a milestone release. Developers cut branches
when making large architectural changes that could make the main tree
unstable. Branches in this context allow freer changing and testing off the
main trunk. To work with branches, set the MOZ_BRANCH environment
variable:
> setenv MOZ_BRANCH=MOZILLA_1_0_BRANCH
The value changes according to the repository with which you work. All
other steps can remain the same in the process.
To find out more about using CVS to get Mozillasourceand to learn about
what else you can do with CVS, go to http://www.mozilla.org/cvs.html.
A.2. BuildingtheSource Code
Now that you have theMozillasource code, what do you do with it? Unlike
the Mozilla binaries that are available for download, you can not start using
Mozilla once you have all thesource code on your computer. Before you can
start using the source, you need to set up your working environment and
then build Mozilla.
For theMozillasource to compile on your computer properly, two main
aspects of your build environment must be set up. These aspects are the
necessary tools andthe proper environment variables. You would expect
such a large code base to require a large number of tools, but there aren't so
many. Table A-1
lists the tools you need to build and run thesource code.
All information here is presented in more detail at
http://www.mozilla.org/build/, including links for gettingthe tools.
Table A-1. Platform tools used to build theMozillasource code
Linux Windows Macintosh
Linux Windows Macintosh
egcs 1.0.3 (or higher),
gcc 2.95.2
Microsoft Visual C++
Version 6.0 or later
(with service pack 3)
Code Warrior Pro 7
(including Plugin SDK)
GTK+ / Glib 1.2.0
Cygnus toolkit for
Windows (the build
page lists the specific
components)
Menu Sharing Toolkit
1.4
GNU make 3.74
Netscape Wintools
(modified versions of
gmake, shmsdos, and
uname)
ToolServer
Perl 5.005 (or higher) Perl5 for Win32
MacPerl
cpan-mac distribution
Perl AppleEvents
module
Perl Launch module
zip 2.3 (or higher) Zip for Win32
Compress:Zlib module
Archive::Zip module
LibIDL 0.6.3 (or higher)
(Required for static
Linux Windows Macintosh
build)
XML::RegExp
XML::Parser
XML::DOM
Autoconf 2.12 (optional)
The Linux environment is usually set up by default with all the tools listed
for that platform; it therefore requires less time to retrieve and set up
programs. Linux distributions usually come with a native compiler that is
compatible with theMozilla build system. Most build time is used compiling
the C++ source code the language most files are written in. Therefore, the
compiler is the central component of the build system. Linux uses egcs or
gcc, Windows uses Microsoft Visual C++, and Macintosh uses Metroworks
Code Warrior. The latest version of CVS for each platform accompanies all
tools listed in Table A-1
.
You can set various environment settings for each platform to configure and
optimize your build environment. Most settings are optional and some are
essential. One essential is the CVSROOT variable, which tells the CVS
server where to look for the tree's home or root. The next section looks at the
differences between the Unix, Windows, and Macintosh platforms.
A.2.1. Unix Environment
Unix is probably the easiest platform to configure. In fact, because it's a
developer's platform, it is designed to work with little or no user interaction.
[...]... executable s and DLLs You can set these variables either by using the set command for per session variables or the System > Advanced > Environment Variable panel in Control Panel to set them more permanently Once your environment is set andthe tools are in place, you can begin the build Go to themozilla directory in thesource code and from there, run the make script (client.mk) with the necessary... environment is set andthe tools are in place, building can begin Go to themozilla directory in thesource code and from there, run the make script (client.mak) with the necessary arguments: > nmake -f client.mak build_all Table A-3 lists these arguments and what they do Leaving out this compile flag starts an incremental build or a fresh build if there is no previous build available When building incrementally,... incrementally, try to use the provided make script instead of the cvs checkout and build_all commands The latter command can lead to inconsistencies in file versions and may re-download files that you do not even need to your tree Table A-3 Make flags Flag Function pull_all Gets only thesource code build_all Builds only the existing source code pull _and_ build_all Retrieves thesource code and then builds it...In thesource tree, script is provided to do all the work for you To run it, you need only the following steps: > cd mozilla > /configure Running this command gathers all necessary system information andthe list of Makefiles needed to compile thesource This command needs to be run only when a Makefile is added or removed from the tree After this, it is sufficient to compile Mozilla by launching... without pulling the tree, use: > make -f client.mk build_all_depend To get or update thesource code and not build, use: > make -f client.mk checkout A.2 .3 Macintosh Environment In terms of environment setup, necessary resources, and actual compile time, the Mac OS is the least straightforward of the three major platforms Mozilla builds on There are several different kinds of Mac builds at mozilla. org, but... platforms Mozilla builds on The minimum specification includes 1 GB of disk space and 128 MB of memory, but you will probably need even more in reality To compile the source, check out the module mozilla/ build/mac/build_scripts Once the download is complete, go to the folder and run BuildMozilla.pl for an optimized build or BuildMozillaDebug.pl for a debug build Running the CodeWarrior environment... setting is the ability to run Mozilla from any directory (rather than just dist/bin) To test this option, use MOZILLA_ FIVE_HOME to point to the full path, to the dist/bin, or wherever your executable resides A.2 .2 Windows Environment The setup is different on Windows and requires more interaction on the user's part, mostly in setting up environment variables Table A-2 lists these variables and expected... two: the Classic Mac OS 9's standard build, which has been the default for a long time, and Mac OS X's Code Fragment Manager (CFM) Mac OS X builds are becoming more popular as the platform is adopted more widely Better performance and native Unix build system tools have boosted developer support for Mozilla on Mac OS X However, the Macintosh is by far the most resource hungry of all platforms Mozilla. .. file onto Mozilla starts the application with those settings You can edit this file by adding or changing the ENV lines or make another file This modification method is useful for single session settings For more permanent settings, you can create a file called ENVIRONMENT and put it in the same folder as MozillaMozilla picks up the environment variables in the ENVIRONMENT file when it runs The file... build after pull _and_ build_all_dep retrieving thesource code Thesource tree is not accessed in a dependent build pull_ clientmak Pulls only the latest version of the build file client.mak Deletes all files produced from a clobber_all previous build to enable a completely fresh build Retrieves the XPConnect module Pull_xpconnect You can retrieve other modules this way, including nspr and psm To rebuild . Appendix A. Getting and Building the Mozilla Source
One of the best things about using Mozilla as an application development
framework is that you. don't need to get involved with the Mozilla source
code to create a Mozilla application. A simple Mozilla binary that you
download and install is the