• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import contextlib
6import os
7import sys
8
9DIR_SOURCE_ROOT = os.environ.get(
10    'CHECKOUT_SOURCE_ROOT',
11    os.path.abspath(os.path.join(os.path.dirname(__file__),
12                                 os.pardir, os.pardir, os.pardir, os.pardir)))
13
14BUILD_COMMON_PATH = os.path.join(
15    DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common')
16
17# third-party libraries
18ANDROID_PLATFORM_DEVELOPMENT_SCRIPTS_PATH = os.path.join(
19    DIR_SOURCE_ROOT, 'third_party', 'android_platform', 'development',
20    'scripts')
21DEVIL_PATH = os.path.join(
22    DIR_SOURCE_ROOT, 'third_party', 'catapult', 'devil')
23PYMOCK_PATH = os.path.join(
24    DIR_SOURCE_ROOT, 'third_party', 'pymock')
25
26@contextlib.contextmanager
27def SysPath(path, position=None):
28  if position is None:
29    sys.path.append(path)
30  else:
31    sys.path.insert(position, path)
32  try:
33    yield
34  finally:
35    if sys.path[-1] == path:
36      sys.path.pop()
37    else:
38      sys.path.remove(path)
39