blob: c316ab218d68c668ff70d83987d814a0989de80c [file] [log] [blame]
#!/bin/bash
# Copyright 2019 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Build "all" of the IREE project.
#
# Designed for CI, but can be run locally. The desired build directory can be
# passed as the first argument. Otherwise, it uses the environment variable
# IREE_BUILD_DIR, defaulting to "build". It reuses the build directory if it
# already exists. Expects to be run from the root of the IREE repository.
set -xeuo pipefail
BUILD_DIR="${1:-${IREE_BUILD_DIR:-build}}"
INSTALL_DIR="${IREE_INSTALL_DIR:-${BUILD_DIR}/install}"
IREE_ENABLE_ASSERTIONS="${IREE_ENABLE_ASSERTIONS:-ON}"
IREE_PYTHON3_EXECUTABLE="${IREE_PYTHON3_EXECUTABLE:-$(which python3)}"
# Enable WebGPU compiler builds and tests by default. All deps get fetched as
# needed, but some of the deps are too large to enable by default for all
# developers.
IREE_TARGET_BACKEND_WEBGPU="${IREE_TARGET_BACKEND_WEBGPU:-ON}"
source build_tools/cmake/setup_build.sh
source build_tools/cmake/setup_ccache.sh
declare -a CMAKE_ARGS=(
"-G" "Ninja"
"-B" "${BUILD_DIR}"
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
"-DCMAKE_INSTALL_PREFIX=$(realpath ${INSTALL_DIR})"
"-DIREE_ENABLE_ASSERTIONS=${IREE_ENABLE_ASSERTIONS}"
# Use `lld` for faster linking.
"-DIREE_ENABLE_LLD=ON"
# Enable docs build on the CI. The additional builds are pretty fast and
# give us early warnings for some types of website publication errors.
"-DIREE_BUILD_DOCS=ON"
# Enable building the python bindings on CI.
"-DIREE_BUILD_PYTHON_BINDINGS=ON"
"-DPython3_EXECUTABLE=${IREE_PYTHON3_EXECUTABLE}"
# Enable CUDA compiler and runtime builds unconditionally. Our CI images all
# have enough deps to at least build CUDA support and compile CUDA binaries
# (but not necessarily test on real hardware).
"-DIREE_HAL_DRIVER_CUDA=ON"
"-DIREE_TARGET_BACKEND_CUDA=ON"
"-DIREE_TARGET_BACKEND_WEBGPU=${IREE_TARGET_BACKEND_WEBGPU}"
)
"$CMAKE_BIN" "${CMAKE_ARGS[@]}"
echo "Building all"
echo "------------"
"$CMAKE_BIN" --build "${BUILD_DIR}" -- -k 0
echo "Building 'install'"
echo "------------------"
"${CMAKE_BIN}" --build "${BUILD_DIR}" --target install -- -k 0
echo "Building test deps"
echo "------------------"
"$CMAKE_BIN" --build "${BUILD_DIR}" --target iree-test-deps -- -k 0
echo "Building sample deps"
echo "------------------"
"$CMAKE_BIN" --build "${BUILD_DIR}" --target iree-sample-deps -- -k 0
if (( IREE_READ_REMOTE_CCACHE == 1 )); then
ccache --show-stats
fi