Home | History | Annotate | Download | only in chromedriver
      1 # Copyright (c) 2012 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 
      5 """Paths to common resources in the Chrome repository."""
      6 
      7 import os
      8 
      9 
     10 _THIS_DIR = os.path.abspath(os.path.dirname(__file__))
     11 
     12 
     13 def GetSrc():
     14   """Returns the path to the root src directory."""
     15   return os.path.abspath(os.path.join(_THIS_DIR, os.pardir, os.pardir,
     16                                       os.pardir))
     17 
     18 
     19 def GetTestData():
     20   """Returns the path to the src/chrome/test/data directory."""
     21   return os.path.join(GetSrc(), 'chrome', 'test', 'data')
     22 
     23 
     24 def GetBuildDir(required_paths):
     25   """Returns the preferred build directory that contains given paths."""
     26   dirs = ['out', 'build', 'xcodebuild', 'sconsbuild']
     27   rel_dirs = [os.path.join(x, 'Release') for x in dirs]
     28   debug_dirs = [os.path.join(x, 'Debug') for x in dirs]
     29   full_dirs = [os.path.join(GetSrc(), x) for x in rel_dirs + debug_dirs]
     30   for build_dir in full_dirs:
     31     for required_path in required_paths:
     32       if not os.path.exists(os.path.join(build_dir, required_path)):
     33         break
     34     else:
     35       return build_dir
     36   raise RuntimeError('Cannot find build directory containing ' +
     37                      ', '.join(required_paths))
     38