From a3b67ae2a7a9a94299255e14600cd1127ad39b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Hajdan=2C=20Jr?= Date: Wed, 30 Aug 2017 15:18:21 +0200 Subject: [PATCH] gclient: predefine host_os MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: 570091 Change-Id: Ib2606fcc7251221ae10a0ef18b6585841d18eef4 Reviewed-on: https://chromium-review.googlesource.com/641750 Commit-Queue: Paweł Hajdan Jr. Reviewed-by: Michael Moss Reviewed-by: Dirk Pranke --- gclient.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gclient.py b/gclient.py index 89fbc27aa..a45d0af48 100755 --- a/gclient.py +++ b/gclient.py @@ -1150,11 +1150,28 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): def get_vars(self): """Returns a dictionary of effective variable values (DEPS file contents with applied custom_vars overrides).""" - result = dict(self._vars) + # Provide some built-in variables. + result = { + 'host_os': repr(_detect_host_os()), + } + # Variables defined in DEPS file override built-in ones. + result.update(self._vars) result.update(self.custom_vars or {}) return result +_PLATFORM_MAPPING = { + 'cygwin': 'win', + 'darwin': 'mac', + 'linux2': 'linux', + 'win32': 'win', +} + + +def _detect_host_os(): + return _PLATFORM_MAPPING[sys.platform] + + class GClient(Dependency): """Object that represent a gclient checkout. A tree of Dependency(), one per solution or DEPS entry.""" @@ -1841,7 +1858,8 @@ class Flattener(object): self._allowed_hosts.update(dep.allowed_hosts) - for key, value in dep.get_vars().iteritems(): + # Only include vars listed in the DEPS files, not possible local overrides. + for key, value in dep._vars.iteritems(): # Make sure there are no conflicting variables. It is fine however # to use same variable name, as long as the value is consistent. assert key not in self._vars or self._vars[key][1] == value