Skip to content

Commit

Permalink
misc/klayout: add build for macos
Browse files Browse the repository at this point in the history
Add support for klayout to build on macos. This involves some rather
egregeous hacks to the Qt build system to work around the fact that
Conda builds things using a custom Mac SDK.

Signed-off-by: Sean Cross <[email protected]>
  • Loading branch information
xobs committed Feb 26, 2023
1 parent e96e6e5 commit 2771625
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
31 changes: 29 additions & 2 deletions misc/klayout/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,30 @@ set -x
UNAME_OUT="$(uname -s)"
case "${UNAME_OUT}" in
Linux*) OS=Linux;;
Darwin*) OS=Mac;;
*) OS="${UNAME_OUT}"
echo "Unknown OS: ${OS}"
exit;;
esac

if [[ $OS == "Linux" ]]; then
bin_ext=""
lib_ext=".so"
elif [[ $OS == "Mac" ]]; then
export bin_ext=".app"
export lib_ext=".dylib"
cd ${PREFIX}
if grep -q -- '-isysroot $$sysroot_path $$version_min_flag' mkspecs/features/mac/default_post.prf; then
sed 's|-isysroot $$sysroot_path $$version_min_flag|-isysroot '$CONDA_BUILD_SYSROOT' -mmacosx-version-min='$MACOSX_DEPLOYMENT_TARGET'|g' mkspecs/features/mac/default_post.prf > mkspecs/features/mac/default_post.prf.bkp
mv mkspecs/features/mac/default_post.prf.bkp mkspecs/features/mac/default_post.prf
elif grep -q -- '-isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag' mkspecs/features/mac/default_post.prf; then
sed 's|-isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag|-isysroot '$CONDA_BUILD_SYSROOT' -mmacosx-version-min='$MACOSX_DEPLOYMENT_TARGET'|g' mkspecs/features/mac/default_post.prf > mkspecs/features/mac/default_post.prf.bkp
mv mkspecs/features/mac/default_post.prf.bkp mkspecs/features/mac/default_post.prf
fi
sed 's|^QMAKE_MAC_SDK_PATH =.*|QMAKE_MAC_SDK_PATH = "'$CONDA_BUILD_SYSROOT'"|g' mkspecs/features/mac/sdk.prf > mkspecs/features/mac/sdk.prf.bkp
mv mkspecs/features/mac/sdk.prf.bkp mkspecs/features/mac/sdk.prf
fi

cd ${SRC_DIR}
./build.sh -build "${SRC_DIR}/build" -python "${PYTHON}" -expert -without-qtbinding -libpng -libexpat -dry-run

Expand All @@ -20,5 +39,13 @@ make V=1 -j$CPU_COUNT
make V=1 install

cd ${SRC_DIR}/bin-release
cp -a klayout strm* ${PREFIX}/bin/
cp -ar *.so* pymod *_plugins ${PREFIX}/lib/
cp -a klayout${bin_ext} strm* ${PREFIX}/bin/
cp -a *${lib_ext}* pymod *_plugins ${PREFIX}/lib/

if [[ $OS == "Mac" ]]; then
# Add a symlink to allow it to run from the command line
cd ${PREFIX}/bin/
ln -s klayout${bin_ext}/Contents/MacOS/klayout .
cd ${SRC_DIR}
cp -a build/pymod/*${lib_ext}* ${PREFIX}/lib/pymod/
fi
30 changes: 17 additions & 13 deletions misc/klayout/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,36 @@ build:
requirements:
build:
- make
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ cdt('mesa-libgl-devel') }} # [linux]
- {{ cdt('mesa-dri-drivers') }} # [linux]
- {{ cdt('libselinux') }} # [linux]
- {{ cdt('libxdamage') }} # [linux]
- {{ cdt('libxxf86vm') }} # [linux]
- {{ cdt('libxext') }} # [linux]
- {{ cdt('libxfixes') }} # [linux]
- {{ cdt('libxau') }} # [linux]
- {{ cdt('libxcb') }} # [linux]
- {{ cdt('expat') }} # [linux]
- {{ cdt('libpng') }} # [linux]
- {{ cdt('mesa-libgl-devel') }} [linux]
- {{ cdt('mesa-dri-drivers') }} [linux]
- {{ cdt('libselinux') }} [linux]
- {{ cdt('libxdamage') }} [linux]
- {{ cdt('libxxf86vm') }} [linux]
- {{ cdt('libxext') }} [linux]
- {{ cdt('libxfixes') }} [linux]
- {{ cdt('libxau') }} [linux]
- {{ cdt('libxcb') }} [linux]
- {{ cdt('expat') }} [linux]
- {{ cdt('libpng') }} [linux]
host:
- python {{ python_version }}
- ruby
- qt
- qt >=5.0,<6.0
- zlib
run:
- python {{ python_version }}
- ruby
- qt
- qt >=5.0,<6.0
- zlib

test:
commands:
- klayout -v
requires:
- ruby
- python {{ python_version }}

about:
home: https://www.klayout.de/
Expand Down

0 comments on commit 2771625

Please sign in to comment.