skia官网:

https://skia.org/

官网下载和编译说明:

https://skia.org/user/download

https://skia.org/user/build

下载参考的下面第一个文章链接

github有个镜像https://github.com/google/skia

注:

// 取消代理

git config --global --unset http.proxy

git config --global --unset https.proxy

skia下载配置

注:最好在根目录执行克隆操作,因为有些工程文件名太长,造成最后编译不通过

# 克隆代码
git clone https://skia.googlesource.com/skia.git
# 进入skia目录
cd skia
# 同步,这个有点卡住的感觉,要稍微等一下
python tools/git-sync-deps

完成后,skia/bin/gn.exe 文件就出现了,skia\third_party\externals目下应该还下载了其他依赖

修改配置文件,补充VC路径,从官方文档看,需要VS2017或者2019,需要支持-std=c++17

# 打开skia\gn\BUILDCONFIG.gn文件查找win_vc = "",我的版本在27行在引号内添加VC路径,修改为自己电脑路径win_vc = "D:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC"

ninja下载配置

# 返回上一级目录
cd ..
# 下载ninja
git clone https://github.com/ninja-build/ninja.git

打开VS2019命令行编译ninja,最好使用x86的

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC\x86 Native Tools Command Prompt for VS 2019
# 进入ninja目录
cd ninja
# 编译
python configure.py --bootstrap
# 编译完成后目录中生成ninja.exe
# 设置ninja目录到临时环境变量中
set PATH=%PATH%;D:\XXX\skia\ninja
# 返回到skia目录,执行ninja命令
cd ..
cd skia
ninja
# 我的提示ninja: error: loading 'build.ninja': 系统找不到指定的文件。那么环境变量设置成功
# 生成CMakeLists.txt等文件,在目录skia\out\config
.\bin\gn.exe gen out/config --ide=json --json-ide-script=../../gn/gn_to_cmake.py
# 启动cmake工具
cmake-gui
# 由于只是设置了临时的环境变量,所以必须在命令行中启动cmake工具,cmake时需要ninja

设置路径后,点击Configure,

Configuring done之后点击Generate,不出问题那么VS工程就已经生成了

编译然后就报错了,工程比较多,编译也比较久

严重性    代码    说明    项目    文件    行    禁止显示状态
错误    MSB3491    未能向文件“Win32\Debug\third_party__spirv-tools_spvtools_vendor_tables_spv-amd-shader-explicit-vertex-parameter\third_pa.34E880A9.tlog\third_party__spirv-tools_spvtools_vendor_tables_spv-amd-shader-explicit-vertex-parameter.lastbuildstate”写入命令行。路径: Win32\Debug\third_party__spirv-tools_spvtools_vendor_tables_spv-amd-shader-explicit-vertex-parameter\third_pa.34E880A9.tlog\third_party__spirv-tools_spvtools_vendor_tables_spv-amd-shader-explicit-vertex-parameter.lastbuildstate 超过 OS 最大路径限制。完全限定的文件名必须少于 260 个字符。    third_party__spirv-tools_spvtools_vendor_tables_spv-amd-shader-explicit-vertex-parameter    d:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets    354

据说把工程放到根目录就好

严重性    代码    说明    项目    文件    行    禁止显示状态错误    D8016    “/O2”和“/RTC1”命令行选项不兼容    third_party__spirv-tools_spvtools

选择失败的项目,基本都是third_party_XXX的项目,可以批量选择修改,右键属性,C/C++->代码生成->基本运行时检查,选择默认


官网页面搬砖:

How to download Skia

Install depot_tools and Git

Follow the instructions on Installing Chromium's depot_tools to download depot_tools (which includes gclient, git-cl, and Ninja). Below is a summary of the necessary steps.

git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'
export PATH="${PWD}/depot_tools:${PATH}"

depot_tools will also install Git on your system, if it wasn't installed already.

Clone the Skia repository

Skia can either be cloned using git or the fetch tool that is installed with depot_tools.

git clone https://skia.googlesource.com/skia.git
# or
# fetch skia
cd skia
python2 tools/git-sync-deps

Getting started with Skia

You will probably now want to build Skia.

Changing and contributing to Skia

At this point, you have everything you need to build and use Skia! If you want to make changes, and possibly contribute them back to the Skia project, read How To Submit a Patch.


