forked from hw-native-sys/PTOAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_install.sh
More file actions
executable file
·71 lines (61 loc) · 2.63 KB
/
Copy pathquick_install.sh
File metadata and controls
executable file
·71 lines (61 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Copyright (c) 2026 Huawei Technologies Co., Ltd.
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
# CANN Open Software License Agreement Version 2.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# Build and install PTOAS in editable mode against an existing LLVM/MLIR
# build. The persistent build directory can subsequently be used with Ninja,
# for example: ninja -C build check-pto.
#
# Usage: quick_install.sh [-v]
# -v verbose: trace commands and pass -v to every pip invocation.
#
# Optional env:
# LLVM_BUILD_DIR - default: <repo-parent>/llvm-project/build-shared
# PTO_BUILD_DIR - default: <repo>/build
# PYTHON_BIN - default: python
set -euo pipefail
VERBOSE=0
while getopts ":v" opt; do
case "${opt}" in
v) VERBOSE=1 ;;
*) echo "usage: $0 [-v]" >&2; exit 2 ;;
esac
done
PIP_VERBOSE=()
if [[ "${VERBOSE}" -eq 1 ]]; then
set -x
PIP_VERBOSE=(-v)
fi
PTO_SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LLVM_SOURCE_DIR="${LLVM_SOURCE_DIR:-$(cd "${PTO_SOURCE_DIR}/.." && pwd)/llvm-project}"
LLVM_BUILD_DIR="${LLVM_BUILD_DIR:-${LLVM_SOURCE_DIR}/build-shared}"
PTO_BUILD_DIR="${PTO_BUILD_DIR:-${PTO_SOURCE_DIR}/build}"
PYTHON_BIN="${PYTHON_BIN:-python}"
LLVM_DIR="${LLVM_BUILD_DIR}/lib/cmake/llvm"
MLIR_DIR="${LLVM_BUILD_DIR}/lib/cmake/mlir"
if [[ ! -d "${LLVM_DIR}" || ! -d "${MLIR_DIR}" ]]; then
echo "LLVM/MLIR CMake packages not found under: ${LLVM_BUILD_DIR}" >&2
echo "Set LLVM_BUILD_DIR to an existing LLVM build directory." >&2
exit 1
fi
if command -v ccache >/dev/null 2>&1; then
export CMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER:-ccache}"
export CMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER:-ccache}"
fi
"${PYTHON_BIN}" -m pip install \
"${PIP_VERBOSE[@]}" \
'scikit-build-core>=0.12.2,<2' \
'pybind11<3' \
'nanobind>=2.4'
LLVM_BUILD_DIR="${LLVM_BUILD_DIR}" \
"${PYTHON_BIN}" -m pip install --editable "${PTO_SOURCE_DIR}" \
--no-build-isolation "${PIP_VERBOSE[@]}" \
--config-settings="build-dir=${PTO_BUILD_DIR}" \
--config-settings="cmake.define.LLVM_DIR=${LLVM_DIR}" \
--config-settings="cmake.define.MLIR_DIR=${MLIR_DIR}"
echo "PTOAS editable install complete."
echo "Build directory: ${PTO_BUILD_DIR}"