Skip to content

Commit 2771625

Browse files
committed
misc/klayout: add build for macos
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]>
1 parent e96e6e5 commit 2771625

File tree

2 files changed

+46
-15
lines changed

2 files changed

+46
-15
lines changed

misc/klayout/build.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,30 @@ set -x
77
UNAME_OUT="$(uname -s)"
88
case "${UNAME_OUT}" in
99
Linux*) OS=Linux;;
10+
Darwin*) OS=Mac;;
1011
*) OS="${UNAME_OUT}"
1112
echo "Unknown OS: ${OS}"
1213
exit;;
1314
esac
1415

16+
if [[ $OS == "Linux" ]]; then
17+
bin_ext=""
18+
lib_ext=".so"
19+
elif [[ $OS == "Mac" ]]; then
20+
export bin_ext=".app"
21+
export lib_ext=".dylib"
22+
cd ${PREFIX}
23+
if grep -q -- '-isysroot $$sysroot_path $$version_min_flag' mkspecs/features/mac/default_post.prf; then
24+
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
25+
mv mkspecs/features/mac/default_post.prf.bkp mkspecs/features/mac/default_post.prf
26+
elif grep -q -- '-isysroot $$QMAKE_MAC_SDK_PATH $$version_min_flag' mkspecs/features/mac/default_post.prf; then
27+
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
28+
mv mkspecs/features/mac/default_post.prf.bkp mkspecs/features/mac/default_post.prf
29+
fi
30+
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
31+
mv mkspecs/features/mac/sdk.prf.bkp mkspecs/features/mac/sdk.prf
32+
fi
33+
1534
cd ${SRC_DIR}
1635
./build.sh -build "${SRC_DIR}/build" -python "${PYTHON}" -expert -without-qtbinding -libpng -libexpat -dry-run
1736

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

2241
cd ${SRC_DIR}/bin-release
23-
cp -a klayout strm* ${PREFIX}/bin/
24-
cp -ar *.so* pymod *_plugins ${PREFIX}/lib/
42+
cp -a klayout${bin_ext} strm* ${PREFIX}/bin/
43+
cp -a *${lib_ext}* pymod *_plugins ${PREFIX}/lib/
44+
45+
if [[ $OS == "Mac" ]]; then
46+
# Add a symlink to allow it to run from the command line
47+
cd ${PREFIX}/bin/
48+
ln -s klayout${bin_ext}/Contents/MacOS/klayout .
49+
cd ${SRC_DIR}
50+
cp -a build/pymod/*${lib_ext}* ${PREFIX}/lib/pymod/
51+
fi

misc/klayout/meta.yaml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,36 @@ build:
2727
requirements:
2828
build:
2929
- make
30+
- {{ compiler('c') }}
3031
- {{ compiler('cxx') }}
31-
- {{ cdt('mesa-libgl-devel') }} # [linux]
32-
- {{ cdt('mesa-dri-drivers') }} # [linux]
33-
- {{ cdt('libselinux') }} # [linux]
34-
- {{ cdt('libxdamage') }} # [linux]
35-
- {{ cdt('libxxf86vm') }} # [linux]
36-
- {{ cdt('libxext') }} # [linux]
37-
- {{ cdt('libxfixes') }} # [linux]
38-
- {{ cdt('libxau') }} # [linux]
39-
- {{ cdt('libxcb') }} # [linux]
40-
- {{ cdt('expat') }} # [linux]
41-
- {{ cdt('libpng') }} # [linux]
32+
- {{ cdt('mesa-libgl-devel') }} [linux]
33+
- {{ cdt('mesa-dri-drivers') }} [linux]
34+
- {{ cdt('libselinux') }} [linux]
35+
- {{ cdt('libxdamage') }} [linux]
36+
- {{ cdt('libxxf86vm') }} [linux]
37+
- {{ cdt('libxext') }} [linux]
38+
- {{ cdt('libxfixes') }} [linux]
39+
- {{ cdt('libxau') }} [linux]
40+
- {{ cdt('libxcb') }} [linux]
41+
- {{ cdt('expat') }} [linux]
42+
- {{ cdt('libpng') }} [linux]
4243
host:
4344
- python {{ python_version }}
4445
- ruby
45-
- qt
46+
- qt >=5.0,<6.0
4647
- zlib
4748
run:
4849
- python {{ python_version }}
4950
- ruby
50-
- qt
51+
- qt >=5.0,<6.0
5152
- zlib
5253

5354
test:
5455
commands:
5556
- klayout -v
57+
requires:
58+
- ruby
59+
- python {{ python_version }}
5660

5761
about:
5862
home: https://www.klayout.de/

0 commit comments

Comments
 (0)