blob: 0e66d4cd24e513b987e2f026c3a3ff687ade0133 [file] [log] [blame]
Joe Onorato88ede352023-12-19 02:56:38 +00001# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import os
16import pathlib
17
18DEFAULT_REPORT_DIR = "benchmarks"
19
20def get_root():
21 top_dir = os.environ.get("ANDROID_BUILD_TOP")
Joe Onorato88ede352023-12-19 02:56:38 +000022 d = pathlib.Path.cwd()
Liz Kammer864dd432024-01-24 14:09:11 -050023 # with cog, someone may have a new workspace and new source tree top, but
24 # not run lunch yet, resulting in a misleading ANDROID_BUILD_TOP value
25 if top_dir and d.is_relative_to(top_dir):
26 return pathlib.Path(top_dir).resolve()
Joe Onorato88ede352023-12-19 02:56:38 +000027 while True:
28 if d.joinpath("build", "soong", "soong_ui.bash").exists():
29 return d.resolve().absolute()
30 d = d.parent
31 if d == pathlib.Path("/"):
32 return None
Yu Liucda84242024-01-17 21:30:53 +000033
34def get_dist_dir():
35 dist_dir = os.getenv("DIST_DIR")
36 if dist_dir:
37 return pathlib.Path(dist_dir).resolve()
38 return get_out_dir().joinpath("dist")
39
40def get_out_dir():
41 out_dir = os.getenv("OUT_DIR")
42 if not out_dir:
43 out_dir = "out"
44 return pathlib.Path(out_dir).resolve()