Linux chromium 源码下载及编译


1. Chromium Souce Code Download

    1.1  download source code

1> 方法一

# 获得所有发布tag的信息。
git fetch --tags
 
# 根据37.0.2062.103版本建立一个你自己的分支
git checkout -b your_release_branch 37.0.2062.103
 
// 同步所有相关工程代码
gclient sync --with_branch_heads --jobs 16

2>方法2

 .gclient

solutions = [
  {
    "managed": True,
    "name": "src",
    "url": "https://chromium.googlesource.com/chromium/[email protected]",
    "custom_deps": {
    "src/content/test/data/layout_tests/LayoutTests": None,
    "src/chrome/tools/test/reference_build/chrome_win": None,
    "src/chrome_frame/tools/test/reference_build/chrome_win":None,
    "src/chrome/tools/test/reference_build/chrome_linux":None,
    "src/chrome/tools/test/reference_build/chrome_mac": None,
    "src/third_party/hunspell_dictionaries": None,
    },
    "deps_file": ".DEPS.git",
    "safesync_url": "",
  },
]
target_os = ['android']
    然后 gclient  sync --with_branch_heads --jobs 16

  1.2 配置gyp

~/chromium$ echo "{ 'GYP_DEFINES': 'OS=android', }"> chromium.gyp_env

~/chromium$ gclient runhooks

1.3 安装jdk

1.4 build

~/chormium$ . build/android/envsetup.sh // 配置环境

~/chromium$ android_gyp //在out目录下生成*.ninja文件,会读取环境变量GYP_DEFINES确定platform

// chromium39推荐使用./build/gyp_chromium来代替android_gyp

~/chromium$ ninja -C out/Release content_shell_apk

如果GYP_DEFINES设置不正确,会产生错误ninja: error: unknown target 'content_shell_apk', did you mean 'content_shell_pak'?



2. Build

   http://code.google.com/p/chromium/wiki/LinuxBuildInstructions

   ./build/gyp_chromium -Dflag1=value1 -Dflag2=value2 // create 'out' folder and makefiles
   ninja -C out/Release chrome

   // ninja -C out/Debug chrome // 4G内存 4Gswap 编译了大概有3个小时


   目前能成功编译,但是运行crash,sanbox问题。待解。。。


3. Debug Render进程

    3.1 调试browser进程

     gdb out/Debug/chrome // 只能调试browser进程代码,即只有browse代码的断点能停住

    3.2 调试render进程

    3.2.1  先运行chrome

       ./out/Debug/chrome

    3.2.2 查看render进程id

        pstree -ap | grep chrome

        返回结果如下

         |                      |-bash(6496)---chrome(7043)-+-chrome(7044)
          |                      |                                                |-chrome(7045)-+-chrome(7076)-+-{chrome}(7077)
          |                      |                                                |              |                                      |-{chrome}(7078)
          |                      |                                                |              |                                      `-{chrome}(7128)

             7076 就是render进程id

    3.3.3 运行gdb 并attach到render进程id (需要root 运行gdb,否则attach失败

        $su

         #gdb

         (gdb) attach 7076

          Attaching to process 7076
          Reading symbols from /home/xxx/work/chrome/google/src/out/Debug/chrome...done.

         (gdb) b WebCore::ResourceLoader::didReceiveResponse
         Breakpoint 1 at 0x7f67077c6ea6: file ../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp, line 317.
         (gdb) c

         //刷新界面后,断点停住,可用bt来查看callstack

        (gdb) bt
#0  WebCore::ResourceLoader::didReceiveResponse (this=0x3518a8a35da0, response=...)
    at ../../third_party/WebKit/Source/core/loader/ResourceLoader.cpp:317
#1  0x00007f670815a35e in WebCore::ResourceHandleInternal::didReceiveResponse (this=0x3518a89138e0, response=...)
    at ../../third_party/WebKit/Source/core/platform/network/ResourceHandle.cpp:122
#2  0x00007f6707cc440f in webkit_glue::WebURLLoaderImpl::Context::OnReceivedResponse (this=0x3518a825fb60, info=...)
    at ../../webkit/glue/weburlloader_impl.cc:640

。。。。。


        

你可能感兴趣的:(Linux chromium 源码下载及编译)