Skip to content

Commit

Permalink
WIP: build(pixi): dicom configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Aug 16, 2024
1 parent cd7c4a7 commit c241d30
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 4 deletions.
6 changes: 5 additions & 1 deletion itk_wasm_env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ export ITK_WASM_DCMTK_REPOSITORY=${ITK_WASM_DCMTK_REPOSITORY:-"https://github.co
export ITK_WASM_DCMTK_GIT_TAG=${ITK_WASM_DCMTK_GIT_TAG:-"fe7cff5de40b67ae0490d476ddf17689c06bcaf4"}

export ITK_WASM_ITK_REPOSITORY=${ITK_WASM_ITK_REPOSITORY:-"https://github.com/KitwareMedical/ITK"}
export ITK_WASM_ITK_BRANCH=${ITK_WASM_ITK_BRANCH:-"itkwasm-main-mutable"}
export ITK_WASM_ITK_BRANCH=${ITK_WASM_ITK_BRANCH:-"itkwasm-2024-05-20-5db055d7ad3b-1"}

export ITK_WASM_NATIVE_WORKSPACE=${ITK_WASM_NATIVE_WORKSPACE:-$(pwd)/native}

export ITK_WASM_ITK_SOURCE_DIR=${ITK_WASM_ITK_SOURCE_DIR:-${ITK_WASM_NATIVE_WORKSPACE}/ITK}
export ITK_WASM_ITK_BUILD_DIR=${ITK_WASM_ITK_BUILD_DIR:-${ITK_WASM_NATIVE_WORKSPACE}/ITK-build}
mkdir -p ${ITK_WASM_ITK_BUILD_DIR} || die "Could not create ITK build directory"


export ITK_WASM_DICOM_TEST_DATA_HASH=${ITK_WASM_DICOM_TEST_DATA_HASH:-$(cat packages/dicom/package.json | jq -e -r '."itk-wasm"."test-data-hash"')}
export ITK_WASM_DICOM_TEST_DATA_URLS=${ITK_WASM_DICOM_TEST_DATA_URLS:-$(cat packages/dicom/package.json | jq -e -r '."itk-wasm"."test-data-urls" | join(" ")')}
8 changes: 8 additions & 0 deletions packages/dicom/gdcm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ else()
set(Iconv_BUILD_COMMAND make)
endif()

if(${CMAKE_VERSION} VERSION_LESS 3.24)
set(download_extract_timestamp_flag)
else()
set(download_extract_timestamp_flag
DOWNLOAD_EXTRACT_TIMESTAMP TRUE)
endif()

ExternalProject_Add(${Iconv_LIBRARY}
PREFIX ${Iconv_DIR}
URL "https://bafybeid2yl6aeunciy5rynjmaoxkhhau3jgjpv7x25pylby7hq6n23c57i.ipfs.dweb.link/libiconv-1.16.tar.gz"
Expand All @@ -52,6 +59,7 @@ ExternalProject_Add(${Iconv_LIBRARY}
BUILD_COMMAND ${Iconv_BUILD_COMMAND}
# needed for ninja generator
BUILD_BYPRODUCTS ${Iconv_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}iconv${CMAKE_STATIC_LIBRARY_SUFFIX}
${download_extract_timestamp_flag}
)

add_library(${Iconv} STATIC IMPORTED)
Expand Down
5 changes: 5 additions & 0 deletions packages/dicom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"description": "scripts to generate @itk-wasm/dicom itk-wasm artifacts.",
"type": "module",
"itk-wasm": {
"test-data-hash": "bafybeicskxufnvuem6342pkfwgeo3siiozgzmfo5f34woge6aptuzuwzzu ",
"test-data-urls": [
"https://github.com/InsightSoftwareConsortium/ITK-Wasm/releases/download/itk-wasm-v1.0.0-b.119/dicom-test-data.tar.gz",
"https://w3s.link/ipfs/bafybeiby67winzvozowf4moqthwunuxxscssitnb6wahxv4ugvfxhu2vki/data.tar.gz"
],
"emscripten-docker-image": "itkwasm/emscripten:latest",
"wasi-docker-image": "itkwasm/wasi:latest",
"typescript-package-name": "@itk-wasm/dicom",
Expand Down
124 changes: 123 additions & 1 deletion pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 40 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@ description = "ITK-Wasm native build and test configuration."
name = "ITK-Wasm"
platforms = ["linux-64"]
version = "0.1.0"
license = "Apache-2.0"
readme = "README.md"

[activation]
scripts = ["itk_wasm_env.bash"]

[tasks]
clean = "git clean -fdx"
pnpm-install = { cmd = "pnpm install", description = "Install Node.js dependencies" }

[tasks.dicom-test-data-download]
cmd = "npx dam download test/data test/data.tar.gz $ITK_WASM_DICOM_TEST_DATA_HASH $ITK_WASM_DICOM_TEST_DATA_URLS"
cwd = "packages/dicom"
depends-on = ["pnpm-install"]
outputs = ["packages/dicom/test/data.tar.gz"]
description = "Download DICOM test data"

[dependencies]
pnpm = ">=9.7.1,<10"
nodejs = ">=22.6.0,<23"
jq = ">=1.7.1,<2"

[feature.native.tasks.clone-itk]
cmd = ["stat", "$ITK_WASM_ITK_SOURCE_DIR", ">/dev/null", "||",
Expand All @@ -22,6 +35,7 @@ cmd = ["stat", "$ITK_WASM_ITK_SOURCE_DIR", ">/dev/null", "||",
"$ITK_WASM_ITK_SOURCE_DIR"]
# Note: pixi does not seem to reliably support activation environmental variables in task inputs / outputs
outputs = ["native/ITK/LICENSE"]
description = "Fetch ITK's source code"

[feature.native.tasks.switch-dcmtk]
cmd = ["sed", "-i", "-e",
Expand All @@ -32,17 +46,16 @@ cmd = ["sed", "-i", "-e",
"/^set(DCMTK_GIT_TAG/c\\set(DCMTK_GIT_TAG \"$ITK_WASM_DCMTK_GIT_TAG\")",
"$ITK_WASM_ITK_SOURCE_DIR/Modules/ThirdParty/DCMTK/DCMTKGitTag.cmake"]
depends-on = ["clone-itk"]
description = "Switch DCMTK to the WASM branch"

[feature.native.tasks.configure-itk]
cmd = '''cmake -B$ITK_WASM_ITK_BUILD_DIR -S$ITK_WASM_ITK_SOURCE_DIR -GNinja
-DCMAKE_CXX_STANDARD:STRING=20
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_CONFIGURATION_TYPES:STRING=Debug
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=OFF
-DBUILD_STATIC_LIBS:BOOL=ON
-DDCMTK_LINK_STATIC:BOOL=ON
-DITK_LEGACY_REMOVE:BOOL=ON
-DITK_BUILD_DEFAULT_MODULES:BOOL=ON
-DITKGroup_IO:BOOL=ON
Expand Down Expand Up @@ -72,11 +85,13 @@ depends-on = ["switch-dcmtk"]
# Note: pixi does not seem to reliably support activation environmental variables in task inputs / outputs
# outputs = ["$ITK_WASM_ITK_BUILD_DIR/CMakeFiles/"]
outputs = ["native/ITK-build/CMakeFiles/**"]
description = "Configure ITK"

[feature.native.tasks.build-itk]
cmd = "cmake --build $ITK_WASM_ITK_BUILD_DIR"
depends-on = ["configure-itk"]
outputs = ["native/ITK-build/**"]
description = "Build ITK"

[feature.native.tasks.configure-itk-wasm]
cmd = '''cmake -B$ITK_WASM_NATIVE_WORKSPACE/ITK-Wasm-build -S. -GNinja
Expand All @@ -86,14 +101,37 @@ cmd = '''cmake -B$ITK_WASM_NATIVE_WORKSPACE/ITK-Wasm-build -S. -GNinja
-DCMAKE_BUILD_TYPE:STRING=Debug'''
depends-on = ["build-itk"]
outputs = ["native/ITK-Wasm-build/CMakeFiles/"]
description = "Configure ITK-Wasm"

[feature.native.tasks.build-itk-wasm]
cmd = "cmake --build $ITK_WASM_NATIVE_WORKSPACE/ITK-Wasm-build"
depends-on = ["configure-itk-wasm"]
description = "Build ITK-Wasm"

[feature.native.tasks.test-itk-wasm]
cmd = "ctest --test-dir $ITK_WASM_NATIVE_WORKSPACE/ITK-Wasm-build"
depends-on = ["build-itk-wasm"]
description = "Test ITK-Wasm"

[feature.native.tasks.configure-native-dicom]
cmd = '''cmake -B$ITK_WASM_NATIVE_WORKSPACE/dicom-build -Spackages/dicom -GNinja
-DITK_DIR:PATH=$ITK_WASM_ITK_BUILD_DIR
-DBUILD_TESTING:BOOL=ON
-DCMAKE_CXX_STANDARD:STRING=20
-DCMAKE_BUILD_TYPE:STRING=Debug'''
depends-on = ["build-itk-wasm", "dicom-test-data-download"]
outputs = ["native/dicom-build/CMakeFiles/"]
description = "Configure dicom native binaries"

[feature.native.tasks.build-native-dicom]
cmd = "cmake --build $ITK_WASM_NATIVE_WORKSPACE/dicom-build"
depends-on = ["configure-native-dicom"]
description = "Build dicom native binaries"

[feature.native.tasks.test-native-dicom]
cmd = "ctest --test-dir $ITK_WASM_NATIVE_WORKSPACE/dicom-build"
depends-on = ["build-native-dicom"]
description = "Test dicom native binaries"

[feature.native.dependencies]
cmake = ">=3.30.2,<4"
Expand Down

0 comments on commit c241d30

Please sign in to comment.