• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2025 Huawei Device Co., Ltd.
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# Utility function to include in each script.
16# Example: source "$(dirname "$0")/common_lib.sh"
17
18# Logging
19COLOR_RST='\033[0m' COLOR_INV="\033[7m"
20COLOR_RED='\033[31m' COLOR_GREEN='\033[32m' COLOR_BLUE='\033[34m' COLOR_GREY='\033[90m'
21log_error() { echo -e "${COLOR_INV}${COLOR_RED}[!]${COLOR_RST} $*" >&2; }
22log_stage() { echo -e "${COLOR_INV}${COLOR_GREEN}[*]${COLOR_RST} $*" >&2; }
23log_action() { echo -e "${COLOR_INV}${COLOR_BLUE}[-]${COLOR_RST} $*" >&2; }
24log_verbose() { echo -e "${COLOR_INV}${COLOR_GREY}[.]${COLOR_RST}${COLOR_GREY} $*${COLOR_RST}" >&2; }
25
26PROJECT_ROOT="$(realpath "$(dirname "$0")"/..)"
27
28init_shell_options() { set -eu -o pipefail; }
29
30chdir_root() { cd "$PROJECT_ROOT"; }
31
32# Shorthand for running the standard uv.
33_uv() { uv --directory="$PROJECT_ROOT/compiler" "$@"; }
34
35init_py_env() {
36    init_shell_options
37    chdir_root
38    cd compiler
39    source .venv/bin/activate
40    set -x
41}
42