Google 멀티소스 관리 도구 gclient
6131 단어 webikit
Google의 chromium 프로젝트는 gclient로 원본을 관리하는 checkout, 업데이트 등입니다.gclient는 구글이 이런 다원 프로젝트를 위한 스크립트로 여러 개의 원본 관리 시스템의 코드를 함께 관리할 수 있습니다.심지어git와svn 코드를 함께 놓는 것도 포함된다.
gclient의sync,update 등 명령은 쉽게 학습하고 사용할 수 있습니다. 더 이상 말하지 않고 gclient와 밀접한 관계를 가진 두 가지 파일을 중점적으로 설명합니다.gclient 및 DEPS.
.gclient 파일은 gclient의 제어 파일로 작업 디렉터리의 맨 위에 있습니다.'.gclient '파일은 파이톤의 스크립트입니다. (구글은 정말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,
}
},
]
"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 = ['android']
만약 targetos_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의 모든 항목은 키-value 쌍을 포함하고 키는 checkout의 로컬 디렉터리이며,value는 대응하는 원격 URL입니다.
만약 경로가 '/' 로 시작한다면, 이것은 상대적인 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을 실행합니다.
DEPS에서 hook의 쓰기 방법은 다음과 같습니다.
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에는 몇 가지 중요한 항목이 있다.
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의 targetos 대응.이러한 대응 관계는 다음과 같습니다. DEPS_OS_CHOICES = {
"win32": "win",
"win": "win",
"cygwin": "win",
"darwin": "mac",
"mac": "mac",
"unix": "unix",
"linux": "unix",
"linux2": "unix",
"linux3": "unix",
"android": "android",
}