Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: mojo/devtools/common/devtoolslib/paths.py

Issue 1268403002: Automatically discover the mojoconfig file. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/devtools/common/devtoolslib/paths.py
diff --git a/mojo/devtools/common/devtoolslib/paths.py b/mojo/devtools/common/devtoolslib/paths.py
index 1b0bff4720377f99d12cccff02a14a385d13f090..502636a06d7681b0ddc2c59110e80474178da6ad 100644
--- a/mojo/devtools/common/devtoolslib/paths.py
+++ b/mojo/devtools/common/devtoolslib/paths.py
@@ -13,9 +13,9 @@ import os.path
import sys
-def find_ancestor_with(relpath):
+def find_ancestor_with(relpath, start_path=None):
"""Returns the lowest ancestor of this file that contains |relpath|."""
- cur_dir_path = os.path.abspath(os.path.dirname(__file__))
+ cur_dir_path = start_path or os.path.abspath(os.path.dirname(__file__))
while True:
if os.path.exists(os.path.join(cur_dir_path, relpath)):
return cur_dir_path
@@ -27,6 +27,16 @@ def find_ancestor_with(relpath):
return None
+def find_within_ancestors(target_relpath, start_path=None):
+ """Returns the absolute path to |target_relpath| in the lowest ancestor of
+ |start_path| that contains it.
+ """
+ ancestor = find_ancestor_with(target_relpath, start_path)
+ if not ancestor:
+ return None
+ return os.path.join(ancestor, target_relpath)
+
+
def infer_paths(is_android, is_debug, target_cpu):
"""Infers the locations of select build output artifacts in a regular
Chromium-like checkout. This should grow thinner or disappear as we introduce
« no previous file with comments | « no previous file | mojo/devtools/common/devtoolslib/shell_arguments.py » ('j') | mojo/devtools/common/devtoolslib/shell_config.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698