How to build Skia

Make sure you have first followed the instructions to download Skia.

Skia uses GN to configure its builds.

  • is_official_build and Third-party Dependencies
  • Supported and Preferred Compilers
  • Quickstart
  • Android
  • ChromeOS
  • Mac
  • iOS
  • Windows
  • Windows ARM64
  • CMake

is_official_build and Third-party Dependencies

Most users of Skia should set is_official_build=true, and most developers should leave it to its false default.

This mode configures Skia in a way that's suitable to ship: an optimized build with no debug symbols, dynamically linked against its third-party dependencies using the ordinary library search path.

In contrast, the developer-oriented default is an unoptimized build with full debug symbols and all third-party dependencies built from source and embedded into libskia. This is how we do all our manual and automated testing.

Skia offers several features that make use of third-party libraries, like libpng, libwebp, or libjpeg-turbo to decode images, or ICU and sftnly to subset fonts. All these third-party dependencies are optional and can be controlled by a GN argument that looks something like skia_use_foo for appropriate foo.

If skia_use_foo is enabled, enabling skia_use_system_foo will build and link Skia against the headers and libaries found on the system paths. is_official_build=true enables all skia_use_system_foo by default. You can use extra_cflags and extra_ldflags to add include or library paths if needed.

Supported and Preferred Compilers

While Skia should compile with GCC, MSVC, and other compilers, a number of routines in Skia's software backend have been written to run fastest when compiled with Clang. If you depend on software rasterization, image decoding, or color space conversion and compile Skia with a compiler other than Clang, you will see dramatically worse performance. This choice was only a matter of prioritization; there is nothing fundamentally wrong with non-Clang compilers. So if this is a serious issue for you, please let us know on the mailing list.

Skia makes use of C++17 language features (compiles with -std=c++17 flag) and thus requires a C++17 compatible compiler. Clang 5 and later implement all of the features of the c++17 standard. Older compilers that lack C++17 support may produce non-obvious compilation errors. You can configure your build to use specific executables for cc and cxx invocations using e.g. --args='cc="clang-6.0" cxx="clang++6.0"' GN build arguments, as illustrated in Quickstart. This can be useful for building Skia without needing to modify your machine's default compiler toolchain.

Quickstart

Run gn gen to generate your build files. As arguments to gn gen, pass a name for your build directory, and optionally --args= to configure the build type.

To build Skia as a static library in a build directory named out/Static:

bin/gn gen out/Static --args='is_official_build=true'

To build Skia as a shared library (DLL) in a build directory named out/Shared:

bin/gn gen out/Shared --args='is_official_build=true is_component_build=true'

If you find that you don't have bin/gn, make sure you've run:

python2 tools/git-sync-deps

For a list of available build arguments, take a look at gn/skia.gni, or run:

bin/gn args out/Debug --list

GN allows multiple build folders to coexist; each build can be configured separately as desired. For example:

bin/gn gen out/Debug
bin/gn gen out/Release  --args='is_debug=false'
bin/gn gen out/Clang    --args='cc="clang" cxx="clang++"'
bin/gn gen out/Cached   --args='cc_wrapper="ccache"'
bin/gn gen out/RTTI     --args='extra_cflags_cc=["-frtti"]'

Once you have generated your build files, run Ninja to compile and link Skia:

ninja -C out/Static

If some header files are missing, install the corresponding dependencies:

tools/install_dependencies.sh

To pull new changes and rebuild:

git pull
python tools/git-sync-deps
ninja -C out/Static

Android

To build Skia for Android you need an Android NDK.

If you do not have an NDK and have access to CIPD, you can use one of these commands to fetch the NDK our bots use:

python2 infra/bots/assets/android_ndk_linux/download.py -t /tmp/ndk
python2 infra/bots/assets/android_ndk_darwin/download.py -t /tmp/ndk
python2 infra/bots/assets/android_ndk_windows/download.py -t C:/ndk

When generating your GN build files, pass the path to your ndk and your desired target_cpu:

bin/gn gen out/arm   --args='ndk="/tmp/ndk" target_cpu="arm"'
bin/gn gen out/arm64 --args='ndk="/tmp/ndk" target_cpu="arm64"'
bin/gn gen out/x64   --args='ndk="/tmp/ndk" target_cpu="x64"'
bin/gn gen out/x86   --args='ndk="/tmp/ndk" target_cpu="x86"'

