Joe Onorato | 88ede35 | 2023-12-19 02:56:38 +0000 | [diff] [blame^] | 1 | # 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 | |
| 15 | import os |
| 16 | import pathlib |
| 17 | |
| 18 | DEFAULT_REPORT_DIR = "benchmarks" |
| 19 | |
| 20 | def 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 |