Google 多源码管理工具 gclient
来源:互联网 发布:知乎在国外开中餐厅 编辑:程序博客网 时间:2024/05/16 08:20
本文根据gclient帮助整理。
google的chromium项目是用gclient来管理源码的checkout, update等。 gclient是google专门为这种多源项目编写的脚本,它可以将多个源码管理系统中的代码放在一起管理。甚至包括将git和svn代码放在一起。
gclient的sync,update等命令很容易学习和使用,不再多说,重点说明下和gclient密切相关的两类文件.gclient和DEPS。
.gclient文件是gclient的控制文件,该文件放在工作目录的最上层。".gclient"文件是一个Python的脚本(google真是对python情有独钟啊),定义了一组"solutions",格式类似如下
solutions = [ { "name" : "src", "url" : "svn://svnserver/component/trunk/src", "custom_deps" : { # To use the trunk of a component instead of what's in DEPS: #"component": "https://svnserver/component/trunk/", # To exclude a component from your working copy: #"data/really_large_component": None, } }, ]
- name : checkout出源码的名字
- url : 源码所在的目录,gclient希望checkout出的源码中包括一个DEPS的文件,这个文件包含了必须checkout到工作目录的源码的信息;
- deps_file 这是一个文件名(不包括路径),指在工程目录中包含依赖列表的文件,该项为可选,默认值为"DEPS"
- custom_deps 这是一个可选的字典对象,会覆盖工程的"DEPS"文件定义的条目。一般它用作本地目录中,那些不用checkout的代码,如
"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, },
或者让本地目录从不同位置checkout一个新的代码出来,或者checkout不同的分支、版本等。也可以用于增加在DEPS中不存在的新的项 目
- target_os : 这个可选的条目可以指出特殊的平台,根据平台来checkout出不同代码,如
target_os = ['android']如果target_os_only值为True的化,那么,仅仅checkout出对应的代码,如
target_os = [ "ios" ] target_os_only = True
在每个checkout出的工程中,gclient期望发现一个DEPS文件(由deps_file来给定),它定义了工程不同部分都是如何checkout出来。
“DEPS”也是一个python脚本,最简单的,如下:
deps = { "src/outside" : "http://outside-server/trunk@1234", "src/component" : "svn://svnserver/component/trunk/src@77829", "src/relative" : "/trunk/src@77829", }
deps的每个条目都包含一个key-value对,key是被checkout的本地目录,而value就是对应的远程URL。
如果路径是以'/'开头的,那么它是一个相对URL,相对与.gclient中URL地址。
URL通常包含一个版本号,以便锁定源码在特定版本上。当然,这是可选的。如果没有,那么它将获取指定分支上最新的版本。
DEPS还可以包含其他类型的数据,如vars,
vars = { 'pymox': 'http://pymox.googlecode.com/svn', 'sfntly': 'http://sfntly.googlecode.com/svn', 'eyes-free': 'http://eyes-free.googlecode.com/svn', 'rlz': 'http://rlz.googlecode.com/svn', 'smhasher': 'http://smhasher.googlecode.com/svn',...}
vars定义了一组变量,在后面,可以通过Var(xxx)来访问。Var(xxx)返回一个字符串,故此,也可以进行操作,如
'src/third_party/cros_dbus_cplusplus/source': Var("git.chromium.org") + '/chromiumos/third_party/dbus-cplusplus.git@5e8f6d9db5c2abfb91d91f751184f25bb5cd0900', 'src/third_party/WebKit': Var("webkit_trunk")[:-6] + '/branches/chromium/1548@153044',第二个自立,Var("webkit_trunk")[:-6]是一个python表达式,表示取得"webkit_trunk"表示的字符串的最后6个
Hooks:DEPS包含可选的内容 hooks,也有重要的作用,它表示在sync, update或者recert后,执行一个hook操作。
如果使用 --nohooks选项(hook默认执行),那么在gclient sync或者其他操作后,不会执行hook。你可以通过gclient runhooks来单独执行; 如果有 gclient sync --force,那么,无论sync是否成功,都会执行hook。
hook在DEPS中的写法,一般是:
hooks = [ { "pattern": "\\.(gif|jpe?g|pr0n|png)$", "action": ["python", "image_indexer.py", "--all"]}, { "pattern": ".", "name": "gyp", "action": ["python", "src/build/gyp_chromium"]}, ]
hooks包含一组hook,每个hook有几个重要项:
- pattern 是一个正则表达式,用来匹配工程目录下的文件,一旦匹配成功,action项就会执行
- action 描述一个根据特定参数运行的命令行。这个命令在每次gclient时,无论多少文件匹配,至多运行一次。这个命令和.gclient在同一目录下运行。如果第一个参数是"python",那么,当前的python解释器将被使用。如果包含字符串 "$matching_files",它将该字符串扩展为匹配出的文件列表。
- name 可选,标记出hook所属的组,可以被用来覆盖和重新组织。
deps_os: DEPS中定义不同平台依赖关系的项目,如
deps_os = { "win": { "src/chrome/tools/test/reference_build/chrome_win": "/trunk/deps/reference_builds/chrome_win@197743", "src/third_party/cygwin": "/trunk/deps/third_party/cygwin@133786",..... }, "ios": { "src/third_party/GTM": (Var("googlecode_url") % "google-toolbox-for-mac") + "/trunk@" + Var("gtm_revision"), "src/third_party/nss": "/trunk/deps/third_party/nss@" + Var("nss_revision"),.... },...}deps_os指定不同平台的依赖,它可以包含多种平台,和.gclient中的target_os对应。这种对应关系如下:
DEPS_OS_CHOICES = { "win32": "win", "win": "win", "cygwin": "win", "darwin": "mac", "mac": "mac", "unix": "unix", "linux": "unix", "linux2": "unix", "linux3": "unix", "android": "android", }
- Google 多源码管理工具 gclient
- Google 多源码管理工具 gclient
- Google 多源码管理工具 gclient .
- Google 多源码管理工具 gclient
- Webrtc 多源码管理工具 gclient
- 源码管理工具
- 下载chromium源码gclient代理设置 git代理设置
- 下载chromium源码gclient代理设置 git代理设置
- gclient 使用
- 编译google chromium代码,并修正gclient脚本中的一些bug
- 源码管理工具的使用
- Git-源码管理工具
- Google容器管理工具Kubernetes简介
- git源码管理工具学习笔记
- 你使用源码管理工具吗?
- chrome for android .gclient
- gclient sync 出错处理
- gclient 设置代理问题
- 类
- mule esb
- VS2010+Qt5.02配置完成后遇到的错误解决方案
- 为什么写这些博客
- 图形图像处理-之-高质量的快速的图像缩放 上篇 近邻取样插值和其速度优化
- Google 多源码管理工具 gclient
- Python学习(六)------- 序列类型
- 百度地图API实现定位与目的地导航
- 一个c语言题目
- linux系统时间修改及同步
- 浅谈Java线程启动与Thread.join()
- hdu 1257 最少拦截系统(DP)
- php同时作为server端和client端(soapclient)的超时时间设置小结
- mmap msync munmap close