From c51a5c00c47044e05b32c4266e13743c7554c18a Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Sat, 27 Jul 2024 05:50:54 +0000 Subject: [PATCH] Replace FindSrcDirPath If the webrtc/src repo is checked out in a directory that isn't named "src", FindSrcDirPath will loop forever. Instead of trying to find the repo root, just use the location of the scripts and work out the root with os.pardir. Bug: b/333744051 Change-Id: Ifccdb85d3f9c7cb27ca57cc0b7bb96adf783660d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/357980 Reviewed-by: Mirko Bonadei Commit-Queue: Gavin Mak Cr-Commit-Position: refs/heads/main@{#42701} --- tools_webrtc/autoroller/roll_deps.py | 11 ++--------- tools_webrtc/presubmit_checks_lib/build_helpers.py | 11 ++--------- tools_webrtc/version_updater/update_version.py | 12 +++--------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 4ec9a7a021..1c248ec71e 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -21,14 +21,6 @@ import sys import urllib.request -def FindSrcDirPath(): - """Returns the abs path to the src/ dir of the project.""" - src_dir = os.path.dirname(os.path.abspath(__file__)) - while os.path.basename(src_dir) != 'src': - src_dir = os.path.normpath(os.path.join(src_dir, os.pardir)) - return src_dir - - # Skip these dependencies (list without solution name prefix). DONT_AUTOROLL_THESE = [ 'src/examples/androidtests/third_party/gradle', @@ -66,7 +58,8 @@ CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION = \'([-0-9a-z]+)\'$') ROLL_BRANCH_NAME = 'roll_chromium_revision' SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -CHECKOUT_SRC_DIR = FindSrcDirPath() +CHECKOUT_SRC_DIR = os.path.realpath( + os.path.join(SCRIPT_DIR, os.pardir, os.pardir)) CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(CHECKOUT_SRC_DIR, os.pardir)) # Copied from tools/android/roll/android_deps/.../BuildConfigGenerator.groovy. diff --git a/tools_webrtc/presubmit_checks_lib/build_helpers.py b/tools_webrtc/presubmit_checks_lib/build_helpers.py index 849fc771ae..9f08d26aae 100644 --- a/tools_webrtc/presubmit_checks_lib/build_helpers.py +++ b/tools_webrtc/presubmit_checks_lib/build_helpers.py @@ -19,15 +19,8 @@ import sys import tempfile -def find_src_dir_path(): - """Returns the abs path to the src/ dir of the project.""" - src_dir = os.path.dirname(os.path.abspath(__file__)) - while os.path.basename(src_dir) != 'src': - src_dir = os.path.normpath(os.path.join(src_dir, os.pardir)) - return src_dir - - -SRC_DIR = find_src_dir_path() +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +SRC_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir)) sys.path.append(os.path.join(SRC_DIR, 'build')) import find_depot_tools diff --git a/tools_webrtc/version_updater/update_version.py b/tools_webrtc/version_updater/update_version.py index bc1bc9d364..786da2103f 100644 --- a/tools_webrtc/version_updater/update_version.py +++ b/tools_webrtc/version_updater/update_version.py @@ -19,16 +19,10 @@ import subprocess import sys -def find_src_dir_path(): - """Returns the abs path to the src/ dir of the project.""" - src_dir = os.path.dirname(os.path.abspath(__file__)) - while os.path.basename(src_dir) != 'src': - src_dir = os.path.normpath(os.path.join(src_dir, os.pardir)) - return src_dir - - UPDATE_BRANCH_NAME = 'webrtc_version_update' -CHECKOUT_SRC_DIR = find_src_dir_path() +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +CHECKOUT_SRC_DIR = os.path.realpath( + os.path.join(SCRIPT_DIR, os.pardir, os.pardir)) NOTIFY_EMAIL = 'webrtc-trooper@webrtc.org'