RSS

Tag Archives: Chrome

Source Code for Google Chrome

Well, it’s been quite a while, but here I am again.

Many developers want to get a “hands on” experience with the new toy (aka Chrome) so, without further delay…

Prerequisites

Build environment

  • Microsoft Windows XP SP2 or later, or Windows Vista.
  • Microsoft Visual Studio 2005 (8.0). Visual Studio 2003 and 2008 are not supported.
  • Microsoft Visual Studio 2005 Service Pack 1 (download).
  • Windows Vista SDK 6.0 or later (download). The Windows 2008 SDK is also supported. To integrate the SDK with Visual Studio, select Microsoft Windows SDK from the Start menu, then Visual Studio Registration > Integrate Windows SDK with Visual Studio 2005

Chromium checkout scripts

Download the depot_tools_win.zip package, which contains gclientgcl, and svn

tools. Add the depot_tools directory to your path:

 

C:\>set PATH=C:\depot_tools;%PATH%

The depot_tools package automatically updates itself every time gclient is run. See the depot_tools page if you want to disable this behavior.

Getting the code

Create a directory (with no spaces anywhere in the path name) to hold your source code. In this example we’ll assume it’s c:\trunk, but other names are fine.

Before syncing the client, visit the Chromium Buildbot waterfall and make sure it says the tree is OPEN at the top. [Note: If this part of the infrastructure is not yet working, please check the topic of the #chromium IRC channel on irc.freenode.net instead.] If you sync while the tree is CLOSED, the code may not compile or link. Once you’ve verified that the tree is open, run the following commands (using your directory in place of c:\trunk):

cd c:\trunk
gclient config
http://src.chromium.org/svn/trunk/src
gclient sync

You can expect this to take about an hour.

gclient config only needs to be run once to set up your working directory. It creates a .gclient file in your source directory that identifies the corresponding structure to pull from the repository. gclient sync will create several subdirectories in your tip directory. To update your tree in the future, you only need to run gclient sync from that directory. More information about gclient is available from the gclient wiki.

Building Chromium

Open the chrome/chrome.sln solution file in Visual Studio and build the solution. This can take from 15 to 40 minutes.

If you just want the Chromium browser, and none of the tests, you can speed up your build by right-clicking chrome_exe 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:

  • Install Microsoft hotfix 935225.
  • Install Microsoft hotfix 947315.
  • Use a true multicore processor (ie. an Intel Core Duo 2; not a Pentium 4 HT).
  • Use 3 parallel builds. In Visual Studio 2005, you will find the option in Tools > Options… > Projects and Solutions > Build and Run > maximum number of parallel project builds.
  • Disable your anti-virus software for .ilk, .pdb, .cc, .h files and only check for viruses on modify. Disable scanning the directory where your sources reside. Don’t do anything stupid.
  • Store and build the Chromium code on a second hard drive. It won’t really speed up the build but at least your computer will stay responsive when you do gclient sync or a build.
  • Defragment your hard drive regularly.
  • Disable virtual memory.

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

Our default solution file is chrome.sln which includes the V8 JavaScript engine. If you need to make a reference build of Chromium using JavaScriptCore, you should use the chrome_kjs.sln solution file. You will also need to set JS_ENGINE_TYPE=_kjs in your environment, then run Visual Studio (devenv) from that same command line. From the command line, type:
    C:\trunk\src\chrome> set JS_ENGINE_TYPE=_kjs
    C:\trunk\src\chrome> devenv chrome_kjs.sln
If the devenv command isn’t found, run the Visual Studio 2005 Command Prompt in your Start menu (by default, under Microsoft Visual Studio 2005 > Tools). This will set up the correct environment to run Visual Studio from the command line.
In Cygwin, use the following command:

$ JS_ENGINE_TYPE=_kjs devenv chrome_kjs.sln

Troubleshooting

Build failures on Vista

If you build on Vista, watch out for security issues. Make sure that the folder where you checked out your files is writable for users and not only for admins.

Compilation failures

Some common things to think about when you have weird compilation failures:
  • Make sure you have SP1 for Visual Studio 2005. It’s required. Really.
  • 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 st” 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.
If it still doesn’t work, repeating this process probably won’t help.

chrome_kjs.sln tempfile problems

If, while building JavaScriptCore, 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 running mkpasswd. Cygwin then imposes its own access control, which is incorrectly restrictive. As a workaround, do one of the following:
  • Edit the NT permissions on third_party\cygwin\tmp to allow Modify and Write actions for Everyone and machine\Users. Cygwin is able to figure this out. Or,
  • Figure out what went wrong with your checkout and try again – try doing the checkout from cmd instead 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.

Running Chromium

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

Debugging

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

Contributing

Once you’re comfortable with building Chromium, read the Contributing Code page for 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

Error message: This application has failed to start because the application configuration is incorrect or The system cannot execute the specified program

Install Microsoft Visual Studio 2005 Service Pack 1 (download).

Additional (free) downloads

Once Visual Studio is installed, you need to download and install some more software.

  1. Download and install Microsoft Visual Studio 2005 Service Pack 1.
    Depending on your computer, installation can take about an hour, and you might need to reboot.
  2. Download and install the Microsoft Windows SDK.
    You might need to reboot. You can save space by not installing the documentation and code samples.

    Note:
    Although the SDK says it’s for Vista, it works on both XP and Vista. If you already have the Microsoft 2008 SDK, you don’t need to install a new one.
  3. Integrate the SDK with Visual Studio: Start > All Programs > Microsoft Windows SDK > Visual Studio Registration > Integrate Windows SDK with Visual Studio 2005

  4. Get the Chromium depot_tools:
    1. Download depot_tools.zip. 

    2. Unzip the file.
      Note: If you have Cygwin installed, don’t use its unzip tool; it will mess up the permissions.
    3. Add the depot tools directory to your PATH. Example: C:\bin\depot_tools
      Note: By default, the depot_tools will automatically update to the latest version every time you run gclient. See the depot_tools page if you want to disable this behavior.

Chromium code

The Chromium codebase consists of hundreds of thousands of files, which means that a checkout straight from the Subversion (SVN) repository can take a long time. To speed up the process, we have provided a tarball that you can use to bootstrap the download. Alternatively, you can skip the tarball and download straight from SVN (not recommended).
Note: There is no advantage to checking out straight from SVN. The tarball includes SVN directories so that after you unpack the tarball, you can get up to the latest revision by using gclient sync.
If you only want to look at the source code, you’ll need at least 1.6 GB of hard drive space available. If you want to build it, you will need just under 10 GB of space, including all the object files and executables.

To bootstrap using the tarball:

  1. Make sure that you have a program that can untar .tar.gz files. Examples include the open-source 7-Zip archiver, the free BsdTar utility (part of LibArchive), and WinZip.  Note: Cygwin’s tar tool will not work; it will mess up the permissions.
  2. Download the source tarball.
  3. Choose a directory to hold your source code. Example: c:\chromiumtrunk

    Important:
    Make sure the directory path has no spaces.

  4. Untar the source tarball into the directory you’ve chosen. Example: If you’re using LibArchive, issue the following command:

    “C:\Program Files\GnuWin32\bin\bsdtar.exe” -xzf chromium.tgz
  5. Optionally, sync to the latest revision of Chromium:
    1. Visit the Chromium Buildbot waterfall to see the state of the tree. [Note: If this part of the infrastructure is not yet working, please check the topic of the #chromium IRC channel on irc.freenode.net instead.] If the top of the waterfall says:

      OPEN
      – The tree is in a good state and you should be able to compile the code. Go to the next step.

      CLOSED
      – There might be compile or test failures. You can download the code, but you’ll get those same failures when you try to compile or run tests. Best to check back later.
    2. In a shell window, execute the following commands:cd c:\chromiumtrunk
      gclient sync

      The gclient tool is included in the depot tools described above. The first time you execute gclient, there will be a delay (a minute or so) while it updates the depot tools.

To check out directly from SVN:

You’ll use the gclient depot tool to download the Chromium code from its SVN repository.

  1. Create a directory to hold your source code. Example: c:\chromiumtrunk

    Important:
    Make sure the directory path has no spaces.

  2. Visit the Chromium Buildbot waterfall to see the state of the tree. [Note: If this part of the infrastructure is not yet working, please check the topic of the #chromium IRC channel on irc.freenode.net instead.] If the top of the waterfall says:

    OPEN
    – The tree is in a good state and you should be able to compile the code. Go to the next step.

    CLOSED
    – There might be compile or test failures. You can download the code, but you’ll get those same failures when you try to compile or run tests. Best to check back later.
  3. In a shell window, execute the following commands:

    cd c:\chromiumtrunk

    gclient config http://src.chromium.org/svn/trunk/src
    gclient sync

The first time you execute gclient, there will be a delay (a minute or so) while it updates the depot tools. Downloading the Chromium code takes about an hour.

Build and launch Chromium

Once you have all the software and code, you can build Chromium and launch it in debug mode.
  1. Launch Visual Studio.
  2. Choose File > Open Project/Solution…, go to the src\chrome directory (under c:\chromiumtrunk or wherever you put the Chromium files), and open the file chrome.sln.
  3. In the Solution Explorer, go to the App directory, right-click chrome_exe, and choose Set as StartUp Project.
  4. Set the user profile used by your build of Chromium:
    1. Right-click chrome_exe, and choose Properties.
    2. In the left column, choose Configuration Properties > Debugging.
    3. In the right column, change the value of Command Arguments to something like this:

      –user-data-dir=c:\tmp\DebugProfile

Click Ok. Chromium creates the specified profile directory (c:\tmp\DebugProfile in the previous example) if the directory doesn’t already exist.

Note:
If you don’t set the profile, then if you try to launch Chromium when Google Chrome or Chromium is already running, a new window comes up in the already running browser. This behavior ensures exclusive access to the user profile, but it means that you can’t debug your version of Chromium!

Warning: If the latest build of Chromium has a new profile format, Google Chrome and older versions of Chromium might not be able to read that format. Unless you set the profile, you could lose your Google Chrome profile data.

  • Press F5, which builds the chrome_exe solution and launches Chromium in debug mode. When you’re asked whether to build out-of-date projects, choose Yes.
  • Building takes 15-40 minutes. When the build completes, a browser window appears on your desktop.
  •  
    6 Comments

    Posted by on September 12, 2008 in Beta Software

     

    Tags: ,