1# Copyright 2022 The ANGLE Project 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 os 6import posixpath 7import sys 8 9ANGLE_ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) 10 11 12def _AddToPathIfNeeded(path): 13 if path not in sys.path: 14 sys.path.insert(0, path) 15 16 17def AddDepsDirToPath(posixpath_from_root): 18 relative_path = os.path.join(*posixpath.split(posixpath_from_root)) 19 full_path = os.path.join(ANGLE_ROOT_DIR, relative_path) 20 if not os.path.exists(full_path): 21 # Assume Chromium checkout 22 chromium_root_dir = os.path.abspath(os.path.join(ANGLE_ROOT_DIR, '..', '..')) 23 full_path = os.path.join(chromium_root_dir, relative_path) 24 assert os.path.exists(full_path) 25 26 _AddToPathIfNeeded(full_path) 27