Fix a dead loop in tools_webrtc/libs/generate_licenses.py

Bug: webrtc:13975
Signed-off-by: hanpfei <hanpfei@gmail.com>
Change-Id: I3943f66b1a80e3f1e4b05f4436dbeff23f3d6285
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259280
Reviewed-by: Jeremy Leconte <jleconte@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Christoffer Jansson <jansson@webrtc.org>
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#36596}
diff --git a/AUTHORS b/AUTHORS
index 6c6a0cd..d9ec369 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -120,6 +120,7 @@
 Yura Yaroshevich <yura.yaroshevich@gmail.com>
 Yuriy Pavlyshak <yuriy@appear.in>
 Yusuke Suzuki <utatane.tea@gmail.com>
+Pengfei Han <hanpfei@gmail.com>
 # END individuals section.
 
 # BEGIN organizations section.
diff --git a/tools_webrtc/libs/generate_licenses.py b/tools_webrtc/libs/generate_licenses.py
index 644bea1..d805477 100755
--- a/tools_webrtc/libs/generate_licenses.py
+++ b/tools_webrtc/libs/generate_licenses.py
@@ -100,17 +100,9 @@
 }
 
 
-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
-
-
-SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
+SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
 WEBRTC_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
-SRC_DIR = FindSrcDirPath()
+SRC_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR))
 sys.path.append(os.path.join(SRC_DIR, 'build'))
 import find_depot_tools