Other arguments like is_debug and is_component_build continue to work. Tweaking ndk_api gives you access to newer Android features like Vulkan.

To test on an Android device, push the binary and resources over, and run it as normal. You may find bin/droid convenient.

ninja -C out/arm64
adb push out/arm64/dm /data/local/tmp
adb push resources /data/local/tmp
adb shell "cd /data/local/tmp; ./dm --src gm --config gl"

ChromeOS

To cross-compile Skia for arm ChromeOS devices the following is needed:

  • Clang 4 or newer
  • An armhf sysroot
  • The (E)GL lib files on the arm chromebook to link against.

To compile Skia for an x86 ChromeOS device, one only needs Clang and the lib files.

If you have access to CIPD, you can fetch all of these as follows:

python2 infra/bots/assets/clang_linux/download.py  -t /opt/clang
python2 infra/bots/assets/armhf_sysroot/download.py -t /opt/armhf_sysroot
python2 infra/bots/assets/chromebook_arm_gles/download.py -t /opt/chromebook_arm_gles
python2 infra/bots/assets/chromebook_x86_64_gles/download.py -t /opt/chromebook_x86_64_gles

If you don't have authorization to use those assets, then see the README.md files for armhf_sysroot, chromebook_arm_gles, and chromebook_x86_64_gles for instructions on creating those assets.

Once those files are in place, generate the GN args that resemble the following:

#ARM
cc= "/opt/clang/bin/clang"
cxx = "/opt/clang/bin/clang++"extra_asmflags = ["--target=armv7a-linux-gnueabihf","--sysroot=/opt/armhf_sysroot/","-march=armv7-a","-mfpu=neon","-mthumb",
]
extra_cflags=["--target=armv7a-linux-gnueabihf","--sysroot=/opt/armhf_sysroot","-I/opt/chromebook_arm_gles/include","-I/opt/armhf_sysroot/include/","-I/opt/armhf_sysroot/include/c++/4.8.4/","-I/opt/armhf_sysroot/include/c++/4.8.4/arm-linux-gnueabihf/","-DMESA_EGL_NO_X11_HEADERS","-funwind-tables",
]
extra_ldflags=["--sysroot=/opt/armhf_sysroot","-B/opt/armhf_sysroot/bin","-B/opt/armhf_sysroot/gcc-cross","-L/opt/armhf_sysroot/gcc-cross","-L/opt/armhf_sysroot/lib","-L/opt/chromebook_arm_gles/lib","--target=armv7a-linux-gnueabihf",
]
target_cpu="arm"
skia_use_fontconfig = false
skia_use_system_freetype2 = false
skia_use_egl = true# x86_64
cc= "/opt/clang/bin/clang"
cxx = "/opt/clang/bin/clang++"
extra_cflags=["-I/opt/clang/include/c++/v1/","-I/opt/chromebook_x86_64_gles/include","-DMESA_EGL_NO_X11_HEADERS","-DEGL_NO_IMAGE_EXTERNAL",
]
extra_ldflags=["-stdlib=libc++","-fuse-ld=lld","-L/opt/chromebook_x86_64_gles/lib",
]
target_cpu="x64"
skia_use_fontconfig = false
skia_use_system_freetype2 = false
skia_use_egl = true

Compile dm (or another executable of your choice) with ninja, as per usual.

Push the binary to a chromebook via ssh and run dm as normal using the gles GPU config.

Most chromebooks by default have their home directory partition marked as noexec. To avoid "permission denied" errors, remember to run something like:

sudo mount -i -o remount,exec /home/chronos

Mac

Mac users may want to pass --ide=xcode to bin/gn gen to generate an Xcode project.

iOS

Run GN to generate your build files. Set target_os="ios" to build for iOS. This defaults to target_cpu="arm64". Choosing x64 targets the iOS simulator.

bin/gn gen out/ios64  --args='target_os="ios"'
bin/gn gen out/ios32  --args='target_os="ios" target_cpu="arm"'
bin/gn gen out/iossim --args='target_os="ios" target_cpu="x64"'

This will also package (and for devices, sign) iOS test binaries. This defaults to a Google signing identity and provisioning profile. To use a different one set the GN args skia_ios_identity to match your code signing identity and skia_ios_profile to the name of your provisioning profile, e.g.

