gn tool 编译

之前介绍过GYP,它是Google早期用来维护chromium项目的meta-build system,GN则是用来替代GYP的工具,目前chromium及相关的开源项目都迁移到基于GN来管理。并且GN是基于C++编写,效率上比基于python的GYP快了近20倍。

环境准备

配置depot_tools (ninja)

参考:http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html

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仓库编译,可以参考:

  1.  
    #!/bin/bash
  2.  
     
  3.  
    set -e
  4.  
    set -v
  5.  
     
  6.  
    # Get the sources
  7.  
    mkdir gn-standalone
  8.  
    cd gn-standalone
  9.  
    mkdir tools
  10.  
    cd tools
  11.  
    git clone https://chromium.googlesource.com/chromium/src/tools/gn
  12.  
    cd ..
  13.  
    mkdir -p third_party/libevent
  14.  
    cd third_party/libevent
  15.  
    wget --no-check-certificate https://chromium.googlesource.com/chromium/chromium/+archive/master/third_party/libevent.tar.gz
  16.  
    tar -xvzf libevent.tar.gz
  17.  
    cd ../..
  18.  
    git clone https://chromium.googlesource.com/chromium/src/base
  19.  
    git clone https://chromium.googlesource.com/chromium/src/build
  20.  
    git clone https://chromium.googlesource.com/chromium/src/build/config
  21.  
    mkdir testing
  22.  
    cd testing
  23.  
    git clone https://chromium.googlesource.com/chromium/testing/gtest
  24.  
    cd ..
  25.  
     
  26.  
    # Build
  27.  
    cd tools/gn
  28.  
    ./bootstrap/bootstrap.py -s
  29.  
     
  30.  
    # At this point, the resulting binary is at:
  31.  
    # gn-standalone/out/Release/gn

使用gn的例子

gn的例子可以参考gn的git仓库中带的example来开始。比如,以下测试的代码根目录是src

 

 

github :

https://github.com/zoujiaqing/gn google gn 工具 

 

  

https://github.com/randyou/gn    

 

 

https://blog.csdn.net/rankun1/article/details/80396110  使用例子

posted on   lydstory  阅读(675)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示