Skip to content

Commit c78afa1

Browse files
committed
Fix CI build failures across Linux, Windows, and macOS jobs
- SWIG >= 4.4 resolves int64_t to 'long long' unless SWIGWORDSIZE64 is defined; glibc defines it as 'long', so the generated wrappers mixed vector<long long> with the library's vector<long> and failed to compile (Conda/Pip/Bioconda Linux builds). Pass -DSWIGWORDSIZE64 to SWIG on Linux for all bindings and instantiate the int64_t-based container templates there for Python-list conversion parity with Windows/macOS. - Commit recipes/docs, referenced by the Docs Build job but never added, which made rattler-build parse an empty recipe. - Anchor the build/ gitignore pattern to the repository root: rattler-build's path source copy honors .gitignore, and the unanchored pattern dropped the tracked thirdparty/libtiff/build/ directory, breaking the bundled-libtiff configure on Windows (add_subdirectory(build) not found). - Raise the macOS deployment floor from 10.13 to 10.15: TTTR.cpp uses std::filesystem and path::u8string, unavailable before 10.15 (ImageJ darwin builds). - Disable LTO on MinGW: its linker fails to resolve symbols from LTO bitcode in static archives (undefined TIFFSetErrorHandler from the bundled libtiff.a in the ImageJ win32 build).
1 parent ac48f10 commit c78afa1

6 files changed

Lines changed: 131 additions & 11 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Build outputs
2-
build/
2+
# Root-anchored: rattler-build's path source copy honors .gitignore, and an
3+
# unanchored build/ would drop the tracked thirdparty/libtiff/build/ directory.
4+
/build/
35
bld-dir/
46
dist/
57
dist

CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,16 @@ ELSEIF (CMAKE_BUILD_TYPE STREQUAL "Release")
155155
-funroll-loops # Unroll loops
156156
-finline-functions # Inline functions
157157
-fomit-frame-pointer # Omit frame pointer
158-
-flto # Link-time optimization
159158
-w # Disable all warnings in Release builds
160159
)
161-
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto")
162-
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -flto")
160+
# LTO everywhere except MinGW: MinGW's ld fails to resolve symbols from
161+
# LTO bitcode inside static archives (e.g. TIFFSetErrorHandler from the
162+
# bundled libtiff.a), producing undefined references at link time.
163+
IF(NOT MINGW)
164+
ADD_COMPILE_OPTIONS(-flto)
165+
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto")
166+
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -flto")
167+
ENDIF()
163168
ENDIF()
164169
ENDIF ()
165170

@@ -174,17 +179,18 @@ ENDIF (MSVC)
174179
if(APPLE)
175180
FIND_PACKAGE(Threads)
176181

177-
# comatibility with older systems
178-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.13")
179-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.13")
180-
set(CMAKE_LFLAGS "${CMAKE_LFLAGS} -mmacosx-version-min=10.13")
182+
# Compatibility with older systems. 10.15 is the floor: the sources use
183+
# std::filesystem and std::filesystem::path::u8string, which Apple's SDK
184+
# marks unavailable before macOS 10.15.
185+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.15")
186+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.15")
187+
set(CMAKE_LFLAGS "${CMAKE_LFLAGS} -mmacosx-version-min=10.15")
181188

182189
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
183190
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
184191
# explicit link to libc++ for recent osx versions
185192
MESSAGE(STATUS "Explicitly link to libc++ on modern osx versions")
186193
ADD_DEFINITIONS(-stdlib=libc++)
187-
SET(CMAKE_LFLAGS "${CMAKE_LFLAGS} -mmacosx-version-min=10.9")
188194
# Don't set MACOSX_RPATH by default
189195
# https://github.com/conda/conda/issues/3624
190196
if(DEFINED ENV{CONDA_PREFIX})

ext/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ MESSAGE(STATUS "SWIG_VERSION: ${SWIG_VERSION}")
1515
INCLUDE(${SWIG_USE_FILE})
1616
INCLUDE_DIRECTORIES(.)
1717

18+
# glibc on LP64 Linux defines int64_t as 'long', but SWIG's stdint.i typedefs
19+
# (applied by SWIG >= 4.4 whenever stdint.i is included) resolve int64_t to
20+
# 'long long' unless SWIGWORDSIZE64 is defined. Without this flag the
21+
# generated wrappers mix std::vector<long long> with the library's
22+
# std::vector<long> and do not compile on Linux.
23+
IF(UNIX AND NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 8)
24+
SET(TTTRLIB_SWIG_INT64_FLAG "-DSWIGWORDSIZE64")
25+
LIST(APPEND CMAKE_SWIG_FLAGS ${TTTRLIB_SWIG_INT64_FLAG})
26+
ENDIF()
27+
1828
IF(BUILD_PYTHON_INTERFACE)
1929

2030
IF(BUILD_PYTHON_DOCS)
@@ -199,7 +209,7 @@ IF(BUILD_R_INTERFACE)
199209
SWIG_MODULE_NAME tttrlib)
200210

201211
# r/tttrlib.i re-includes the shared fragments that live in ext/python.
202-
SET(CMAKE_SWIG_FLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/python)
212+
SET(CMAKE_SWIG_FLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/python ${TTTRLIB_SWIG_INT64_FLAG})
203213

