gn tool 编译
之前介绍过GYP,它是Google早期用来维护chromium项目的meta-build system,GN则是用来替代GYP的工具,目前chromium及相关的开源项目都迁移到基于GN来管理。并且GN是基于C++编写,效率上比基于python的GYP快了近20倍。
环境准备
配置depot_tools (ninja)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
配置gn
虽然depot_tools已经带了gn,但它其实只是一个shell脚本,直接使用会报错,找不到真正的gn二进制文件。
如果编译过webrtc或chromium,gn相关的工具链已经下载,可以在src/buildtools/mac/gn
找到。
自己编译可以基于gn的git仓库编译,可以参考:
-
-
-
set -e
-
set -v
-
-
# Get the sources
-
mkdir gn-standalone
-
cd gn-standalone
-
mkdir tools
-
cd tools
-
git clone https://chromium.googlesource.com/chromium/src/tools/gn
-
cd ..
-
mkdir -p third_party/libevent
-
cd third_party/libevent
-
wget --no-check-certificate https://chromium.googlesource.com/chromium/chromium/+archive/master/third_party/libevent.tar.gz
-
tar -xvzf libevent.tar.gz
-
cd ../..
-
git clone https://chromium.googlesource.com/chromium/src/base
-
git clone https://chromium.googlesource.com/chromium/src/build
-
git clone https://chromium.googlesource.com/chromium/src/build/config
-
mkdir testing
-
cd testing
-
git clone https://chromium.googlesource.com/chromium/testing/gtest
-
cd ..
-
-
# Build
-
cd tools/gn
-
./bootstrap/bootstrap.py -s
-
-
# At this point, the resulting binary is at:
-
# gn-standalone/out/Release/gn
使用gn的例子
gn的例子可以参考gn的git仓库中带的example来开始。比如,以下测试的代码根目录是src
github :
https://github.com/zoujiaqing/gn google gn 工具
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了