Quellcode durchsuchen

[gclient] Export CONFIG_CTX for other modules to extend.

The recipe engine has a refactor coming up where CONFIG_CTX needs to
be explicitly exported for other modules to extend it. Currently
a handful of modules in the build, build_internal and
release_scripts repos extend the gclient configuration context.

Exporting it like this should have no functional effect, but is just
in preparation for the upcoming refactor.

R=gavinmak

Bug: 1462728
Change-Id: I5871d472f7e28d38eefa9b1e89cfcc804823a1bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4680284
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Robert Iannucci vor 2 Jahren
Ursprung
Commit
d78d8ab771

+ 1 - 1
recipes/README.recipes.md

@@ -161,7 +161,7 @@ Returns (Path): The "depot_tools" root directory.
 &emsp; **@property**<br>&mdash; **def [upload\_to\_google\_storage\_path](/recipes/recipe_modules/depot_tools/api.py#21)(self):**
 &emsp; **@property**<br>&mdash; **def [upload\_to\_google\_storage\_path](/recipes/recipe_modules/depot_tools/api.py#21)(self):**
 ### *recipe_modules* / [gclient](/recipes/recipe_modules/gclient)
 ### *recipe_modules* / [gclient](/recipes/recipe_modules/gclient)
 
 
-[DEPS](/recipes/recipe_modules/gclient/__init__.py#3): [git](#recipe_modules-git), [gitiles](#recipe_modules-gitiles), [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
+[DEPS](/recipes/recipe_modules/gclient/__init__.py#1): [git](#recipe_modules-git), [gitiles](#recipe_modules-gitiles), [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
 
 
 
 
 #### **class [GclientApi](/recipes/recipe_modules/gclient/api.py#77)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
 #### **class [GclientApi](/recipes/recipe_modules/gclient/api.py#77)([RecipeApi][recipe_engine/wkt/RecipeApi]):**

+ 4 - 2
recipes/recipe_modules/gclient/__init__.py

@@ -1,5 +1,3 @@
-PYTHON_VERSION_COMPATIBILITY = 'PY2+3'
-
 DEPS = [
 DEPS = [
   'git',
   'git',
   'gitiles',
   'gitiles',
@@ -13,3 +11,7 @@ DEPS = [
   'recipe_engine/step',
   'recipe_engine/step',
   'tryserver',
   'tryserver',
 ]
 ]
+
+from .config import config_ctx as CONFIG_CTX
+
+__all__ = ['CONFIG_CTX']

+ 13 - 18
recipes/recipe_modules/gclient/config.py

@@ -2,11 +2,6 @@
 # Use of this source code is governed by a BSD-style license that can be
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 # found in the LICENSE file.
 
 
-try:
-  _STRING_TYPE = basestring
-except NameError:  # pragma: no cover
-  _STRING_TYPE = str
-
 from recipe_engine.config import config_item_context, ConfigGroup, BadConf
 from recipe_engine.config import config_item_context, ConfigGroup, BadConf
 from recipe_engine.config import ConfigList, Dict, Single, Static, Set, List
 from recipe_engine.config import ConfigList, Dict, Single, Static, Set, List
 
 
@@ -19,31 +14,31 @@ def BaseConfig(USE_MIRROR=True, CACHE_DIR=None,
   return ConfigGroup(
   return ConfigGroup(
     solutions = ConfigList(
     solutions = ConfigList(
       lambda: ConfigGroup(
       lambda: ConfigGroup(
-        name = Single(_STRING_TYPE),
-        url = Single((_STRING_TYPE, type(None)), empty_val=''),
-        deps_file = Single(_STRING_TYPE, empty_val=deps_file, required=False,
+        name = Single(str),
+        url = Single((str, type(None)), empty_val=''),
+        deps_file = Single(str, empty_val=deps_file, required=False,
                            hidden=False),
                            hidden=False),
         managed = Single(bool, empty_val=True, required=False, hidden=False),
         managed = Single(bool, empty_val=True, required=False, hidden=False),
-        custom_deps = Dict(value_type=(_STRING_TYPE, type(None))),
-        custom_vars = Dict(value_type=(_STRING_TYPE, bool)),
-        safesync_url = Single(_STRING_TYPE, required=False),
+        custom_deps = Dict(value_type=(str, type(None))),
+        custom_vars = Dict(value_type=(str, bool)),
+        safesync_url = Single(str, required=False),
 
 
         revision = Single(
         revision = Single(
-            (_STRING_TYPE, gclient_api.RevisionResolver),
+            (str, gclient_api.RevisionResolver),
             required=False, hidden=True),
             required=False, hidden=True),
       )
       )
     ),
     ),
-    deps_os = Dict(value_type=_STRING_TYPE),
-    hooks = List(_STRING_TYPE),
-    target_os = Set(_STRING_TYPE),
+    deps_os = Dict(value_type=str),
+    hooks = List(str),
+    target_os = Set(str),
     target_os_only = Single(bool, empty_val=False, required=False),
     target_os_only = Single(bool, empty_val=False, required=False),
-    target_cpu = Set(_STRING_TYPE),
+    target_cpu = Set(str),
     target_cpu_only = Single(bool, empty_val=False, required=False),
     target_cpu_only = Single(bool, empty_val=False, required=False),
     cache_dir = Static(cache_dir, hidden=False),
     cache_dir = Static(cache_dir, hidden=False),
 
 
     # If supplied, use this as the source root (instead of the first solution's
     # If supplied, use this as the source root (instead of the first solution's
     # checkout).
     # checkout).
-    src_root = Single(_STRING_TYPE, required=False, hidden=True),
+    src_root = Single(str, required=False, hidden=True),
 
 
     # Maps 'solution' -> build_property
     # Maps 'solution' -> build_property
     # TODO(machenbach): Deprecate this in favor of the one below.
     # TODO(machenbach): Deprecate this in favor of the one below.
@@ -57,7 +52,7 @@ def BaseConfig(USE_MIRROR=True, CACHE_DIR=None,
     # of code here of setting custom vars AND passing in --revision. We hope
     # of code here of setting custom vars AND passing in --revision. We hope
     # to remove custom vars later.
     # to remove custom vars later.
     revisions = Dict(
     revisions = Dict(
-        value_type=(_STRING_TYPE, gclient_api.RevisionResolver),
+        value_type=(str, gclient_api.RevisionResolver),
         hidden=True),
         hidden=True),
 
 
     # TODO(iannucci): HACK! The use of None here to indicate that we apply this
     # TODO(iannucci): HACK! The use of None here to indicate that we apply this