编译Chromium 源码

LinuxBuildInstructions
Build instructions for Linux
Linux
Updated Jan 30, 2012by [email protected]

Overview

Due mostly to its history and its complexity, Chromium uses a nonstandard set of custom tools to check out and build. Here's an overview of the steps you'll run:

  1. gclient. A checkout involves pulling nearly 100 different SVN repositories of code. This process is managed with a tool calledgclient.
  2. gyp. The cross-platform build configuration system is calledgyp, and on Linux it generates Makefiles. Runninggypis analogous to the./configurestep seen in most other software.
  3. make. The actual build itself uses GNUmake.
  4. We don't provide any sort of "install" step.

Getting a checkout

  • Prerequisites: what you need before you build
  • Get the Code: check out the source code

Linux users often prefer to use Git. We have apage on how to check out the main tree with Git, but note that you still will need to understand and run all ofgclientandgypanyway.

First Time Build Bootstrap

  • Make sure your dependencies are up to date by running the install-build-deps.sh script:
    .../chromium/src $ ./build/install-build-deps.sh 

Configuring

Aftergclient syncfinishes, it will rungypautomatically to generate the Makefiles. You can re-run gyp yourself asbuild/gyp_chromium.

gypsupports a minimal amount of build configuration via the-Dflag.

./build/gyp_chromium -Dflag1=value1 -Dflag2=value2
  • gcc warnings. By default we fail to build if there are any compiler warnings. If you're getting warnings, can't build because of that, but just want to get things done, you can specify-Dwerror=to turn that off.
  • ChromeOS.-Dchromeos=1builds the ChromeOS version of Chrome. This isnotall of ChromeOS (seethe ChromiumOSpage for full build instructions), this is just the slightly tweaked version of the browser that runs on that system. Its not designed to be run outside of ChromeOS and some features won't work, but compiling on your Linux desktop can be useful for certain types of development and testing.

Compilation

The weird "src/" directory is an artifact of gclient. Start with:

$ cd src

Build just chrome

$ make chrome

Faster builds

To do a parallel build, add-jXwhere X is the number of make processes to start up. This is useful for multiple-core machines or machines using distcc.

Build every tests

$ make

The above builds all libraries and tests in all components.It will take hours.

Specifying other target names to restrict the build to just what you're interested in. To build just the simplest unit test:

$ make base_unittests

Or you can specify the explicit file you want to build:

$ make out/Debug/chrome

GCC 4.6 is not supported yet.You may run into some build errors (and patches are welcome to fix them). Please seehttp://crbug.com/80071before you proceed.

Clang builds

Information about building with Clang can be foundhere.

Output

Executables are written insrc/out/Debug/for Debug builds, andsrc/out/Release/for Release builds.

Release mode

AddBUILDTYPE=Releaseto the make invocation:

$ make BUILDTYPE=Release

Seeing the commands

If you want to see the actual commands that make is invoking, addV=1to the make invocation.

$ make V=1

This is useful if, for example, you are debugging gyp changes, or otherwise need to see what make is actually doing.

Clean builds

All built files are put into theout/directory, so to start over with a clean build, just:

rm -rf out

Troubleshooting

If you seemake: *** No targets specified and no makefile found. Stop., you probably need to rungypagain. See the "Configuring" steps above.

Linker Crashes

If, during the final link stage:

 LINK(target) out/Debug/chrome

You get an error like:

collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc'

collect2: ld terminated with signal 11 [Segmentation fault], core dumped 

you are probably running out of memory when linking. Try one of:

  1. Use thegoldlinker
  2. Build on a 64-bit computer
  3. Build in Release mode (debugging symbols require a lot of memory)
  4. Build as shared libraries (note: this build is for developers only, and may have broken functionality)
Most of these are described on the LinuxFasterBuildspage.

Advanced Features

  • Building frequently? SeeLinuxFasterBuilds.
  • Cross-compiling for ARM? SeeLinuxChromiumArm.
  • Want to use Eclipse as your IDE? SeeLinuxEclipseDev.

Next Steps

If you want to contribute to the effort toward a Chromium-based browser for Linux, please check out theLinux Development pagefor more information.

你可能感兴趣的:(编译Chromium 源码)