Skip to content

Commit 804aed3

Browse files
authored
Merge pull request #4138 from Sahil7741/fix/macos-setup-installer
Improve macOS build support with dependencies validation
2 parents a6cc418 + ccc7e17 commit 804aed3

6 files changed

Lines changed: 90 additions & 6 deletions

File tree

build_openroad.sh

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,64 @@ __docker_build()
253253
__local_build()
254254
{
255255
if [[ "$OSTYPE" == "darwin"* ]]; then
256-
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$(brew --prefix tcl-tk)/bin:$PATH"
257-
export CMAKE_PREFIX_PATH=$(brew --prefix or-tools)
256+
257+
_bison=$(brew --prefix bison 2>/dev/null || true)
258+
_flex=$(brew --prefix flex 2>/dev/null || true)
259+
_ortools=$(brew --prefix or-tools 2>/dev/null || true)
260+
261+
if [[ -z "$_bison" || ! -d "$_bison/bin" ]]; then
262+
echo "[ERROR] bison not found or broken. Run: brew install bison" >&2
263+
exit 1
264+
fi
265+
if [[ -z "$_flex" || ! -d "$_flex/bin" ]]; then
266+
echo "[ERROR] flex not found or broken. Run: brew install flex" >&2
267+
exit 1
268+
fi
269+
if [[ -z "$_ortools" || ! -d "$_ortools/lib" || ! -d "$_ortools/include" ]]; then
270+
echo "[ERROR] or-tools not found or broken. Run: brew install or-tools" >&2
271+
exit 1
272+
fi
273+
274+
export PATH="$_bison/bin:$_flex/bin:$PATH"
275+
export CMAKE_PREFIX_PATH="${_ortools}"
276+
277+
_qt5=$(brew --prefix qt@5 2>/dev/null || true)
278+
if [[ -z "$_qt5" || ! -d "$_qt5/lib" ]]; then
279+
echo "[ERROR] qt@5 not found or broken. Run: brew install qt@5" >&2
280+
exit 1
281+
fi
282+
283+
cmakeOptions+=" -DQt5_DIR=$_qt5/lib/cmake/Qt5"
284+
285+
_tcl8=$(brew --prefix tcl-tk@8 2>/dev/null || true)
286+
if [[ -z "$_tcl8" || ! -d "$_tcl8/lib" || ! -d "$_tcl8/include" ]]; then
287+
echo "[ERROR] tcl-tk@8 not found or broken. Run: brew install tcl-tk@8" >&2
288+
exit 1
289+
fi
290+
291+
cmakeOptions+=" -DTCL_LIBRARY=$_tcl8/lib/libtcl8.6.dylib"
292+
293+
cmakeOptions+=" -DTCL_INCLUDE_PATH=$_tcl8/include"
294+
cmakeOptions+=" -DFLEX_INCLUDE_DIR=$_flex/include"
295+
296+
cmakeOptions+=" -DCMAKE_CXX_FLAGS=-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED"
297+
298+
_icu="$(brew --prefix icu4c 2>/dev/null || true)"
299+
if [[ -z "$_icu" || ! -d "$_icu/lib" ]]; then
300+
echo "[ERROR] icu4c not found or broken. Run: brew install icu4c" >&2
301+
exit 1
302+
fi
303+
304+
export LDFLAGS="-L$_icu/lib"
305+
export CPPFLAGS="-I$_icu/include"
306+
export PKG_CONFIG_PATH="$_icu/lib/pkgconfig"
307+
308+
_extra_lib_paths=("/opt/homebrew/lib")
309+
310+
_joined_paths="$(IFS=:; echo "${_extra_lib_paths[*]}")"
311+
312+
export LIBRARY_PATH="${_joined_paths}${LIBRARY_PATH:+:$LIBRARY_PATH}"
313+
echo "[INFO] General LIBRARY_PATH=$LIBRARY_PATH"
258314
fi
259315
if [[ -f "/opt/rh/rh-python38/enable" ]]; then
260316
set +u

dev_env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function __setpaths() {
1010

1111
if [[ "$OSTYPE" == "darwin"* ]]; then
1212
export CMAKE_PREFIX_PATH="$(brew --prefix or-tools)"
13+
export QT_QPA_PLATFORM=cocoa
1314
fi
1415
}
1516
__setpaths

env.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function __setpaths() {
1717

1818
if [[ "$OSTYPE" == "darwin"* ]]; then
1919
export PATH="/Applications/KLayout/klayout.app/Contents/MacOS:$PATH"
20-
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$(brew --prefix tcl-tk)/bin:$PATH"
20+
export PATH="$(brew --prefix bison)/bin:$(brew --prefix flex)/bin:$(brew --prefix tcl-tk@8)/bin:$PATH"
21+
export QT_QPA_PLATFORM=cocoa
2122
fi
2223

2324
export FLOW_HOME=$DIR/flow

etc/DependencyInstaller.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,23 @@ _installPipCommon() {
3737
set -u
3838
fi
3939
local pkgs="pandas numpy firebase_admin click pyyaml yamlfix"
40-
if [[ $(id -u) == 0 ]]; then
41-
pip3 install --no-cache-dir -U $pkgs
40+
if [[ "$OSTYPE" == "darwin"* ]]; then
41+
if [[ "$EUID" -eq 0 ]]; then
42+
echo "Error: Do NOT run with sudo."
43+
exit 1
44+
fi
45+
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
46+
pip3 install --no-cache-dir -U $pkgs
47+
else
48+
echo "Error: Activate a virtual environment on macOS."
49+
exit 1
50+
fi
4251
else
43-
pip3 install --no-cache-dir --user -U $pkgs
52+
if [[ $(id -u) == 0 ]]; then
53+
pip3 install --no-cache-dir -U $pkgs
54+
else
55+
pip3 install --no-cache-dir --user -U $pkgs
56+
fi
4457
fi
4558
}
4659

flow/scripts/synth.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
set -u -eo pipefail
33
mkdir -p $RESULTS_DIR $LOG_DIR $REPORTS_DIR $OBJECTS_DIR
4+
touch $2
45
$YOSYS_EXE -V > $(realpath $2)
56
$PYTHON_EXE "$SCRIPTS_DIR/run_command.py" --log "$(realpath $2)" --append --tee -- \
67
$YOSYS_EXE $YOSYS_FLAGS -c $1

setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ elif grep -q "^+" "$tmpfile"; then
3535
exit 1
3636
fi
3737

38+
if [[ "$OSTYPE" == "darwin"* ]]; then
39+
if [[ ! -d "$DIR/.venv" ]]; then
40+
echo "Creating Python virtual environment at $DIR/.venv"
41+
python3 -m venv "$DIR/.venv"
42+
fi
43+
44+
echo "Activating virtual environment"
45+
source "$DIR/.venv/bin/activate"
46+
47+
python -m pip install --upgrade pip
48+
fi
49+
3850
"$DIR/etc/DependencyInstaller.sh" -base
3951
if [[ "$OSTYPE" == "darwin"* ]]; then
4052
"$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"

0 commit comments

Comments
 (0)