Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/user/Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ it can be uploaded in the "Relevant log output" section of OpenROAD
[issue forms](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/issues/new/choose).
```

### Only for macOS Setup

On macOS, it is recommended to use a Python virtual environment to isolate dependencies and avoid system conflicts.

1. Create a virtual environment in the OpenROAD directory:
``` shell
python3 -m venv .venv
```

2. Activate the virtual environment:
``` shell
source .venv/bin/activate
```

3. With virtual environment activated, run without `sudo`:
``` shell
./etc/DependencyInstaller.sh -base
./etc/DependencyInstaller.sh -common -local
```

### Install Dependencies

You may follow our helper script to install dependencies as follows:
Expand Down
62 changes: 59 additions & 3 deletions etc/Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildDir="build"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
numThreads=$(nproc --all)
elif [[ "$OSTYPE" == "darwin"* ]]; then
numThreads=$(sysctl -n hw.ncpu)
numThreads=$(sysctl -n hw.logicalcpu)
else
cat << EOF
WARNING: Unsupported OSTYPE: cannot determine number of host CPUs"
Expand Down Expand Up @@ -196,8 +196,64 @@ mkdir -p "${buildDir}"
__logging

if [[ "$OSTYPE" == "darwin"* ]]; then
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$PATH"
export CMAKE_PREFIX_PATH=$(brew --prefix or-tools)

_bison=$(brew --prefix bison 2>/dev/null || true)
_flex=$(brew --prefix flex 2>/dev/null || true)
_ortools=$(brew --prefix or-tools 2>/dev/null || true)

if [[ -z "$_bison" || ! -d "$_bison/bin" ]]; then
echo "[ERROR] bison not found or broken. Run: brew install bison" >&2
exit 1
fi
if [[ -z "$_flex" || ! -d "$_flex/bin" ]]; then
echo "[ERROR] flex not found or broken. Run: brew install flex" >&2
exit 1
fi
if [[ -z "$_ortools" || ! -d "$_ortools/lib" || ! -d "$_ortools/include" ]]; then
echo "[ERROR] or-tools not found or broken. Run: brew install or-tools" >&2
exit 1
fi

export PATH="$_bison/bin:$_flex/bin:$PATH"
export CMAKE_PREFIX_PATH="${_ortools}"

_qt5=$(brew --prefix qt@5 2>/dev/null || true)
if [[ -z "$_qt5" || ! -d "$_qt5/lib" ]]; then
echo "[ERROR] qt@5 not found or broken. Run: brew install qt@5" >&2
exit 1
fi

cmakeOptions+=" -DQt5_DIR=$_qt5/lib/cmake/Qt5"

_tcl8=$(brew --prefix tcl-tk@8 2>/dev/null || true)
if [[ -z "$_tcl8" || ! -d "$_tcl8/lib" || ! -d "$_tcl8/include" ]]; then
echo "[ERROR] tcl-tk@8 not found or broken. Run: brew install tcl-tk@8" >&2
exit 1
fi

cmakeOptions+=" -DTCL_LIBRARY=$_tcl8/lib/libtcl8.6.dylib"

cmakeOptions+=" -DTCL_INCLUDE_PATH=$_tcl8/include"
cmakeOptions+=" -DFLEX_INCLUDE_DIR=$_flex/include"

cmakeOptions+=" -DCMAKE_CXX_FLAGS=-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED"

_icu="$(brew --prefix icu4c 2>/dev/null || true)"
if [[ -z "$_icu" || ! -d "$_icu/lib" ]]; then
echo "[ERROR] icu4c not found or broken. Run: brew install icu4c" >&2
exit 1
fi

export LDFLAGS="-L$_icu/lib"
export CPPFLAGS="-I$_icu/include"
export PKG_CONFIG_PATH="$_icu/lib/pkgconfig"

_extra_lib_paths=("$(brew --prefix)/lib")

_joined_paths="$(IFS=:; echo "${_extra_lib_paths[*]}")"

export LIBRARY_PATH="${_joined_paths}${LIBRARY_PATH:+:$LIBRARY_PATH}"
echo "[INFO] General LIBRARY_PATH=$LIBRARY_PATH"
fi

# ==============================================================================
Expand Down
14 changes: 9 additions & 5 deletions etc/DependencyInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ set -euo pipefail
PREFIX=""
CI="no"
SAVE_DEPS_PREFIXES=""
NUM_THREADS=$(nproc)
if [[ "$OSTYPE" == "darwin"* ]]; then
NUM_THREADS=$(sysctl -n hw.logicalcpu)
else
NUM_THREADS=$(nproc)
fi
SKIP_SYSTEM_OR_TOOLS="false"
BASE_DIR=$(mktemp -d /tmp/DependencyInstaller-XXXXXX)
CMAKE_PACKAGE_ROOT_ARGS=""
Expand Down Expand Up @@ -953,9 +957,9 @@ EOF
exit 1
fi
log "Install darwin base packages using homebrew (-base or -all)"
_execute "Installing Homebrew packages..." brew install bison boost bzip2 cmake eigen flex fmt groff googletest libomp or-tools pandoc pkg-config pyqt python spdlog tcl-tk zlib swig yaml-cpp
_execute "Installing pipx..." brew install pipx
_execute "Installing Python click..." pipx install click
_execute "Installing Homebrew packages..." brew install bison boost bzip2 cmake eigen flex fmt groff googletest icu4c libomp or-tools pandoc pkg-config qt@5 python spdlog tcl-tk@8 zlib swig yaml-cpp
# _execute "Installing pipx..." brew install pipx
_execute "Installing Python click..." pip install click
_execute "Linking libomp..." brew link --force libomp
_execute "Installing lemon-graph..." brew install The-OpenROAD-Project/lemon-graph/lemon-graph
}
Expand Down Expand Up @@ -1220,7 +1224,7 @@ main() {
cat <<EOF

To install or run OpenROAD, update your path with:
export PATH="\$(brew --prefix bison)/bin:\$(brew --prefix flex)/bin:\$(brew --prefix tcl-tk)/bin:\${PATH}"
export PATH="\$(brew --prefix bison)/bin:\$(brew --prefix flex)/bin:\$(brew --prefix tcl-tk@8)/bin:\${PATH}"
export CMAKE_PREFIX_PATH=\$(brew --prefix or-tools)
EOF
;;
Expand Down
Loading