blob: 97097be5987baa5a8229fb3ef6498679e3304a85 [file] [log] [blame]
Joe Onorato31614fd2024-08-02 17:44:28 +00001# Copyright 2024, 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"""Utilities for interacting with buildbot, with a simulation in a local environment"""
16
17import os
18import sys
19
20# Check that the script is running from the root of the tree. Prevents subtle
21# errors later, and CI always runs from the root of the tree.
22if not os.path.exists("build/make/ci/buildbot.py"):
23 raise Exception("CI script must be run from the root of the tree instead of: "
24 + os.getcwd())
25
26# Check that we are using the hermetic interpreter
27if "prebuilts/build-tools/" not in sys.executable:
28 raise Exception("CI script must be run using the hermetic interpreter from "
29 + "prebuilts/build-tools instead of: " + sys.executable)
30
31
32def OutDir():
33 "Get the out directory. Will create it if needed."
34 result = os.environ.get("OUT_DIR", "out")
35 os.makedirs(result, exist_ok=True)
36 return result
37
38def DistDir():
39 "Get the dist directory. Will create it if needed."
40 result = os.environ.get("DIST_DIR", os.path.join(OutDir(), "dist"))
41 os.makedirs(result, exist_ok=True)
42 return result
43