Google Multi-source management tool Gclient

Source: Internet
Author: User
Tags vars

Google's chromium project is to use Gclient to manage the source of checkout, update and so on. Gclient is a script that Google has written specifically for this multi-source project, and it can manage the code in multiple source management systems together. It even includes putting git and SVN code together.

Gclient Sync,update and other commands are easy to learn and use, no longer say, focus on the next and gclient closely related to the two types of files. Gclient and Deps.

The. gclient file is the control file for Gclient, which is placed at the top of the working directory. The ". Gclient" file is a Python script (Google really has a unique love for Python) and defines a set of "solutions" in a format similar to the following

[Python]View Plaincopy
  1. Solutions = [
  2. { "name": "src",
  3. " url": "Svn://svnserver/component/trunk/src",
  4. "Custom_deps": {
  5. # to use the trunk of a component instead of "s in DEPS:
  6. # "Component": "https://svnserver/component/trunk/",
  7. # to exclude a component from your working copy:
  8. # "Data/really_large_component": None,
  9. }
  10. },
  11. ]

    • Name:checkout the name of the source code
    • URL: Source directory, gclient Hope checkout out of the source code includes a deps file, this file contains the necessary checkout to the working directory of the source information;
    • Deps_file This is a file name (not including a path) that contains a dependent list of files in the project directory, which is optional and the default value is "Deps"
    • Custom_deps This is an optional Dictionary object that overrides the entries defined by the project's "Deps" file. Typically it is used as a local directory, and those code that is not checkout, such as

[Python]View Plaincopy
  1. "Custom_deps": {
  2. "src/content/test/data/layout_tests/layouttests": None,
  3. "Src/chrome/tools/test/reference_build/chrome_win": None,
  4. "Src/chrome_frame/tools/test/reference_build/chrome_win": None,
  5. "Src/chrome/tools/test/reference_build/chrome_linux": None,
  6. "Src/chrome/tools/test/reference_build/chrome_mac": None,
  7. "src/third_party/hunspell_dictionaries": None,
  8. },


or let the local directory checkout a new code from a different location, or checkout different branches, versions, and so on. can also be used to add new items that do not exist in the Deps

    • Target_os: This optional entry can point to a special platform that checkout different code depending on the platform, such as

[Python]View Plaincopy
    1. Target_os = [' Android ']

If the Target_os_only value is true, then just checkout out the corresponding code, such as

[Python]View Plaincopy
    1. Target_os = [ "ios"]
    2. target_os_only = True

In each checkout project, Gclient expects to find a deps file (given by Deps_file), which defines how the different parts of the project are checkout.

"DEPS" is also a Python script, the simplest of which is as follows:

[Python]View Plaincopy
    1. Deps = {
    2. " src/outside": "Http://outside-server/[email protected]",
    3. " src/component": "Svn://svnserver/component/trunk/[email protected]",
    4. " src/relative": "/trunk/[email protected]",
    5. }


Each entry in the Deps contains a key-value pair, the key is the local directory that is checkout, and value is the corresponding remote URL.

If the path starts with a '/', then it is a relative URL relative to the URL address in the. Gclient.

A URL usually contains a version number to lock the source code on a specific version. Of course, this is optional. If not, it gets the latest version on the specified branch.

Deps can also contain other types of data, such as VARs,

[Python]View Plaincopy
  1. VARs = {
  2. ' Pymox ':
  3. ' Http://pymox.googlecode.com/svn ',
  4. ' sfntly ':
  5. ' Http://sfntly.googlecode.com/svn ',
  6. ' Eyes-free ':
  7. ' Http://eyes-free.googlecode.com/svn ',
  8. ' Rlz ':
  9. ' Http://rlz.googlecode.com/svn ',
  10. ' Smhasher ':
  11. ' Http://smhasher.googlecode.com/svn ',
  12. ...
  13. }


VARs defines a set of variables that can be accessed later by using VAR (XXX). Var (XXX) returns a string, so it can also be manipulated, as

[Python]View Plaincopy
    1. ' Src/third_party/cros_dbus_cplusplus/source ':
    2. Var ("git.chromium.org") + '/chromiumos/third_party/[email protected] ',
    3. ' Src/third_party/webkit ':
    4. nbsp Var ("Webkit_trunk") [:-6] + '/branches/chromium/[email protected] ',

The second self-reliance, Var ("Webkit_trunk") [:-6] is a Python expression that represents the last 6 of the string represented by "Webkit_trunk"

Hooks:deps contains optional content Hooks, which also plays an important role in performing a hook operation after sync, update, or Recert.

If you use the--nohooks option (the hook is executed by default), the hook will not be executed after gclient sync or any other operation. You can do it alone by Gclient runhooks, and if you have gclient sync--force, the hook will be executed regardless of whether sync is successful.

Hook in the deps of the wording, generally:

[Python]View Plaincopy
    1. HOOKS = [  
    2.   { 
    3.      "action":   [ "Python",  
    4.    { 
    5.      "name":   "Gyp",   
    6.     
    7. ]  


The hooks contains a set of hooks with several important items for each hook:

    • Pattern is a regular expression that matches a file in the project directory, and once the match is successful, the action item executes
    • The action describes a command line that runs according to a specific parameter. This command runs at most once per gclient, regardless of how many files are matched. This command runs in the same directory as the. gclient. If the first parameter is "Python", then the current Python interpreter will be used. If the string "$matching _files" is included, it expands the string to match the list of files.
    • The name is optional, marking the group to which the hook belongs, which can be used to overwrite and reorganize.

Projects that define different platform dependencies in deps_os:deps, such as

[Python]View Plaincopy
  1. Deps_os = {
  2. "Win": {
  3. "Src/chrome/tools/test/reference_build/chrome_win":
  4. "/trunk/deps/reference_builds/[email protected]",
  5. "Src/third_party/cygwin":
  6. "/trunk/deps/third_party/[email protected]",
  7. .....
  8. },
  9. "ios": {
  10. "Src/third_party/gtm":
  11. (Var ("Googlecode_url")% "Google-toolbox-for-mac") + "/[email protected]" +
  12. Var ("gtm_revision"),
  13. "Src/third_party/nss":
  14. " /trunk/deps/third_party/[email protected]" + Var ("nss_revision"),
  15. ....
  16. },
  17. ...
  18. }

DEPS_OS specifies dependencies on different platforms, which can contain multiple platforms and correspond to Target_os in. Gclient. The corresponding relationship is as follows:

[Python]View Plaincopy
  1. Deps_os_choices = {
  2. " Win32": "Win",
  3. " win": "Win",
  4. " Cygwin": "Win",
  5. " Darwin": "Mac",
  6. "Mac": "Mac",
  7. " Unix": "Unix",
  8. " Linux": "Unix",
  9. " linux2": "Unix",
  10. " linux3": "Unix",
  11. " Android": "Android",
  12. }



Google Multi-source management tool Gclient

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.