Skip to content
42 changes: 42 additions & 0 deletions recipes/recipes_emscripten/libitk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
set -e

mkdir -p build
cd build

emcmake cmake ${CMAKE_ARGS} \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
-DITK_USE_GPU=OFF \
-DITK_DEFAULT_THREADER=Platform \
-DITK_USE_PTHREADS=OFF \
-DITK_USE_OPENMP=OFF \
-DModule_ITKTBBImageToImageFilter=OFF \
-DITK_USE_FFTWD=OFF \
-DITK_USE_FFTWF=OFF \
-DITK_USE_SYSTEM_FFTW=OFF \
-DITK_DYNAMIC_LOADING=OFF \
-DITK_USE_SYSTEM_EXPAT=ON \
-DITK_USE_SYSTEM_JPEG=ON \
-DITK_USE_SYSTEM_PNG=ON \
-DITK_USE_SYSTEM_TIFF=ON \
-DITK_USE_SYSTEM_ZLIB=ON \
-DITK_USE_SYSTEM_EIGEN=ON \
-DITK_BUILD_DEFAULT_MODULES=ON \
-DModule_ITKReview=ON \
-DModule_ITKTBB=OFF \
-DModule_ITKHDF5=OFF \
-DModule_ITKIOHDF5=OFF \
-DModule_ITKIOTransformHDF5=OFF \
-DModule_ITKIOTransformFactory=OFF \
-DITK_FORBID_DOWNLOADS=ON \
"${SRC_DIR}"

ninja -j${CPU_COUNT}
ninja install
50 changes: 50 additions & 0 deletions recipes/recipes_emscripten/libitk/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
context:
name: libitk
version: "5.4.6"

package:
name: ${{ name }}
version: ${{ version }}

source:
- url: https://github.com/InsightSoftwareConsortium/ITK/archive/v${{ version }}.tar.gz
sha256: cf28bc7220c57c24ebcbabbd3b2544ea7ab65f0aad430a99f8e157738ed812b7

build:
number: 0

requirements:
build:
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- cmake
- ninja
host:
- expat
- libjpeg-turbo
- libpng
- libtiff
- eigen
- zlib

tests:
- package_contents:
files:
- include/ITK-5.4/itkImage.h
- lib/libITKCommon-5.4.a

about:
homepage: https://www.itk.org/
license: Apache-2.0
license_file: LICENSE
summary: ITK is an open-source toolkit for multidimensional image analysis
description: |
The Insight Toolkit (ITK) is an open-source, cross-platform system that
provides developers with an extensive suite of software tools for image
analysis. Developed through extreme programming methodologies, ITK employs
leading-edge algorithms for registering and segmenting multidimensional data.
repository: https://github.com/InsightSoftwareConsortium/ITK

extra:
recipe-maintainers:
- Copilot
54 changes: 54 additions & 0 deletions recipes/recipes_emscripten/simpleitk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
set -e

# Step 1: Build SimpleITK C++ library (without Python wrapping)
# Use CMAKE_ARGS from emscripten environment (set up by emscripten_emscripten-wasm32)
# but strip the Python flags that cross-python adds, as they are not needed here
mkdir -p build_cpp
cd build_cpp

cmake ${CMAKE_ARGS} \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
-DSimpleITK_BUILD_DISTRIBUTE=ON \
-DWRAP_DEFAULT=OFF \
"${SRC_DIR}"

ninja -j${CPU_COUNT}
ninja install

cd ..

# Step 2: Build the Python wrapper
# CMAKE_ARGS now also contains Python-related flags added by cross-python
mkdir -p build_python
cd build_python

cmake ${CMAKE_ARGS} \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_PROJECT_INCLUDE="${RECIPE_DIR}/overwriteProp.cmake" \
-DSimpleITK_BUILD_DISTRIBUTE=ON \
-DSimpleITK_PYTHON_THREADS=OFF \
-DSimpleITK_PYTHON_USE_VIRTUALENV=OFF \
-DSimpleITK_PYTHON_USE_LIMITED_API=OFF \
-DPython_EXECUTABLE="${PYTHON}" \
-DSWIG_EXECUTABLE="$(which swig)" \
"${SRC_DIR}/Wrapping/Python"

ninja -j${CPU_COUNT}

# Install the Python package
"${PYTHON}" -m pip install . ${PIP_ARGS}
4 changes: 4 additions & 0 deletions recipes/recipes_emscripten/simpleitk/overwriteProp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s WASM_BIGINT -s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s WASM_BIGINT -s SIDE_MODULE=1 -fwasm-exceptions")
set(CMAKE_STRIP FALSE)
63 changes: 63 additions & 0 deletions recipes/recipes_emscripten/simpleitk/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
context:
name: SimpleITK
version: "2.5.3"

package:
name: simpleitk
version: ${{ version }}

source:
- url: https://github.com/SimpleITK/SimpleITK/releases/download/v${{ version }}/SimpleITK-${{ version }}.tar.gz
sha256: 1ef3642b0695c8eb0a0193fefe7677c57bce94a86d6b01f48f58b2291b4ca935

build:
number: 0
files:
exclude:
- '**/__pycache__/**'
- '**/*.pyc'
python:
skip_pyc_compilation:
- '**/*.py'

requirements:
build:
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- cmake
- ninja
- swig >=4.0.0
- cross-python_${{ target_platform }}
- python
host:
- python
- pip
- libitk
run:
- python

tests:
- script: pytester
files:
recipe:
- test_import_simpleitk.py
requirements:
build:
- pytester
run:
- pytester-run

about:
homepage: http://www.simpleitk.org
license: Apache-2.0
license_file: LICENSE
summary: Simplified interface to the Insight Toolkit for image registration and segmentation
description: |
SimpleITK is a simplified layer built on top of ITK (Insight Segmentation and
Registration Toolkit). It provides bindings for multiple programming languages
including Python, Java, C#, R, Lua, Tcl, and Ruby.
repository: https://github.com/SimpleITK/SimpleITK

extra:
recipe-maintainers:
- Copilot
6 changes: 6 additions & 0 deletions recipes/recipes_emscripten/simpleitk/test_import_simpleitk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def test_import_simpleitk():
import SimpleITK as sitk
# Basic sanity check
img = sitk.Image(10, 10, sitk.sitkUInt8)
assert img.GetWidth() == 10
assert img.GetHeight() == 10
Loading