Download chips/openroad_flow_scripts/etc/DependencyInstaller.sh from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 20.1 kB
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/openroad_flow_scripts/etc/DependencyInstaller.sh
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData/chips/openroad_flow_scripts/etc/DependencyInstaller.sh
-
curl -L -o DependencyInstaller.sh https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/openroad_flow_scripts/etc/DependencyInstaller.sh
20.1 kB
| set -euo pipefail | |
| # Capture the script's absolute directory before any cd | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| _script_dir="$(dirname $(perl -e 'use Cwd "abs_path";print abs_path(shift)' $0))" | |
| else | |
| _script_dir="$(dirname $(readlink -f $0))" | |
| fi | |
| # Make sure we are on the correct folder before beginning | |
| cd "${_script_dir}/../" | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| numThreads=$(sysctl -n hw.logicalcpu) | |
| else | |
| numThreads=$(nproc) | |
| fi | |
| _versionCompare() { | |
| local a b IFS=. ; set -f | |
| printf -v a %08d $1; printf -v b %08d $3 | |
| test $a "$2" $b | |
| } | |
| # Yosys is built with CMake and needs CMake >= 3.28, | |
| # newer than Ubuntu 22.04 ships, so fetch a release from Kitware when the | |
| # one on PATH is too old. | |
| cmakeMinVersion=3.28 | |
| cmakeVersion=3.31.9 | |
| cmakeChecksumX86_64=64797150473dabe9de95459cb1ce0715 | |
| cmakeChecksumAarch64=8d426361ce8c54494c0a041a0e3bcc5c | |
| # True if version $1 >= version $2. Unlike _versionCompare, this handles | |
| # versions with a different number of components (3.22.1 vs 3.28). | |
| _versionAtLeast() { | |
| [[ "$(printf '%s\n%s\n' "$2" "$1" | sort -V | head -n1)" == "$2" ]] | |
| } | |
| # Prints the version of tool $2, looking in prefix $1 first, or 0 if absent. | |
| _toolVersion() { | |
| local bin | |
| bin=$(PATH="$1/bin:${PATH}" command -v "$2" || true) | |
| if [[ -z "${bin}" ]]; then | |
| echo 0 | |
| return | |
| fi | |
| "${bin}" --version | head -n1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1 | |
| } | |
| _installCmake() { | |
| local prefix=${PREFIX:-"/usr/local"} | |
| local current | |
| current=$(_toolVersion "${prefix}" cmake) | |
| if _versionAtLeast "${current}" "${cmakeMinVersion}"; then | |
| echo "CMake ${current} found, skipping install" | |
| return | |
| fi | |
| local arch checksum installer workDir | |
| arch=$(uname -m) | |
| if [[ "${arch}" == "aarch64" ]]; then | |
| checksum=${cmakeChecksumAarch64} | |
| else | |
| checksum=${cmakeChecksumX86_64} | |
| fi | |
| installer="cmake-${cmakeVersion}-linux-${arch}.sh" | |
| workDir=$(mktemp -d) | |
| ( | |
| cd "${workDir}" | |
| wget -q "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/${installer}" | |
| md5sum -c <(echo "${checksum} ${installer}") | |
| mkdir -p "${prefix}" | |
| sh "${installer}" --skip-license --prefix="${prefix}" | |
| ) | |
| rm -rf "${workDir}" | |
| } | |
| # Yosys needs Bison >= 3.6, newer than EL8 ships, so build the release that | |
| # the OpenROAD installer uses when the one on PATH is too old. | |
| bisonMinVersion=3.6 | |
| bisonVersion=3.8.2 | |
| bisonChecksum=1e541a097cda9eca675d29dd2832921f | |
| _installBison() { | |
| local prefix=${PREFIX:-"/usr/local"} | |
| local current | |
| current=$(_toolVersion "${prefix}" bison) | |
| if _versionAtLeast "${current}" "${bisonMinVersion}"; then | |
| echo "Bison ${current} found, skipping install" | |
| return | |
| fi | |
| local tarball="bison-${bisonVersion}.tar.gz" | |
| local workDir | |
| workDir=$(mktemp -d) | |
| ( | |
| cd "${workDir}" | |
| wget -q "https://ftp.gnu.org/gnu/bison/${tarball}" | |
| md5sum -c <(echo "${bisonChecksum} ${tarball}") | |
| tar xzf "${tarball}" | |
| cd "bison-${bisonVersion}" | |
| ./configure --prefix="${prefix}" | |
| make -j "${numThreads}" | |
| make install | |
| ) | |
| rm -rf "${workDir}" | |
| } | |
| _installORDependencies() { | |
| if [[ ${YOSYS_VER} == "" ]]; then | |
| YOSYS_VER=v$(grep 'yosys_ver =' tools/yosys/docs/source/conf.py | awk -F'"' '{print $2}') | |
| fi | |
| ./tools/OpenROAD/etc/DependencyInstaller.sh ${OR_INSTALLER_ARGS} -yosys-ver="${YOSYS_VER}" | |
| } | |
| _installPipCommon() { | |
| local lockfile piplock | |
| lockfile="${_script_dir}/requirements-common_lock.txt" | |
| piplock="${_script_dir}/requirements-pip_lock.txt" | |
| if [[ -n "${VIRTUAL_ENV:-}" ]]; then | |
| # The lock goes into the virtual environment, created if it does | |
| # not exist yet; the Docker images name one with ENV VIRTUAL_ENV. | |
| if [[ ! -x "${VIRTUAL_ENV}/bin/python3" ]]; then | |
| python3 -m venv "${VIRTUAL_ENV}" | |
| fi | |
| "${VIRTUAL_ENV}/bin/python3" -m pip install --no-cache-dir --upgrade --require-hashes -r "$piplock" | |
| "${VIRTUAL_ENV}/bin/python3" -m pip install --no-cache-dir -r "$lockfile" | |
| elif [[ "$OSTYPE" == "darwin"* ]]; then | |
| if [[ "$EUID" -eq 0 ]]; then | |
| echo "Error: Do NOT run with sudo." | |
| exit 1 | |
| fi | |
| echo "Error: Activate a virtual environment on macOS." | |
| exit 1 | |
| else | |
| # pip before 23.3 fails --require-hashes on requirements-common_lock.txt: | |
| # it does not match an extras-bearing pin such as | |
| # googleapis-common-protos[grpc]==X against a plain request for the same | |
| # package. Raise pip first, from its own hashed lock. | |
| if [[ $(id -u) == 0 ]]; then | |
| python3 -m pip install --no-cache-dir --upgrade --require-hashes -r "$piplock" | |
| python3 -m pip install --no-cache-dir -r "$lockfile" | |
| else | |
| python3 -m pip install --no-cache-dir --user --upgrade --require-hashes -r "$piplock" | |
| python3 -m pip install --no-cache-dir --user -r "$lockfile" | |
| fi | |
| fi | |
| } | |
| _installPipSystem() { | |
| apt-get -y install python3-pandas python3-numpy python3-click python3-yaml python3-yamlfix | |
| } | |
| # Enterprise Linux 8/9 cleanup | |
| _install_EL8_EL9_CleanUp() { | |
| dnf clean -y all | |
| } | |
| # Enterprise Linux 8/9 package installation (EL8/EL9 = RHEL, Rocky Linux, or AlmaLinux) | |
| _install_EL8_EL9_Packages() { | |
| # Re-detect EL version | |
| if [[ -f /etc/os-release ]]; then | |
| elVersion=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g' | cut -d. -f1) | |
| else | |
| echo "ERROR: Could not detect Enterprise Linux version" | |
| exit 1 | |
| fi | |
| # EL8 and EL9 use `dnf`, instead of `yum` | |
| dnf -y update | |
| # EPEL has tcl-tclreadline. | |
| dnf -y install "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${elVersion}.noarch.rpm" | |
| # The rest builds Yosys. | |
| dnf -y install \ | |
| bison \ | |
| boost-devel \ | |
| findutils \ | |
| flex \ | |
| gcc \ | |
| gcc-c++ \ | |
| git \ | |
| libffi-devel \ | |
| make \ | |
| pkgconf-pkg-config \ | |
| python3 \ | |
| python3-devel \ | |
| python3-pip \ | |
| readline \ | |
| ruby \ | |
| ruby-devel \ | |
| tcl-devel \ | |
| tcllib \ | |
| time \ | |
| wget \ | |
| zlib-devel | |
| # The pip lock files need Python 3.10 or newer, which | |
| # is newer than the EL8 and EL9 defaults. | |
| dnf -y install python3.12 python3.12-devel python3.12-pip | |
| update-alternatives --install /usr/bin/python3 python3 "$(command -v python3.12)" 50 | |
| # EL8 registers its Python 3.6 with a higher priority, so select 3.12. | |
| update-alternatives --set python3 "$(command -v python3.12)" | |
| if [[ "${elVersion}" == "8" ]]; then | |
| dnf -y install \ | |
| readline-devel \ | |
| tcl-tclreadline \ | |
| tcl-tclreadline-devel | |
| # The default GCC 8 is too old for Yosys, which needs C++20. | |
| dnf -y install gcc-toolset-13 | |
| fi | |
| if [[ "${elVersion}" == "9" ]]; then | |
| dnf -y install \ | |
| https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/readline-devel-8.1-4.el9.x86_64.rpm | |
| fi | |
| } | |
| _installUbuntuCleanUp() { | |
| apt-get autoclean -y | |
| apt-get autoremove -y | |
| } | |
| _installUbuntuPackages() { | |
| export DEBIAN_FRONTEND="noninteractive" | |
| apt-get -y update | |
| apt-get -y install --no-install-recommends \ | |
| bison \ | |
| build-essential \ | |
| ca-certificates \ | |
| curl \ | |
| flex \ | |
| git \ | |
| help2man \ | |
| libboost-iostreams-dev \ | |
| libffi-dev \ | |
| libfl-dev \ | |
| libfl2 \ | |
| libgit2-dev \ | |
| libgmock-dev \ | |
| libgoogle-perftools-dev \ | |
| libgtest-dev \ | |
| libqt5multimediawidgets5 \ | |
| libqt5opengl5 \ | |
| libqt5svg5-dev \ | |
| libqt5xmlpatterns5-dev \ | |
| libreadline-dev \ | |
| libz-dev \ | |
| perl \ | |
| pkg-config \ | |
| python3-dev \ | |
| python3-pip \ | |
| python3-venv \ | |
| qtmultimedia5-dev \ | |
| qttools5-dev \ | |
| ruby \ | |
| ruby-dev \ | |
| tcl-dev \ | |
| tcl-tclreadline \ | |
| tcllib \ | |
| time \ | |
| unzip \ | |
| wget \ | |
| zlib1g \ | |
| zlib1g-dev | |
| packages=() | |
| # Choose libstdc++ version | |
| if _versionCompare $1 -ge 25.04; then | |
| packages+=("libstdc++-15-dev") | |
| elif _versionCompare $1 -ge 24.04; then | |
| packages+=("libstdc++-14-dev") | |
| elif _versionCompare $1 -ge 22.10; then | |
| packages+=("libstdc++-12-dev") | |
| fi | |
| apt-get install -y --no-install-recommends ${packages[@]} | |
| if [[ $1 == "rodete" ]]; then | |
| apt-get -y install --no-install-recommends python3-pandas | |
| fi | |
| if command -v docker &> /dev/null; then | |
| # The user can uninstall docker if they want to reinstall it, | |
| # and also this allows the user to choose drop in replacements | |
| # for docker, such as podman-docker | |
| echo "Docker is already installed, skip docker reinstall." | |
| return 0 | |
| fi | |
| # Add Docker's official GPG key: | |
| install -m 0755 -d /etc/apt/keyrings | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ | |
| -o /etc/apt/keyrings/docker.asc | |
| chmod a+r /etc/apt/keyrings/docker.asc | |
| # Add the repository to Apt sources: | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
| $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | |
| tee /etc/apt/sources.list.d/docker.list > /dev/null | |
| apt-get -y update | |
| if [[ $1 != "rodete" ]]; then | |
| apt-get -y install --no-install-recommends \ | |
| docker-ce \ | |
| docker-ce-cli \ | |
| containerd.io \ | |
| docker-buildx-plugin \ | |
| docker-compose-plugin | |
| fi | |
| } | |
| _installDarwinPackages() { | |
| brew install libffi tcl-tk ruby | |
| brew install python libomp doxygen bison flex boost spdlog zlib cmake | |
| brew link --force libomp | |
| brew install docker docker-buildx | |
| } | |
| _installCI() { | |
| apt-get -y update | |
| apt-get -y install --no-install-recommends \ | |
| apt-transport-https \ | |
| ca-certificates \ | |
| coreutils \ | |
| curl \ | |
| gnupg \ | |
| jq \ | |
| lsb-release \ | |
| parallel \ | |
| python3 \ | |
| software-properties-common \ | |
| zip | |
| } | |
| _help() { | |
| cat <<EOF | |
| All arguments and flags are only applicable for OpenROAD dependencies | |
| Usage: $0 [-all|-base|-common] [-<ARGS>] | |
| # Installs all of OpenROAD's dependencies no | |
| # need to run -base or -common. Requires | |
| # privileged access. | |
| # | |
| $0 -base | |
| # Installs OpenROAD's dependencies using | |
| # package managers, including Bazel | |
| # (bazelisk). -common must be executed | |
| # in another command. | |
| $0 -common | |
| # Installs OpenROAD's common dependencies | |
| # (-base must be executed in another | |
| # command). | |
| $0 -bazel | |
| # Default. Installs the dependencies to | |
| # build OpenROAD with Bazel. | |
| $0 -cmake | |
| # Installs the dependencies to build | |
| # OpenROAD with CMake instead of Bazel, | |
| # e.g. for build_openroad.sh | |
| # --openroad-args -cmake-build. | |
| $0 -prefix=DIR | |
| # Installs common dependencies in an existing | |
| # user-specified directory. Only used | |
| # with -common. This flag cannot be used | |
| # with sudo or with root access. | |
| $0 -local | |
| # Installs common dependencies in | |
| # "$HOME/.local". Only used with | |
| # -common. This flag cannot be used with | |
| # sudo or with root access. | |
| $0 -ci | |
| # Installs CI tools | |
| $0 -yosys-ver=VERSION | |
| # Installs specified version of Yosys. | |
| # By default, the Yosys version is | |
| # obtained from tools/yosys/docs/source/conf.py | |
| $0 -constant-build-dir | |
| # Use constant build directory, instead of | |
| # random one. | |
| EOF | |
| exit "${1:-1}" | |
| } | |
| # default args | |
| OR_INSTALLER_ARGS="" | |
| YOSYS_VER="" | |
| # default prefix | |
| PREFIX="" | |
| # default option | |
| option="none" | |
| # default isLocal | |
| isLocal="false" | |
| constantBuildDir="false" | |
| CI="no" | |
| # OpenROAD build system to install dependencies for: bazel or cmake | |
| buildSystem="bazel" | |
| # default values, can be overwritten by cmdline args | |
| while [ "$#" -gt 0 ]; do | |
| case "${1}" in | |
| -h|-help) | |
| _help 0 | |
| ;; | |
| -all) | |
| if [[ "${option}" != "none" ]]; then | |
| echo "WARNING: previous argument -${option} will be overwritten with -all." >&2 | |
| fi | |
| option="all" | |
| ;; | |
| -base) | |
| if [[ "${option}" != "none" ]]; then | |
| echo "WARNING: previous argument -${option} will be overwritten with -base." >&2 | |
| fi | |
| option="base" | |
| ;; | |
| -common) | |
| if [[ "${option}" != "none" ]]; then | |
| echo "WARNING: previous argument -${option} will be overwritten with -common." >&2 | |
| fi | |
| option="common" | |
| ;; | |
| -bazel) | |
| buildSystem="bazel" | |
| ;; | |
| -cmake) | |
| buildSystem="cmake" | |
| ;; | |
| -local) | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -local" | |
| PREFIX="${HOME}/.local" | |
| ;; | |
| -ci) | |
| CI="yes" | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -save-deps-prefixes=/etc/openroad_deps_prefixes.txt" | |
| ;; | |
| -save-deps-prefixes=*) | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1" | |
| ;; | |
| -yosys-ver=*) | |
| YOSYS_VER=${1#*=} | |
| ;; | |
| -prefix=*) | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1" | |
| PREFIX=${1#*=} | |
| ;; | |
| -constant-build-dir) | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1" | |
| constantBuildDir="true" | |
| ;; | |
| -threads=*) | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1" | |
| numThreads=${1#*=} | |
| ;; | |
| *) | |
| echo "unknown option: ${1}" >&2 | |
| _help | |
| ;; | |
| esac | |
| shift 1 | |
| done | |
| if [[ "${option}" == "none" ]]; then | |
| echo "You must use one of: -all|-base|-common" >&2 | |
| _help | |
| fi | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -${option}" | |
| # build_openroad.sh builds OpenROAD with Bazel by default. The Bazel runtime | |
| # libraries need root, and -common may run unprivileged, so they ride along | |
| # with -base only; -common installs bazelisk. -cmake asks for the OpenROAD | |
| # CMake dependencies instead. | |
| if [[ "${buildSystem}" == "cmake" ]]; then | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -cmake" | |
| elif [[ "${option}" == "base" || "${option}" == "all" ]]; then | |
| OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -bazel" | |
| fi | |
| platform="$(uname -s)" | |
| case "${platform}" in | |
| "Linux" ) | |
| if [[ -f /etc/os-release ]]; then | |
| os=$(awk -F= '/^NAME/{print $2}' /etc/os-release | sed 's/"//g') | |
| else | |
| os="Unidentified OS, could not find /etc/os-release." | |
| fi | |
| ;; | |
| "Darwin" ) | |
| if [[ $(id -u) == 0 ]]; then>&2 | |
| echo "ERROR: cannot install on macOS if you are root or using sudo (not recommended for brew)." >&2 | |
| exit 1 | |
| fi | |
| os="Darwin" | |
| ;; | |
| *) | |
| echo "${platform} is not supported" >&2 | |
| _help | |
| ;; | |
| esac | |
| case "${os}" in | |
| "Red Hat Enterprise Linux"* | "AlmaLinux" | "Rocky Linux") | |
| # Enterprise Linux support - dispatch based on specific version | |
| if [[ ${CI} == "yes" ]]; then | |
| echo "WARNING: Installing CI dependencies is only supported on Ubuntu 24.04 and 26.04" >&2 | |
| fi | |
| # Detect EL version to choose appropriate functions | |
| if [[ -f /etc/os-release ]]; then | |
| elVersion=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g' | cut -d. -f1) | |
| else | |
| echo "ERROR: Could not detect Enterprise Linux version" >&2 | |
| exit 1 | |
| fi | |
| # Only EL8 and EL9 are supported; other versions stop before any install. | |
| case "${elVersion}" in | |
| "8"|"9") | |
| # EL8/EL9 = RHEL, Rocky Linux, or AlmaLinux | |
| # First install OpenROAD base | |
| _installORDependencies | |
| if [[ "${option}" == "base" || "${option}" == "all" ]]; then | |
| _install_EL8_EL9_Packages | |
| _install_EL8_EL9_CleanUp | |
| fi | |
| ;; | |
| *) | |
| echo "ERROR: Unsupported Enterprise Linux version: ${elVersion}" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| if [[ "${option}" == "common" || "${option}" == "all" ]]; then | |
| _installCmake | |
| _installBison | |
| _installPipCommon | |
| fi | |
| ;; | |
| "Ubuntu" | "Debian GNU/Linux rodete" ) | |
| version=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g') | |
| if [[ -z ${version} ]]; then | |
| version=$(awk -F= '/^VERSION_CODENAME/{print $2}' /etc/os-release | sed 's/"//g') | |
| fi | |
| if [[ ${CI} == "yes" ]]; then | |
| echo "Installing CI Tools" | |
| _installCI | |
| fi | |
| _installORDependencies | |
| if [[ "${option}" == "base" || "${option}" == "all" ]]; then | |
| _installUbuntuPackages "${version}" | |
| _installUbuntuCleanUp | |
| fi | |
| if [[ "${option}" == "common" || "${option}" == "all" ]]; then | |
| _installCmake | |
| fi | |
| if [[ $version != "rodete" ]] && _versionCompare ${version} -lt 23.04 ; then | |
| if [[ "${option}" == "common" || "${option}" == "all" ]]; then | |
| _installPipCommon | |
| fi | |
| else | |
| # The system Python is externally managed (PEP 668): its | |
| # packages come from apt, in -base with the other system | |
| # packages. The lock, which also has packages apt does not | |
| # carry, among them the klayout module the flow writes GDS | |
| # with, goes into the virtual environment VIRTUAL_ENV names; | |
| # setup.sh names the checkout's .venv. | |
| if [[ $version != "rodete" ]] && [[ "${option}" == "base" || "${option}" == "all" ]]; then | |
| _installPipSystem | |
| fi | |
| if [[ "${option}" == "common" || "${option}" == "all" ]]; then | |
| if [[ -z "${VIRTUAL_ENV:-}" ]]; then | |
| echo "ERROR: the system Python is externally managed;" \ | |
| "set VIRTUAL_ENV to the virtual environment to" \ | |
| "install etc/requirements-common_lock.txt into," \ | |
| "or run setup.sh, which installs it into .venv." >&2 | |
| exit 1 | |
| fi | |
| _installPipCommon | |
| fi | |
| fi | |
| ;; | |
| "Darwin" ) | |
| if [[ ${CI} == "yes" ]]; then | |
| echo "WARNING: Installing CI dependencies is only supported on Ubuntu 24.04 and 26.04" >&2 | |
| fi | |
| _installORDependencies | |
| if [[ "${option}" == "base" || "${option}" == "all" ]]; then | |
| _installDarwinPackages | |
| fi | |
| if [[ "${option}" == "common" || "${option}" == "all" ]]; then | |
| _installPipCommon | |
| fi | |
| ;; | |
| *) | |
| echo "unsupported system: ${os}" >&2 | |
| _help | |
| ;; | |
| esac | |