Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: build/android/devil/devil_env.py

Issue 1502033002: Revert of [Android] Add a configurable environment for devil/. (RELAND 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/devil/devil_dependencies.json ('k') | build/android/devil/utils/lazy/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/devil/devil_env.py
diff --git a/build/android/devil/devil_env.py b/build/android/devil/devil_env.py
deleted file mode 100644
index fa7392f4f44a355909cb2109a8f8da5342a40d3f..0000000000000000000000000000000000000000
--- a/build/android/devil/devil_env.py
+++ /dev/null
@@ -1,138 +0,0 @@
-# Copyright 2015 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import contextlib
-import json
-import logging
-import os
-import sys
-import tempfile
-import threading
-
-# TODO(jbudorick): Update this once dependency_manager moves to catapult.
-CATAPULT_BASE_PATH = os.path.abspath(os.path.join(
- os.path.dirname(__file__), os.pardir, os.pardir, os.pardir,
- 'tools', 'telemetry'))
-
-@contextlib.contextmanager
-def SysPath(path):
- sys.path.append(path)
- yield
- if sys.path[-1] != path:
- logging.debug('Expected %s at the end of sys.path. Full sys.path: %s',
- path, str(sys.path))
- sys.path.remove(path)
- else:
- sys.path.pop()
-
-with SysPath(CATAPULT_BASE_PATH):
- from catapult_base import dependency_manager # pylint: disable=import-error
-
-_ANDROID_BUILD_TOOLS = {'aapt', 'dexdump', 'split-select'}
-
-_DEVIL_DEFAULT_CONFIG = os.path.abspath(os.path.join(
- os.path.dirname(__file__), 'devil_dependencies.json'))
-
-_LEGACY_ENVIRONMENT_VARIABLES = {
- 'ADB_PATH': {
- 'dependency_name': 'adb',
- 'platform': 'android_host',
- },
- 'ANDROID_SDK_ROOT': {
- 'dependency_name': 'android_sdk',
- 'platform': 'android_host',
- },
-}
-
-
-def _GetEnvironmentVariableConfig():
- env_var_config = {}
- for k, v in _LEGACY_ENVIRONMENT_VARIABLES.iteritems():
- path = os.environ.get(k)
- if path:
- env_var_config[v['dependency_name']] = {
- 'file_info': {
- v['platform']: {
- 'local_paths': [path]
- }
- }
- }
- return env_var_config
-
-
-class _Environment(object):
-
- def __init__(self):
- self._dm_init_lock = threading.Lock()
- self._dm = None
-
- def Initialize(self, configs=None, config_files=None):
- """Initialize devil's environment from configuration files.
-
- This uses all configurations provided via |configs| and |config_files|
- to determine the locations of devil's dependencies. Configurations should
- all take the form described by catapult_base.dependency_manager.BaseConfig.
- If no configurations are provided, a default one will be used if available.
-
- Args:
- configs: An optional list of dict configurations.
- config_files: An optional list of files to load
- """
-
- # Make sure we only initialize self._dm once.
- with self._dm_init_lock:
- if self._dm is None:
- if configs is None:
- configs = []
-
- env_config = _GetEnvironmentVariableConfig()
- if env_config:
- configs.insert(0, env_config)
- self._InitializeRecursive(
- configs=configs,
- config_files=config_files)
- assert self._dm is not None, 'Failed to create dependency manager.'
-
- def _InitializeRecursive(self, configs=None, config_files=None):
- # This recurses through configs to create temporary files for each and
- # take advantage of context managers to appropriately close those files.
- # TODO(jbudorick): Remove this recursion if/when dependency_manager
- # supports loading configurations directly from a dict.
- if configs:
- with tempfile.NamedTemporaryFile() as next_config_file:
- next_config_file.write(json.dumps(configs[0]))
- next_config_file.flush()
- self._InitializeRecursive(
- configs=configs[1:],
- config_files=[next_config_file.name] + (config_files or []))
- else:
- config_files = config_files or []
- if 'DEVIL_ENV_CONFIG' in os.environ:
- config_files.append(os.environ.get('DEVIL_ENV_CONFIG'))
- config_files.append(_DEVIL_DEFAULT_CONFIG)
-
- self._dm = dependency_manager.DependencyManager(
- [dependency_manager.BaseConfig(c) for c in config_files])
-
- def FetchPath(self, dependency, arch=None, device=None):
- if self._dm is None:
- self.Initialize()
- if dependency in _ANDROID_BUILD_TOOLS:
- self.FetchPath('android_build_tools_libc++', arch=arch, device=device)
- return self._dm.FetchPath(dependency, _GetPlatform(arch, device))
-
- def LocalPath(self, dependency, arch=None, device=None):
- if self._dm is None:
- self.Initialize()
- return self._dm.LocalPath(dependency, _GetPlatform(arch, device))
-
-
-def _GetPlatform(arch, device):
- if not arch:
- arch = device.product_cpu_abi if device else 'host'
- return 'android_%s' % arch
-
-
-config = _Environment()
-
« no previous file with comments | « build/android/devil/devil_dependencies.json ('k') | build/android/devil/utils/lazy/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698