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 pathlib 7import posixpath 8import sys 9 10ANGLE_ROOT_DIR = str(pathlib.Path(__file__).resolve().parents[3]) 11 12 13def AddDepsDirToPath(posixpath_from_root): 14 relative_path = os.path.join(*posixpath.split(posixpath_from_root)) 15 full_path = os.path.join(ANGLE_ROOT_DIR, relative_path) 16 if not os.path.exists(full_path): 17 # Assume Chromium checkout 18 chromium_root_dir = os.path.abspath(os.path.join(ANGLE_ROOT_DIR, '..', '..')) 19 full_path = os.path.join(chromium_root_dir, relative_path) 20 assert os.path.exists(full_path) 21 22 if full_path not in sys.path: 23 sys.path.insert(0, full_path) 24