Fix generate_licenses Presubmit when working within chromium

When working within chromium, we need to move up two more levels before
we can import the "find_depot_tools" module. Previously this was
managed by a loop that kept moving up until it found a directory named
'src', but this didn't work if the base-level webrtc code was not in
a directory named 'src'.

Bug: webrtc:14411
Change-Id: I2729603d6d2fd8242a1294ae5d95d946db619d0a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273561
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37971}
This commit is contained in:
Alex Cooper
2022-08-31 10:55:37 -07:00
committed by WebRTC LUCI CQ
parent 73e677817a
commit 813177d98f

View File

@ -103,6 +103,13 @@ LIB_REGEX_TO_LICENSES_DICT = {
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
WEBRTC_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir)) WEBRTC_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
SRC_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR)) SRC_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR))
# Chromium, and potentially other repositories, embed us in the location
# "//third_party/webrtc". When this is the case, we expect that some of the
# tools we need are *actually* in their build folder, thus we need to move up
# to the *true* source root, when we're embedded like this.
if SRC_DIR.endswith(os.path.join('third_party', 'webrtc')):
SRC_DIR = os.path.abspath(os.path.join(SRC_DIR, os.pardir, os.pardir))
sys.path.append(os.path.join(SRC_DIR, 'build')) sys.path.append(os.path.join(SRC_DIR, 'build'))
import find_depot_tools import find_depot_tools