204214
# Rerun SWIG when any shared fragment, the R module, or the R array library changes.
205215
file(GLOB R_SWIG_DEPS
@@ -250,7 +260,7 @@ IF(BUILD_JAVA_INTERFACE)
250260
SET_SOURCE_FILES_PROPERTIES(java/tttrlib.i PROPERTIES
251261
CPLUSPLUS ON
252262
SWIG_MODULE_NAME tttrlib)
253-
SET(CMAKE_SWIG_FLAGS -package ${J_PACKAGE} -I${CMAKE_CURRENT_SOURCE_DIR}/python)
263+
SET(CMAKE_SWIG_FLAGS -package ${J_PACKAGE} -I${CMAKE_CURRENT_SOURCE_DIR}/python ${TTTRLIB_SWIG_INT64_FLAG})
254264
SET(CMAKE_SWIG_OUTDIR ${J_OUTDIR})
255265

256266
file(GLOB J_SWIG_DEPS

ext/python/misc_types.i

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2+
%include "stdint.i";
23
%include "stl.i";
34
%include "typemaps.i";
45
%include "std_string.i";
@@ -74,6 +75,16 @@ $result = swig::from($1);
7475
// Pair templates
7576
%template(VectorPairInt) std::vector<std::pair<int,int>>;
7677
%template(VectorPairInt64) std::vector<std::pair<long long, long long>>;
78+
79+
// With SWIGWORDSIZE64 (Linux, see ext/CMakeLists.txt) int64_t is 'long' and
80+
// therefore a different type than the 'long long' containers above.
81+
// Instantiate the int64_t-based containers there so the APIs spelled with
82+
// int64_t (BurstFilter, BurstFeatureExtractor) convert to/from native lists
83+
// just like they do on Windows/macOS, where int64_t is 'long long'.
84+
#ifdef SWIGWORDSIZE64
85+
%template(VectorInt64T) std::vector<int64_t>;
86+
%template(VectorPairInt64T) std::vector<std::pair<int64_t, int64_t>>;
87+
#endif
7788
%template(PairVectorDouble) std::pair<std::vector<double>, std::vector<double>>;
7889
%template(PairVectorInt64) std::pair<std::vector<unsigned long long>, std::vector<unsigned long long>>;
7990

recipes/docs/build.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
# 1. Build & install tttrlib into the host python (needed for autodoc/gallery).
5+
export CMAKE_ARGS="-DWITH_AVX=OFF"
6+
"${PYTHON}" -m pip install . --no-deps --no-build-isolation -vv
7+
8+
# 2. Reference data for the example gallery (examples are NOT executed).
9+
export TTTRLIB_DATA="${SRC_DIR}/tttr-data"
10+
export TTTRLIB_DOCS_EXECUTE_EXAMPLES=0
11+
"${PYTHON}" -m pip install --no-build-isolation pooch tqdm || true
12+
"${PYTHON}" test/download_test_data.py --output-dir "${TTTRLIB_DATA}" --quiet || \
13+
echo "warning: reference data download failed; gallery thumbnails may be missing"
14+
15+
# 3. Build the HTML documentation.
16+
export BUILD_TIER="${BUILD_TIER:-4}"
17+
cd doc
18+
mkdir -p _build/api
19+
"${PYTHON}" -m sphinx -T -b html -d _build/doctrees . _build/html/stable
20+
"${PYTHON}" ../tools/check_docs_pages.py _build/html/stable || true
21+
rm -rf _build/html/stable/api
22+
[ -d _build/api ] && cp -r _build/api _build/html/stable/ || true
23+
cd ..
24+
25+
# 4. Install the built HTML into the package.
26+
mkdir -p "${PREFIX}/share/doc/tttrlib"
27+
cp -r doc/_build/html/stable "${PREFIX}/share/doc/tttrlib/html"

recipes/docs/recipe.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# rattler-build recipe that builds the tttrlib HTML documentation (Sphinx +
2+
# Doxygen) reproducibly and packages it under share/doc/tttrlib/html.
3+
# Build with: rattler-build build --recipe recipes/docs -c conda-forge
4+
context:
5+
version: ${{ env.get("PKG_VERSION", default="0.27.0") }}
6+
7+
package:
8+
name: tttrlib-docs
9+
version: ${{ version }}
10+
11+
source:
12+
path: ../..
13+
14+
build:
15+
number: 0
16+
# Documentation is built on Linux.
17+
skip: ${{ not linux }}
18+
19+
requirements:
20+
build:
21+
- ${{ compiler('c') }}
22+
- ${{ compiler('cxx') }}
23+
- cmake
24+
- ninja
25+
- make
26+
- swig >=4.1
27+
- doxygen
28+
- pandoc
29+
- graphviz
30+
host:
31+
- python
32+
- pip
33+
- scikit-build-core
34+
- numpy
35+
- hdf5
36+
- highfive
37+
- nlohmann_json
38+
# Sphinx documentation stack (mirrors the CI docs dependencies)
39+
- sphinx
40+
- sphinx-copybutton
41+
- sphinx-design
42+
- sphinxext-opengraph
43+
- numpydoc
44+
- nbsphinx
45+
- matplotlib-base
46+
- ipython
47+
- sphinxcontrib-bibtex
48+
- sphinx-gallery
49+
- pydata-sphinx-theme
50+
- scikit-image
51+
- phconvert
52+
- numba
53+
- imagecodecs
54+
55+
about:
56+
homepage: https://github.com/fluorescence-tools/tttrlib
57+
summary: HTML documentation for tttrlib (Sphinx + Doxygen).
58+
license: BSD-3-Clause
59+
license_file: LICENSE.txt
60+
repository: https://github.com/fluorescence-tools/tttrlib
61+
62+
extra:
63+
recipe-maintainers:
64+
- tpeulen

0 commit comments

Comments
 (0)