22set -euo pipefail
33
44ROOT_DIR=" $( cd " $( dirname " $0 " ) /.." && pwd) "
5- LBUG_DIR=" ${1:- ${ROOT_DIR} / ladybug} "
5+ LBUG_DIR=" ${1:- $(cd " ${ROOT_DIR} /.." && pwd)/ ladybug} "
6+ BUILD_DIR=" ${ROOT_DIR} /build/pybind"
7+ CCACHE_DIR=" ${ROOT_DIR} /.cache/ccache"
8+ CCACHE_TEMPDIR=" ${CCACHE_DIR} /tmp"
69
710if [[ ! -d " ${LBUG_DIR} " ]]; then
811 echo " ladybug source checkout not found: ${LBUG_DIR} " >&2
9- echo " Expected inverted layout: <repo>/ladybug " >&2
12+ echo " Set LBUG_SOURCE_DIR to your Ladybug source tree checkout. " >&2
1013 exit 1
1114fi
1215
13- TOOLS_DIR=" ${LBUG_DIR} /tools"
14- API_LINK=" ${TOOLS_DIR} /python_api"
15-
16- mkdir -p " ${TOOLS_DIR} "
17-
18- if [[ -e " ${API_LINK} " && ! -L " ${API_LINK} " ]]; then
19- echo " Refusing to overwrite non-symlink path: ${API_LINK} " >&2
20- echo " Please remove it manually or convert it to a symlink to ${ROOT_DIR} " >&2
21- exit 1
22- fi
23-
24- rm -f " ${API_LINK} "
25- ln -s " ${ROOT_DIR} " " ${API_LINK} "
26-
27- echo " [pybind] Building via ${LBUG_DIR} (target: make python)"
16+ echo " [pybind] Building ${ROOT_DIR} with Ladybug sources from ${LBUG_DIR} "
2817PYTHON_BIN=" ${PYTHON_BIN:- ${ROOT_DIR} / .venv/ bin/ python} "
2918if [[ ! -x " ${PYTHON_BIN} " ]]; then
3019 PYTHON_BIN=" $( command -v python3) "
@@ -37,31 +26,29 @@ export PATH="$(dirname "${PYTHON_BIN}"):${PATH}"
3726export PYTHON_EXECUTABLE=" ${PYTHON_BIN} "
3827export Python_EXECUTABLE=" ${PYTHON_BIN} "
3928export Python3_EXECUTABLE=" ${PYTHON_BIN} "
29+ export CCACHE_DIR
30+ export CCACHE_TEMPDIR
4031
41- make -C " ${LBUG_DIR} " clean-python-api || true
42- rm -rf " ${LBUG_DIR} /build/release"
32+ mkdir -p " ${CCACHE_TEMPDIR} "
4333
44- EXTRA_CMAKE_FLAGS=" -DPYTHON_EXECUTABLE=${PYTHON_BIN} -DPython_EXECUTABLE=${PYTHON_BIN} -DPython3_EXECUTABLE=${PYTHON_BIN} -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION} " \
45- make -C " ${LBUG_DIR} " python
34+ rm -rf " ${BUILD_DIR} "
4635
47- mkdir -p " ${ROOT_DIR} /build/ladybug"
48- cp " ${ROOT_DIR} " /src_py/* .py " ${ROOT_DIR} /build/ladybug/"
36+ cmake \
37+ -S " ${ROOT_DIR} " \
38+ -B " ${BUILD_DIR} " \
39+ -DCMAKE_BUILD_TYPE=Release \
40+ -DLBUG_SOURCE_DIR=" ${LBUG_DIR} " \
41+ -DPYTHON_EXECUTABLE=" ${PYTHON_BIN} " \
42+ -DPython_EXECUTABLE=" ${PYTHON_BIN} " \
43+ -DPython3_EXECUTABLE=" ${PYTHON_BIN} " \
44+ -DPYBIND11_PYTHON_VERSION=" ${PYTHON_VERSION} "
4945
50- # Copy extension artifact(s) to local build package.
51- shopt -s nullglob
52- for ext in " ${API_LINK} /build/ladybug" /_lbug* .so " ${API_LINK} /build/ladybug" /_lbug* .pyd " ${API_LINK} /build/ladybug" /_lbug* .dylib; do
53- src_real=" $( realpath " ${ext} " ) "
54- dst_real=" $( realpath " ${ROOT_DIR} /build/ladybug/$( basename " ${ext} " ) " 2> /dev/null || true) "
55- if [[ -n " ${dst_real} " && " ${src_real} " == " ${dst_real} " ]]; then
56- continue
57- fi
58- cp " ${ext} " " ${ROOT_DIR} /build/ladybug/"
59- done
46+ cmake --build " ${BUILD_DIR} " --config Release --target _lbug
6047
6148if compgen -G " ${ROOT_DIR} /build/ladybug/_lbug*" > /dev/null; then
62- echo " [pybind] Copied extension into ${ROOT_DIR} /build/ladybug"
49+ echo " [pybind] Built extension into ${ROOT_DIR} /build/ladybug"
6350else
6451 echo " [pybind] Build finished, but no _lbug extension artifact was found." >&2
65- echo " Checked: ${API_LINK } /build/ladybug" >&2
52+ echo " Checked: ${ROOT_DIR } /build/ladybug" >&2
6653 exit 1
6754fi
0 commit comments