`
izuoyan
  • 浏览: 8933016 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

chromium 构建步骤

 
阅读更多

因为伟大的墙,我没法轻松访问chromium开发的文档, 现在找了个代理,就先都保存下来,以后好看.

Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution 2.5 license, and examples are licensed under the BSD License.

The Chromium OS designs and code are preliminary. Expect them to evolve.
For Developers‎ > ‎How-Tos‎ > ‎

Build Instructions (Windows)

This page has detailed information on building Chromium on Windows, including tips for troubleshooting and for speeding up the build.


Build environment

Prerequisitesoftware

Additional (free) downloads

  1. If you use Microsoft Visual Studio 2005, install Microsoft Visual Studio 2005 Team Suite Service Pack 1.
    1. InstallKB935225,KB947315,KB949009,KB946310,and KB971090.
    2. If you're running Vista, you need to install Service Pack 1 Update for Windows Vista.
  2. If you use Microsoft Visual Studio 2008
    1. Install VS2008 Service Pack 1.
    2. InstallKB967631;KB960075; KB957912and KB971092. Yes, that's 400 megs of updates. :/
    3. InstallKB958842(unless you use Visual Studio 2008 Pro).
      1. Not necessary yet:KB956420andKB958357. Only if you enjoy downloading another 750 megs of data and wasting a few hours.
  3. Install theWindows 7 SDK. (v6.1 no longer works as of revision ~39982)
    1. Read the instructions on the SDK download page! Read it Again!
      1. If you use VS2005, you need to read point 5.1.5 in the release notes!
    2. You might need to reboot. You can save space by not installing the documentation and code samples.
    3. If you have previously installed an earlier version of the Windows SDK 6.0 and built Chromium, you need to do the following:
      1. Clobber your build (recursively delete (rd /s /q) the src/chrome/Debug andsrc/chrome/Release directories).
      2. Do a gclient sync --force
  4. Integrate the SDK with Visual Studio:
    1. Start > All Programs > Microsoft Windows SDK > Visual Studio Registration >Windows SDK Configuration Tool.
      If this program crashes, try running it from the command line with:windowssdkver -version:v7 -legacy
    2. If build still fails, try registering the SDK manually.
    3. If you had a previous version of the SDK installed before installing v7.0, verify that your VC++ directories are set to use v7.0 and not an earlier SDK. Seeregistering the SDK manuallyfor details.
  5. Install the DirectX SDK.
    1. Verify MSVC|Tools|Options|Projects and Solutions|VC++ Directories has Include: $(DXSDK_DIR)include and Lib:$(DXSDK_DIR)lib
  6. Get the Chromium depot_tools.

Chromium code

  1. Check out the source code using either the bootstrap tarball or a direct svn checkout.

Building Chromium

  1. Open the chrome/chrome.sln solution file in Visual Studio and build the solution. This can take from 10 minutes to 2 hours. More likely 1 hour.
  2. If you just want the Chromium browser, and none of the tests, you can speed up your build by right-clicking the chrome project in the solution explorer and selecting Build. You may want to make sure this project is the Startup project (which will display as bold) by right-clicking it and selecting Set as Startup Project. This will make Chromium (as opposed to some random test) build and run when you press F5.

Accelerating the build

In decreasing order of speedup:

  • Use a true multicore processor; ie. an Intel Core Duo or later; not a Pentium 4 HT.
  • Use a x64 OS otherwise incremental linking is disabled.
  • Have 8 gigs of RAM.
  • Use VS2008 or do this manual fix for VS2005:
    • Ensure that /MP is enabled. You can do this by creating a file called include.gypi which contains the following lines:
      {
      'variables': {
      'msvs_multi_core_compile': 1
      }
      }

      Put this file in a folder called
      .gyp under your home directory. On Windows, this will be something like:C:/Documents and Settings/<username>/.gyp/include.gypi,or if you are on Vista:C:/Users/<username>/.gyp/include.gypi
      .Use "mkdir %userprofile%/.gyp" in a command promptto create the folderbecause explorer may complain that you need to provide a file name.Make sure you run "gclient runhooks --force" after creating this file to rebuild the project files, forcing GYP to output /MP.
  • Disable your anti-virus software for.ilk,.pdb,.cc,.hfiles and only check for viruses onmodify. Disable scanning the directory where your sources reside.
  • Store and build the Chromium code ona second hard drive. It won't really speed up the build but at least your computer will stay responsive when you dogclient syncor a build.
  • Defragment your hard drive regularly.

Optional

Rebuild / Clean

You can use Rebuild and Clean on individual projects to rebuild them. However, because of the large number of files generated by the build system, avoid using Rebuild All or Clean All - these do not erase everything! Instead delete the entire output directory (chrome/Debug or chrome/Release).

Build Chromium with JavaScriptCore

Build with javascriptcore (JSC/KJS) is not maintained and not supported anymore.

Build Chromium with Command Line

You would need to have Visual Studio installed, but not running. Navigate to source directory (src/chrome) and type the following command:

C:/trunk/src/chrome>devenv.exe /build Debug chrome.sln /project chrome.vcproj

You can also use devenv.com with the same command-line. This will show the output of the various build commands, which can be useful when trying to track down errors during building.

Note for Windows Vista: the devenv command may silently fail if Visual Studio has been configured to always run asAdministrator. You can check or disable this by right clicking the Visual Studio application icon, then select Properties -> Compatibility -> Run this program as administrator.

Official/WPO/LTCG build

To enable whole program optimization / link-time code generation, make sure to set the environment variable:
  1. set GYP_DEFINES=branding=Chrome buildtype=Official
  2. gclient runhooks --force
  3. cd src/chrome
  4. chrome.sln
The dirty trick is defined in release_impl_official.gypi.

Unit tests

Some unit tests (such as gfx_unittests) require at least Vista/2008 with Platform Updateinstalled or Windows 7 to execute all of the tests completely.

Other tricks

See Visual Studio Macros page and debugging pages.
Blog post on setting a right-hand print margin

Running Chromium

Thechrome.exe executable can be found atchrome/Debug/chrome.exe or chrome/Release/chrome.exe, depending on the selected build configuration.

Because of Chromium's unique architecture, there are a number of special challenges associated with development. See Debugging Chromiumfor more information.

Once you're comfortable with building Chromium, read the Contributing Code pagefor information about writing code for Chromium and contributing it.

Packaging

If you want to package your build into a zip file, do the following:

cd /path/to/chrome
./tools/build/win/make_zip.sh Release my-chromium

This will create my-chromium.zip. You can change Release to Debug if you want to zip up the debug build instead.

Troubleshooting

Build failures on Vista

IfyoubuildonVista,watchoutforsecurityissues.Makesurethatthefolderwhereyoucheckedoutyourfilesiswritableforusersandnotonlyforadmins.

Compilation failures

Some common things to think about when you have weird compilation failures:

  1. Make sure you have SP1 for Visual Studio 2005. It's required. Really.
  2. If you happen to have checked out the source code before installing the build prerequisites (Visual Studio, the SDK, and all the patches), you'll need to re-generate the VS solution files by quitting Visual Studio and then running "gclient runhooks".
  3. Sometimes Visual Studio does the wrong thing when building Chromium and gets stuck on a bogus error. A good indication of this is if it is only failing for one person but others (including the Buildbots) are not complaining. To resolve this, try the following steps:
    1. Close Visual Studio.
    2. Sync to the tip of tree and ensure there are no conflicts ("svn status" should not show any "C"s in front of files that you've changed).
    3. If there were conflicts, sync again after resolving them.
    4. Manually erase the output directory (chrome/Debug and chrome/Release. Using the command line, you can use "erase /S /Q Debug Release" from the chrome directory to do this, or "rm -rf Debug Release" if you have Unix-like tools installed.
    5. Restart Visual Studio and open the Chromium solution.
    6. Rebuild the solution.
  4. If you get errors like these:
    * C:/Program Files/Microsoft SDKs/Windows/v6.1/Include/unknwn.idl(108) : error MIDL2025 : syntax error : expecting ] or , near "annotation"
    * browser/download/download_util.cc(469) : error C2065:'ITaskbarList3' : undeclared identifier
    You either have the wrong Platform SDK or it is incorrectly registered. Try installing theWindows 7 SDKor, if already installed, tryregistering the SDK manually.
  5. If you get errors like this:
    * error C2039: '_Swap_adl' : is not a member of 'std'
    Then you've likely run into a conflict between the Windows SDK and a security patch. See thisMSDN blog postfor more detailstryreinstalling Visual Studio SP1.

If it still doesn't work, repeating this process probably won't help.

Cygwin access control issues

If, while buildingJavaScriptCore, you see errors like:

3>Error in tempfile() using /tmp/dftables-XXXXXXXX.in: Parent directory (/tmp/) is not writable
3> at /cygdrive/c/b/slave/WEBKIT~1/build/webkit/third_party/JavaScriptCore/pcre/dftables line 236
3>make: *** [chartables.c] Error 255

...it's because the Cygwin installation included in the Chromium source is having trouble mapping the NT ACL to POSIX permissions. This seems to happen when Chromium is checked out into a directory for which Cygwin can't figure out the permissions in the first place, possibly when the directory is created from within a Cygwin environment before runningmkpasswd. Cygwin then imposes its own access control, which is incorrectly restrictive. As a workaround, do one of the following:

  • Edit the NT permissions onthird_party/cygwin/tmpto allowModifyandWriteactions forEveryoneandmachine/Users. Cygwin is able to figure this out. Or,
  • Figure out what went wrong with your checkout and try again - try doing the checkout fromcmdinstead of from a Cygwin shell, then verify that the permissions aren't completely blank in your Cygwin installation. Or,
  • Bypass Cygwin's access control (NT's will still be in effect) by editing webkit/build/JavaScriptCore/prebuild.bat and webkit/build/WebCore/prebuild.bat to include the following line before invoking anything that uses Cygwin:

    set CYGWIN=nontsec

Only one of these solutions should be needed.

Execution error messages

" This application has failed to start because the application configuration is incorrect "

or

"The system cannot execute the specified program "

Read the manual! Install Microsoft Visual Studio 2005 Service Pack 1 (download).

Manually registering the Platform SDK

  1. Open Visual Studio, Tools > Options... > Projects and Solutions > VC++ Directories
  2. Assuming your base SDK directory isC:/Program Files/Microsoft SDKs/Windows/v7.0, remove any existing entries v6.0 and v6.1 and add the following:
  • In Executable Files, insert on topC:/Program Files/Microsoft SDKs/Windows/v7.0/bin
  • In Include Files, insert on topC:/Program Files/Microsoft SDKs/Windows/v7.0/Include andC:/Program Files/Microsoft SDKs/Windows/v7.0/Include/gl
  • In Library Files, insert on topC:/Program Files/Microsoft SDKs/Windows/v7.0/lib
  • In Exclude directories, insert on topC:/Program Files/Microsoft SDKs/Windows/v7.0/Include andC:/Program Files/Microsoft SDKs/Windows/v7.0/Include/gl

Reinstalling Visual Studio SP1

If you get errors like this:
error C2039: '_Swap_adl' : is not a member of 'std'
then you've likely run into a conflict between the Windows SDK and a security patch. See this MSDN blog post for more details. The workaround is to re-download and over-install SP1 for Visual Studio 2008. Note that at this point you're going to need to re-install all of the hotfixes from above and you should verify that the SDK directories are correct and fix them if not (see "Manually registering the Platform SDK" above).

Special Service Pack Preparation Tool for Visual Studio 2008

If you are having weird compilation problems on Visual Studio 2008, you may have missed some small prints when downloading the Service Pack 1. Here's an excerpt for you:
  • If you previously installed a Visual Studio 2008 Hotfix or Visual Studio 2008 SP1 pre-release, you must run theService Pack Preparation toolbefore installing Visual Studio 2008 SP1.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics