编译Skia

Skia官方网站

Window 10

Python 2.7.8
Window 10 1909 (18363.1379)
Window 10 SDK
VS 2019
LLVM 11.0.0

  • 准备Python2,并且设置Python2的优先级高于Python3(在环境变量里Python2的路径比Python3先出现即可)
    否则会出现depot_tools错误和编译时ICU生成错误
  • 拉取部署工具库
    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
  • 拉取Skia仓库
    git clone https://skia.googlesource.com/skia.git
  • 同步需要的第三方库
    cd skia
    python2 tools/git-sync-deps
  • 设置VS路径
    在 bn\BUILDCONFIG.gn 文件中,设置
    win_vc = <VS_Path>
    win_vc = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC"
  • 生成编译文件
    Skia 编译成静态连接库中,会自动设置 Runtime 为 MT,需要手动设置为 MD
    Win 32位编译需要在输出文件夹中将 toolchain.ninjarule command 中所有的
    cmd.exe /c C:/Program Files (x86)/Windows Kits/10/bin/SetEnv.cmd /x86 &&
    去掉,实际上既没有这个脚本,也不需要这个脚本
    • win32 Debug 静态连接 /MDd Angle
      bin\gn gen out/Debug --args="is_debug=true target_cpu=\"x86\" extra_cflags=[\"/MDd\"] clang_win=\"C:/Program Files (x86)/LLVM\" skia_use_angle = true"
    • win32 Release 静态连接 /MD Angle
      bin\gn gen out/Release --args="is_debug=false target_cpu=\"x86\" extra_cflags=[\"/MD\"] clang_win=\"C:/Program Files (x86)/LLVM\" skia_use_angle = true"
  • 编译
    ninja -C <outpath>