skia_ios_identity=".*Jane Doe.*"
skia_ios_profile="iPad Profile"`

A list of identities can be found by typing security find-identity on the command line. The name of the provisioning profile should be available on the Apple Developer site. Alternatively, skia_ios_profile can be the absolute path to the mobileprovision file.

If you find yourself missing a Google signing identity or provisioning profile, you'll want to have a read through go/appledev.

For signed packages ios-deploy makes installing and running them on a device easy:

ios-deploy -b out/Debug/dm.app -d --args "--match foo"

Alternatively you can generate an Xcode project by passing --ide=xcode to bin/gn gen. If you are using Xcode version 10 or later, you may need to go to Project Settings... and verify that Build System: is set to Legacy Build System.

Deploying to a device with an OS older than the current SDK can be done by setting the ios_min_target arg:

ios_min_target = "<major>.<minor>"

where <major>.<minor> is the iOS version on the device, e.g., 12.0 or 11.4.

Windows

Skia can build on Windows with Visual Studio 2017 or 2019. If GN is unable to locate either of those, it will print an error message. In that case, you can pass your VC path to GN via win_vc.

Skia can be compiled with the free Build Tools for Visual Studio 2017 or 2019.

The bots use a packaged 2019 toolchain, which Googlers can download like this:

python2 infra/bots/assets/win_toolchain/download.py -t C:/toolchain

You can then pass the VC and SDK paths to GN by setting your GN args:

win_vc = "C:\toolchain\VC"
win_sdk = "C:\toolchain\win_sdk"

This toolchain is the only way we support 32-bit builds, by also setting target_cpu="x86".

The Skia build assumes that the PATHEXT environment variable contains ".EXE".

Highly Recommended: Build with clang-cl

Skia uses generated code that is only optimized when Skia is built with clang. Other compilers get generic unoptimized code.

Setting the cc and cxx gn args is not sufficient to build with clang-cl. These variables are ignored on Windows. Instead set the variable clang_win to your LLVM installation directory. If you installed the prebuilt LLVM downloaded from here in the default location that would be:

clang_win = "C:\Program Files\LLVM"

Follow the standard Windows path specification and not MinGW convention (e.g. C:\Program Files\LLVM not /c/Program Files/LLVM).

Visual Studio Solutions

If you use Visual Studio, you may want to pass --ide=vs to bin/gn gen to generate all.sln. That solution will exist within the GN directory for the specific configuration, and will only build/run that configuration.

If you want a Visual Studio Solution that supports multiple GN configurations, there is a helper script. It requires that all of your GN directories be inside the out directory. First, create all of your GN configurations as usual. Pass --ide=vs when running bin/gn gen for each one. Then:

python2 gn/gn_meta_sln.py

This creates a new dedicated output directory and solution file out/sln/skia.sln. It has one solution configuration for each GN configuration, and supports building and running any of them. It also adjusts syntax highlighting of inactive code blocks based on preprocessor definitions from the selected solution configuration.

Windows ARM64

There is early, experimental support for Windows 10 on ARM. This currently requires (a recent version of) MSVC, and the Visual C++ compilers and libraries for ARM64 individual component in the Visual Studio Installer. For Googlers, the win_toolchain asset includes the ARM64 compiler.

To use that toolchain, set the target_cpu GN argument to "arm64". Note that OpenGL is not supported by Windows 10 on ARM, so Skia's GL backends are stubbed out, and will not work. ANGLE is supported:

bin/gn gen out/win-arm64 --args='target_cpu="arm64" skia_use_angle=true'

This will produce a build of Skia that can use the software or ANGLE backends, in DM. Viewer only works when launched with --backend angle, because the software backend tries to use OpenGL to display the window contents.

CMake

We have added a GN-to-CMake translator mainly for use with IDEs that like CMake project descriptions. This is not meant for any purpose beyond development.

bin/gn gen out/config --ide=json --json-ide-script=../../gn/gn_to_cmake.py

参考:

https://www.cnblogs.com/alita/p/10616318.html

https://www.jianshu.com/p/4225f4342d18

https://blog.csdn.net/qq_36640999/article/details/85066999

那些编译skia跳过的坑 https://blog.csdn.net/weixin_42001089/article/details/80320424

skia windows编译相关推荐

  1. Skia Windows 编译

    Skia Windows 编译 编译环境:win10 64位.VS2017.git.LLVM 一.下载Skia相关源码 1. 下载google工具depot_tools git clone https ...

  2. OGRE 2.1 Windows 编译

    版权所有,转载请注明链接 OGRE 2.1 Windows 编译 环境: Windows 7 64Bit Visual Studio 2012 OGRE 2.1 CMake 2.8.12.1 OGRE ...

  3. DCNv2 windows编译2021

    2019年曾经写过一篇DCNv2 windows编译的博客 https://blog.csdn.net/jacke121/article/details/91355170 当时vs2015是编译成功的 ...

  4. Cef mysql.exe_CEF3.2623使用记录:windows编译

    CEF3.2623使用记录:windows编译 1:cef3.2623下载地址 2623是cef3最后一个支持xp系统的版本,且可以支持html的audio标签,可以用作对html音频的处理下载地址为 ...

  5. LibreCAD for windows 编译

    LibreCAD for windows 编译 项目中要用到平面CAD功能,找到libreCAD,发现不很适合需求,需要重新改造一下:)要改造就要编译: 1.下载源码解压到H盘 2.用notepad+ ...

  6. FreeRDP 2.0 for Windows 编译

    简介 Freerdp 一个开源的RDP跨平台客户端: https://github.com/FreeRDP/FreeRDP 版本 2020-04-09 Github上其发布了2.0版本: 只下载其re ...

  7. Windows编译FreeRDP

    Windows编译FreeRDP 需要准备的工具 1.安装CMake (cmake-gui) 2.安装`Visual Studio Community 2017` 3.下载`FreeRDP`源码 4. ...

  8. windows编译g20问题解决记录

    windows编译g20问题解决记录 error C3861: 'vasprintf': identifier not found 参考链接 here

  9. Windows编译安装AzerothCore魔兽世界开源服务端Lua脚本引擎Eluna和防作弊anticheat模块教程

    Windows编译安装AzerothCore魔兽世界开源服务端Lua脚本引擎Eluna和防作弊anticheat模块教程 大家好,我是艾西今天和大家聊聊魔兽世界游戏内的脚步以及防作弊模块 Eluna是 ...

最新文章

  1. List数组,string数组,Dictionary字典三种contain方法的查询速度
  2. Linux文件系统的隐藏权限:chattr lsattr(journal)
  3. tomcat日志格式中的含义
  4. Solr入门和实践以及我对Solr的8点理解
  5. P1352-没有上司的舞会【树形dp】
  6. css 向左白色箭头,带CSS的工具提示左侧的箭头
  7. js图片压缩java上传,JS实现异步上传压缩图片
  8. 信息学奥赛一本通C++语言——1016: 整型数据类型存储空间大小
  9. (转)国外 RPA 企业盘点:谁是领导者,谁是挑战者
  10. unity 入门学习之(二)脚本学习
  11. Android开发 -使用腾讯TBS浏览服务 X5webview控件
  12. 【游戏客户端】如何实现环形进度条
  13. 【教程】EasyDSS演示模式播放ws-flv格式视频流,如何控制3分钟自动跳转登录页?
  14. harries算子特征提取与图像匹配
  15. 《程序员面试金典(第6版)》面试题 08.14. 布尔运算(动态规划,分治,递归,难度hard++)
  16. [CF802N][jzoj5378]闷声刷大题
  17. galaxy s4刷机相关说明
  18. 柚子壁纸为什么自动安装_火爆抖音的时间罗盘壁纸,iPhone和安卓都支持!
  19. 功能测试如何转型自动化测试
  20. SparkListener监听使用方式及自定义的事件处理动作

热门文章

  1. 网站刷关键词_2019年刷百度统计的最新技巧,让你又多一种推广渠道
  2. 3D打印品牌的康复骨科支具有何特别之处?
  3. shell获取明天、上周、上个月时间
  4. 【考研英语语法】十三种时态
  5. 网站程序有漏洞用waf可以防护吗?如何防护?
  6. Idea的hierarchy打开
  7. 双边滤波和交叉双边滤波
  8. origin打开时遇到mfc110.dll或是msvcp.dll的解决方法
  9. 清退300余名研究生!四川大学回应:最早已入学18年!
  10. H3C S3600 交换机 VLAN中不同类型端口的配置