-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinstall_iree_host_tools.sh
executable file
·107 lines (78 loc) · 3.69 KB
/
install_iree_host_tools.sh
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
#!/bin/bash
# Copyright 2022 The IREE bare-metal Arm 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
# Bash script to build / install the IREE host tools.
if [[ $# -ne 0 && $# -ne 1 ]] ; then
echo "Usage: $0"
echo " or: $0 -pip"
echo ""
echo "By default, the iree-dist tarball is fetched and unpacked."
echo "In addition, iree-compile can be installed via pip, whereas additional"
echo "tools are installed from source."
exit 1
fi
# Check if pip should be used instead of fetching the iree-dist tarball
if [[ $# -eq 1 && "$1" != "-pip" ]]; then
echo "$0: unrecognized option '${1}'"
exit 1
fi
if [[ "${VIRTUAL_ENV}" != "" ]]; then
echo "$0 cannot be executed in a venv since it creates a new venv."
exit 1;
fi
# Determine which version to install
PATH_TO_SCRIPT="`dirname $0`"
PATH_TO_REPO="`realpath ${PATH_TO_SCRIPT}/../`"
if [[ $# -eq 0 ]] ; then
IREE_VERSION="`sed -n 's/.*dist-\(.*\)-linux-x86_64.tar.xz/\1/p' ${PATH_TO_REPO}/iree-release-link.txt`"
else
IREE_VERSION="`sed -n 4p ${PATH_TO_REPO}/requirements-compiler.txt | sed 's/.*=//'`"
fi
echo "Installing IREE host tools version ${IREE_VERSION}"
# Create the IREE_HOST_BIN_DIR directory
mkdir -p build-iree-host-install-${IREE_VERSION}/bin
ln -sfn build-iree-host-install-${IREE_VERSION} build-iree-host-install
# Create a virtual environment and install required tool
python3 -m venv venv-iree-${IREE_VERSION}
source venv-iree-${IREE_VERSION}/bin/activate
pip3 install -r ${PATH_TO_REPO}/requirements.txt
# Use the iree-dist tarball
if [[ $# -eq 0 ]] ; then
wget -i ${PATH_TO_REPO}/iree-release-link.txt -P build-iree-host-install-${IREE_VERSION}
tar xvfJ build-iree-host-install-${IREE_VERSION}/iree-dist-${IREE_VERSION}-linux-x86_64.tar.xz -C build-iree-host-install-${IREE_VERSION}
rm build-iree-host-install-${IREE_VERSION}/iree-dist-${IREE_VERSION}-linux-x86_64.tar.xz
echo ""
echo -e "Created a virtual environment at '\033[36mvenv-iree-${IREE_VERSION}\033[m'"
echo -e "\033[32mMake sure to active the virtual environment before building the samples\033[m"
echo -e "Downloaded and unpacked IREE dist tarball to '\033[36mbuild-iree-host-install-${IREE_VERSION}\033[m'"
echo -e "Created a symbolic link to '\033[36mbuild-iree-host-install-${IREE_VERSION}\033[m' with the name '\033[36mbuild-iree-host-install\033[m'"
exit 0
fi
# Use pip + install `iree-c-embed-data` and `iree-flatcc-cli` from source
pip3 install -r ${PATH_TO_REPO}/requirements-compiler.txt
mkdir -p build-iree-host-tools-${IREE_VERSION}
ln -sfn build-iree-host-tools-${IREE_VERSION} build-iree-host-tools
cd build-iree-host-tools
cmake -GNinja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DIREE_ERROR_ON_MISSING_SUBMODULES=OFF \
-DIREE_ENABLE_THREADING=OFF \
-DIREE_HAL_DRIVER_DEFAULTS=OFF \
-DIREE_BUILD_COMPILER=OFF \
-DIREE_BUILD_SAMPLES=OFF \
-DIREE_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=../build-iree-host-install \
${PATH_TO_REPO}/third_party/iree/
cmake --build . --target iree-c-embed-data iree-flatcc-cli
cp tools/iree-c-embed-data ../build-iree-host-install/bin
cp tools/iree-flatcc-cli ../build-iree-host-install/bin/
cd ..
echo ""
echo -e "Installed IREE snapshot to '\033[36mvenv-iree-${IREE_VERSION}\033[m'"
echo -e "\033[32mMake sure to active the virtual environment before building the samples\033[m"
echo -e "Copied IREE tools to '\033[36mbuild-iree-host-install-${IREE_VERSION}\033[m'"
echo -e "Created a symbolic link to '\033[36mbuild-iree-host-install-${IREE_VERSION}\033[m' with the name '\033[36mbuild-iree-host-install\033[m'"