Update benchmarks to handle cog workflows

Test: run ./build/make/tools/benchmarks in a cog workspace
Change-Id: I421d1d08b4e90a79b8416486025229d4f3263fbe
This commit is contained in:
Liz Kammer
2024-01-24 14:09:11 -05:00
parent f67a6e8114
commit 864dd43c07
2 changed files with 11 additions and 3 deletions

View File

@@ -19,9 +19,11 @@ DEFAULT_REPORT_DIR = "benchmarks"
def get_root():
top_dir = os.environ.get("ANDROID_BUILD_TOP")
if top_dir:
return pathlib.Path(top_dir).resolve()
d = pathlib.Path.cwd()
# with cog, someone may have a new workspace and new source tree top, but
# not run lunch yet, resulting in a misleading ANDROID_BUILD_TOP value
if top_dir and d.is_relative_to(top_dir):
return pathlib.Path(top_dir).resolve()
while True:
if d.joinpath("build", "soong", "soong_ui.bash").exists():
return d.resolve().absolute()