用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
hedongfu的公告
<center><img src=http://services.nexodyne.com/email/icon/k.W7Iq.oxtQ%3D/EfrVnrY%3D/R01haWw%3D/0/image.png></center> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-730147-1"; urchinTracker(); </script>
文章分类
友情链接
Google 黑板报
KarlChen
上善若水
孙华勇
将族
开复学生网
陈睿
靠近我
存档

原创  开发谷歌浏览器Chrome 收藏

谷歌浏览器Chrome推出几天了,源代码也已经开放供全球的编程爱好者开发。我也在第一时间下载并在本地编译、链接成功。按照的官方网站的步骤,基本上没有什么问题。不过该网站目前只能通过代理访问,为了方便国内的开发者,我把文章翻译过来,同时官方的英文版也拷贝在下面,英语好的同学可直接跳到下面的英文版。

开始

如果你很关心Chromium是怎样工作的,这篇文章就是为你而写.你会得到Chromium的代码和生成它.然后你就可以使用Visual Studio 2005 来调试看它是怎样工作的。你也可以看一下它对普遍的用户行为是怎样反应的.

注意:这篇文章是为那些安装了Windows的并想了解正在运行的代码的开发者和测试者提供的.如果你还没有运行环境,你可以看看文档.如果你没有Windows,请看MacLinux的编译指示.

得到你需要的软件

这一节告诉你怎样设置你的Windows开发环境.如果你碰到问题或想了解更细节的内容,开发指示(Windows).

必须软件

首先,你的电脑上必须安装了下列软件:

  • Windows XP (SP2 or later) or Windows Vista
  • Microsoft Visual Studio 2005 (8.0)

额外(免费)下载

一旦Visual Studio安装成功了,你需要下载和安装一些其它的软件。

  1. 下载并安装Microsoft Visual Studio 2005 Service Pack 1.取决于你的电脑,安装可能需要一个小时,并且你可能需要重启。
  2. 下载并安装Microsoft Windows SDK.

你可能需要重启。如果你不安装文档和代码示例,能节省一部分磁盘空间。

  1. 注意:虽然SDK说它是针对Vista的,但它在XPVista都能工作。如果你已经安装了Microsoft 2008 SDK,你不需要再安装新的。
  2. 集成SDKVisual Studio

开始>所有程序>Microsoft Windows SDK>Visual Studio 注册>集成 Windows SDK Visual Studio 2005

  1. 得到Chromium depot_tools:
    1. 下载depot_tools.zip.
    2. 解压缩文件。

注意:如果你安装了Cygwin,不要用它的解压缩工具;他会把权限搞混乱。

    1. depot工具的路径加到PATH里。比如:: C:\bin\depot_tools

注意:每次你运行gclient,这个工具depot_tools默认会自动更新代码到最新版本。请看depot_tools页面如果你想禁用这个行为。

Chromium的代码

Chromium的代码库包括了成千上万个文件,这意味着如果你直接从Subversion (SVN) 拿会花很长时间。为了加快这个步骤,我们提供了tarball,你能使用bootstrap来下载。你也可以跳过tarball直接从SVN上下载(不推荐)。

注意:从SVN上下载并没有什么直接的好处。Tarball包括了SVN的目录,所以你把tarball解压缩后,你可以使用gclient sync来得到最新的版本。

 

如果你只是想看看代码,你需要至少1.6GB的硬盘空间。如果你想编译、链接,你需要10GB的空间,包括所有的目标文件和可执行文件。

tarball得到源代码:

  1. 确保你有软件可以解压缩.tar.gz格式的文件。
  2. 下载source tarball
  3. 选个目录来存放你的源代码。比如c:\chromiumtrunk

重要提示:确保这个路径没有空格。

  1. 把源代码解压缩到你选的目录。

  2. 这步是可选的,把Chromium代码更新到最新版本:

a)   访问Chromium Buildbot waterfall看树的最新版本。

OPEN这个树的状态是好的,并且你可以编译这个代码。转到下一步。

CLOSED有可能有编译、测试错误。你能下载代码,但是当你编译或运行测试用例时可能会碰到错误。最好稍后再来访问。

b)   windowshell,执行下列命令:
cd c:\chromiumtrunk
gclient sync

这个gclient工具包括了刚才提到的depot tools。你第一次执行时可能会比较慢(大概1分钟),因为好更新depot tools

编译并运行Chromium

一旦你有了软件和代码,你就可以在debug模式下生成并运行Chromium了。

  1. 打开Visual Studio
  2. 选择文件>打开项目/解决方案,到src\chrome目录(在c:\chromiumtrunk或你放Chromium的地方),然后打开文件chrome.sln.
  3. 在解决方案这个选项卡了,到App目录,右击chrome_exe,选择设为启动项目。
  4. 设置用来生成你的Chromium的用户文件:
    1. 右击chrome_exe, 然后选择 Properties.
    2. 在左边栏,选择 配置属性>调试
    3. 在右边,把命令参数改成类似下面的样子:

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

选择确定。如果这个路径不存在,Chromium会帮你生成。

  1. F5,就会在debug模式下编译、链接chrome_exe 。然后你会被问到是否生成过时的项目,选择是。
  2. 编译大概会花15-40分钟。生成结束后,你的桌面会出现一个浏览器。

 


以下是官方网站英文原版:

Getting Started

If you're serious about learning how Chromium works, this is the page for you. You'll get the Chromium code and build it. Then you'll use the Visual Studio 2005 debugger to see how the browser works — in particular, how it responds to common user actions.

 

Note: This page is aimed at developers and testers who have Windows and want to inspect running code. If you're not ready to set up a build environment, you can read the documentation. If you don't have Windows, check out the build instructions for Mac and Linux.

Get the software you need

This section tells you how to set up your Windows build environment. If you have problems or want further details, see Build Instructions (Windows).

Prerequisite software

First, your computer must have the following software installed:

  • Windows XP (SP2 or later) or Windows Vista
  • Microsoft Visual Studio 2005 (8.0)

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.
  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.
  5. 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.
  6. Building takes 15-40 minutes. When the build completes, a browser window appears on your desktop.

    If the build fails or a new browser window does not appear, go to Build Instructions (Windows) for help.

 

发表于 @ 2008年09月06日 20:12:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:偶遇李开复 | 新一篇:自行车卖了

  • 发表评论
  • 评论内容:
  •  
Copyright © hedongfu
Powered by CSDN Blog