-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·134 lines (118 loc) · 3.25 KB
/
build.sh
File metadata and controls
executable file
·134 lines (118 loc) · 3.25 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# Define directoriesi
CURRENT_DIR=$(pwd)
INSTALL_PATH="${INSTALL_PATH:-$HOME/.passes}"
# Default values
NUM_JOBS=1 # Default number of jobs
BUILD_DOCS=OFF # Default: Do not build documentation
BUILD_TESTS=OFF # Default: Do not build tests
BUILD_TOOLS=OFF # Default: Do not build tests
BUILD_TYPE="Release" # Default: Release mode
# Default directories (can be overridden by arguments)
MLIR_DIR="/opt/llvm/lib/cmake/mlir"
CLANG_DIR="/opt/llvm/lib/cmake/clang"
LLVM_DIR="/opt/llvm/lib/cmake/llvm"
INSTALL_DIR="${INSTALL_PATH:-$HOME/.passes}"
# Parse command-line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-j|--jobs)
NUM_JOBS="$2"
shift 2
;;
--debug)
BUILD_TYPE="Debug"
shift
;;
--mlir-dir)
MLIR_DIR="$2"
shift 2
;;
--install-dir)
INSTALL_DIR="$2"
shift 2
;;
--clang-dir)
CLANG_DIR="$2"
shift 2
;;
--llvm-dir)
LLVM_DIR="$2"
shift 2
;;
--build-tools)
BUILD_TOOLS=ON
shift
;;
--build-docs)
BUILD_DOCS=ON
shift
;;
--build-tests)
BUILD_TESTS=ON
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
BUILD_DIR=${CURRENT_DIR}"/build"
DEPS_DIR="${BUILD_DIR}/_deps"
CUDAQ_DIR="${DEPS_DIR}/cuda-quantum"
CUDAQ_REPO="https://github.com/NVIDIA/cuda-quantum.git"
# Create directories if they don't exist
mkdir -p "${BUILD_DIR}"
mkdir -p "${DEPS_DIR}"
# Clone the CUDA Quantum repository
echo "Cloning CUDA Quantum repository into ${CUDAQ_DIR}..."
if [ ! -d "${CUDAQ_DIR}" ]; then
git clone "${CUDAQ_REPO}" "${CUDAQ_DIR}"
if [ $? -ne 0 ]; then
echo "Failed to clone CUDA Quantum repository."
exit 1
fi
else
echo "CUDA Quantum repository already exists at ${CUDAQ_DIR}. Skipping clone."
fi
# Navigate to the CUDA Quantum directory
cd "${CUDAQ_DIR}" || { echo "Failed to navigate to ${CUDAQ_DIR}."; exit 1; }
# Create a build directory
mkdir -p build && cd build || { echo "Failed to create or navigate to build directory."; exit 1; }
# Configure CUDA Quantum using CMake
echo "Configuring CUDA Quantum with CMake..."
cmake -G Ninja \
-DMLIR_DIR="${MLIR_DIR}" \
-DClang_DIR="${CLANG_DIR}" \
-DLLVM_DIR="${LLVM_DIR}" \
..
if [ $? -ne 0 ]; then
echo "CMake configuration failed."
exit 1
fi
# Build the cudaq-mlir-runtime target using Ninja
echo "Building cudaq-mlir-runtime target with ${NUM_JOBS} jobs..."
ninja -j"${NUM_JOBS}" cudaq-mlir-runtime
if [ $? -ne 0 ]; then
echo "Failed to build cudaq-mlir-runtime target."
exit 1
fi
echo "Build completed successfully!"
echo ${BUILD_DIR}
cd "${BUILD_DIR}" || { echo "Failed to navigate back to the original directory."; exit 1; }
echo "Configuring MQSS Passes Repository CMake..."
cmake .. \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DMLIR_DIR="${MLIR_DIR}" \
-DLLVM_DIR="${LLVM_DIR}" \
-DBUILD_MLIR_PASSES_TOOLS="${BUILD_TOOLS}" \
-DBUILD_MLIR_PASSES_DOCS="${BUILD_DOCS}" \
-DBUILD_MLIR_PASSES_TESTS="${BUILD_TESTS}"\
-DCUDAQ_SOURCE_DIR="${CUDAQ_DIR}" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}"
echo "Building MQSS Repository Passes with ${NUM_JOBS} jobs..."
make -j"${NUM_JOBS}"
echo "Build of MQSS Repository Passes completed successfully!..."