blob: 934130dc86c58f7d0154b91dbcb240a15a082a64 [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")
22 if top_dir:
23 return pathlib.Path(top_dir).resolve()
24 d = pathlib.Path.cwd()
25 while True:
26 if d.joinpath("build", "soong", "soong_ui.bash").exists():
27 return d.resolve().absolute()
28 d = d.parent
29 if d == pathlib.Path("/"):
30 return None
Yu Liucda84242024-01-17 21:30:53 +000031
32def get_dist_dir():
33 dist_dir = os.getenv("DIST_DIR")
34 if dist_dir:
35 return pathlib.Path(dist_dir).resolve()
36 return get_out_dir().joinpath("dist")
37
38def get_out_dir():
39 out_dir = os.getenv("OUT_DIR")
40 if not out_dir:
41 out_dir = "out"
42 return pathlib.Path(out_dir).resolve()