Skip to content

Commit

Permalink
Merge pull request #1209 from thewtex/native-itk-dcmtk-bumps
Browse files Browse the repository at this point in the history
native itk dcmtk bumps
  • Loading branch information
thewtex authored Aug 24, 2024
2 parents d18468d + f81d1de commit d07d12b
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 74 deletions.
126 changes: 66 additions & 60 deletions .github/workflows/toolchains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,76 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main

- name: Pull latest Docker images
run: |
./src/docker/pull.sh --no-debug
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: docker-cache
path: ./docker-cache

- name: Build itk-wasm-base
run: |
if [[ -e ./docker-cache/itk-wasm-emscripten-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-emscripten-base.tar.xz | docker load ; fi
./src/docker/itk-wasm-base/build.sh
mkdir -p ./docker-cache
docker export itkwasm/emscripten-base:latest | xz -e9 -T0 > ./docker-cache/itk-wasm-emscripten-base.tar.xz
- name: Build itk-wasm-base
run: |
if [[ -e ./docker-cache/itk-wasm-wasi-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-wasi-base.tar.xz | docker load ; fi
./src/docker/itk-wasm-base/build.sh --with-wasi
mkdir -p ./docker-cache
docker export itkwasm/wasi-base:latest | xz -e9 -T0 > ./docker-cache/itk-wasm-wasi-base.tar.xz
- name: Cache docker results
uses: actions/upload-artifact@v4
with:
name: docker-cache
path: ./docker-cache
retention-days: 7
- uses: actions/checkout@v4

- uses: prefix-dev/setup-pixi@v0.8.1
- run: pixi run export-itk-wasm-env-vars

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main

- name: Pull latest Docker images
run: |
./src/docker/pull.sh --no-debug
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: docker-cache
path: ./docker-cache

- name: Build itk-wasm-base
run: |
if [[ -e ./docker-cache/itk-wasm-emscripten-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-emscripten-base.tar.xz | docker load ; fi
./src/docker/itk-wasm-base/build.sh
mkdir -p ./docker-cache
docker export itkwasm/emscripten-base:latest | xz -e9 -T0 > ./docker-cache/itk-wasm-emscripten-base.tar.xz
- name: Build itk-wasm-base
run: |
if [[ -e ./docker-cache/itk-wasm-wasi-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-wasi-base.tar.xz | docker load ; fi
./src/docker/itk-wasm-base/build.sh --with-wasi
mkdir -p ./docker-cache
docker export itkwasm/wasi-base:latest | xz -e9 -T0 > ./docker-cache/itk-wasm-wasi-base.tar.xz
- name: Cache docker results
uses: actions/upload-artifact@v4
with:
name: docker-cache
path: ./docker-cache
retention-days: 7

build-itk-wasm:
name: "Build itk-wasm"
needs: build-itk-wasm-base
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main

- name: Pull latest Docker images
run: |
./src/docker/pull.sh --no-debug
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: docker-cache
path: ./docker-cache

- name: Build itk-wasm
run: |
sudo mkdir -p /var/lib/docker/tmp
if [[ -e ./docker-cache/itk-wasm-emscripten-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-emscripten-base.tar.xz | docker import - itkwasm/emscripten:latest ; fi
./src/docker/itk-wasm/build.sh
- name: Build itk-wasi
run: |
if [[ -e ./docker-cache/itk-wasm-wasi-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-wasi-base.tar.xz | docker import - itkwasm/wasi:latest ; fi
./src/docker/itk-wasm/build.sh --with-wasi
- uses: actions/checkout@v4

- uses: prefix-dev/setup-pixi@v0.8.1
- run: pixi run export-itk-wasm-env-vars

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main

- name: Pull latest Docker images
run: |
./src/docker/pull.sh --no-debug
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: docker-cache
path: ./docker-cache

- name: Build itk-wasm
run: |
sudo mkdir -p /var/lib/docker/tmp
if [[ -e ./docker-cache/itk-wasm-emscripten-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-emscripten-base.tar.xz | docker import - itkwasm/emscripten:latest ; fi
./src/docker/itk-wasm/build.sh
- name: Build itk-wasi
run: |
if [[ -e ./docker-cache/itk-wasm-wasi-base.tar.xz ]]; then xz -d -k < ./docker-cache/itk-wasm-wasi-base.tar.xz | docker import - itkwasm/wasi:latest ; fi
./src/docker/itk-wasm/build.sh --with-wasi
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ packages/transform-io/typescript/demo-app/
*.egg-info

native/

src/docker/itk-wasm-base/itk_wasm_env_vars.sh
4 changes: 2 additions & 2 deletions docs/development/hacking_itk_wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ To pull the `latest` the build environment Docker images,
To build the `latest` build environment Docker images from the Docker configuration and local C++ core,

```sh
./src/docker/build.sh --with-debug
pixi run build-docker-images --with-debug
```

The `--with-debug` flag will also build the `latest-debug` tagged images.
Expand Down Expand Up @@ -242,4 +242,4 @@ and rebuild whenever the documentation changes.
[standard GitHub contribution best practices]: https://docs.itk.org/en/latest/contributing/index.html
[web3.storage]: https://web3.storage/
[Windows Git Bash]: https://gitforwindows.org/
[WSL]: https://learn.microsoft.com/en-us/windows/wsl/install
[WSL]: https://learn.microsoft.com/en-us/windows/wsl/install
10 changes: 5 additions & 5 deletions itk_wasm_env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ function die() {
exit 1
}

if [$OSTYPE == "cygwin"] || [$OSTYPE == "msys"] || [$OSTYPE =="win32"]; then
if test "$OSTYPE" = "cygwin" || test "$OSTYPE" = "msys" || test "$OSTYPE" = "win32"; then
echo "Windows platform detected ... adding \"/Zc:__cplusplus /DNOMINMAX\" to \$CXXFLAGS"
export CXXFLAGS="/Zc:__cplusplus /DNOMINMAX"
export CXXFLAGS="/Zc:__cplusplus /Zc:preprocessor /DNOMINMAX"
fi

export ITK_WASM_DCMTK_REPOSITORY=${ITK_WASM_DCMTK_REPOSITORY:-"https://github.com/InsightSoftwareConsortium/DCMTK"}
export ITK_WASM_DCMTK_GIT_TAG=${ITK_WASM_DCMTK_GIT_TAG:-"fe7cff5de40b67ae0490d476ddf17689c06bcaf4"}
export ITK_WASM_DCMTK_GIT_TAG=${ITK_WASM_DCMTK_GIT_TAG:-"93e6d1b20b476c388f0379245c8c6e96af7f16f4"}

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

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

Expand All @@ -27,4 +27,4 @@ export ITK_WASM_DICOM_TEST_DATA_HASH=${ITK_WASM_DICOM_TEST_DATA_HASH:-$(cat pack
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(" ")')}

export ITK_WASM_MESH_IO_TEST_DATA_HASH=${ITK_WASM_MESH_IO_TEST_DATA_HASH:-$(cat packages/mesh-io/package.json | jq -e -r '."itk-wasm"."test-data-hash"')}
export ITK_WASM_MESH_IO_TEST_DATA_URLS=${ITK_WASM_MESH_IO_TEST_DATA_URLS:-$(cat packages/mesh-io/package.json | jq -e -r '."itk-wasm"."test-data-urls" | join(" ")')}
export ITK_WASM_MESH_IO_TEST_DATA_URLS=${ITK_WASM_MESH_IO_TEST_DATA_URLS:-$(cat packages/mesh-io/package.json | jq -e -r '."itk-wasm"."test-data-urls" | join(" ")')}
16 changes: 16 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ depends-on = ["pnpm-install"]
outputs = ["packages/mesh-io/test/data.tar.gz"]
description = "Download mesh-io test data"

[tasks.export-itk-wasm-env-vars]
cmd = "bash -c ./itk_wasm_env.bash && env | grep ITK_WASM | grep -v TEST > ./src/docker/itk-wasm-base/itk_wasm_env_vars.sh"
outputs = ["src/docker/itk-wasm-base/itk_wasm_env_vars.*"]
inputs = ["itk_wasm_env.*"]
description = "Provide ITK_WASM environmental variables to the Docker image"

[tasks.update-default-image-tag]
cmd = "sed -i \"s/const defaultImageTag = '.*'/const defaultImageTag = '$new_tag'/g\" packages/core/typescript/itk-wasm/src/cli/default-image-tag.js"
outputs = ["packages/core/typescript/itk-wasm/src/cli/default-image-tag.*"]
description = "Update the default Docker image tag"

[tasks.build-docker-images]
cmd = "src/docker/build.sh"
description = "Build the ITK-Wasm docker images"
depends-on = ["clean", "export-itk-wasm-env-vars", "update-default-image-tag"]

[dependencies]
pnpm = ">=9.7.1,<10"
nodejs = ">=22.6.0,<23"
Expand Down
11 changes: 5 additions & 6 deletions src/docker/itk-wasm-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LABEL org.opencontainers.image.source="https://github.com/InsightSoftwareConsort

WORKDIR /

COPY itk_wasm_env_vars.sh /

# Note: on entry, emsdk will prepend to the path with its own node, so add to an earlier path
ENV NODE_TAG v20.12.2
RUN curl -LO https://nodejs.org/dist/${NODE_TAG}/node-${NODE_TAG}-linux-x64.tar.xz && \
Expand All @@ -33,19 +35,16 @@ RUN curl -L https://api.github.com/repos/facebook/zstd/tarball/${zstd_GIT_TAG} |
cd .. && \
rm -rf zstd-build zstd

# tag commit date: 2024-08-16
ENV ITK_GIT_TAG eddb514e52a23e2b0987b71fda59780c6ad209ab
ENV ITK_GIT_BRANCH itkwasm-2024-05-20-5db055d7ad3b-3
RUN git clone --branch $ITK_GIT_BRANCH --single-branch --depth 1 https://github.com/KitwareMedical/ITK.git && \
RUN . /itk_wasm_env_vars.sh && git clone --branch $ITK_WASM_ITK_BRANCH --single-branch --depth 1 $ITK_WASM_ITK_REPOSITORY && \
sed -i -e '/^option(OPJ_USE_THREAD/c\option(OPJ_USE_THREAD "use threads" OFF)' \
/ITK/Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmopenjpeg/src/lib/openjp2/CMakeLists.txt

# Modify CMake variable to use patched DCMTK library
# GIT_TAG refers to DCMTK branch: 20240311_DCMTK_PATCHES_FOR_ITK-Wasm-1
RUN sed -i -e '/^set(DCMTK_GIT_REPOSITORY/c\set(DCMTK_GIT_REPOSITORY "https://github.com/InsightSoftwareConsortium/DCMTK.git")' \
RUN . /itk_wasm_env_vars.sh && sed -i -e "/^set(DCMTK_GIT_REPOSITORY/c\set(DCMTK_GIT_REPOSITORY \"${ITK_WASM_DCMTK_REPOSITORY}\")" \
/ITK/Modules/ThirdParty/DCMTK/DCMTKGitTag.cmake

RUN sed -i -e '/^set(DCMTK_GIT_TAG/c\set(DCMTK_GIT_TAG "93e6d1b20b476c388f0379245c8c6e96af7f16f4")' \
RUN . /itk_wasm_env_vars.sh && sed -i -e "/^set(DCMTK_GIT_TAG/c\set(DCMTK_GIT_TAG \"${ITK_WASM_DCMTK_GIT_TAG}\")" \
/ITK/Modules/ThirdParty/DCMTK/DCMTKGitTag.cmake

RUN if test -e $WASI_SDK_PATH/share/cmake/wasi-sdk.cmake; then sed -i '/cmake_minimum_required/d' $WASI_SDK_PATH/share/cmake/wasi-sdk.cmake; fi
Expand Down

0 comments on commit d07d12b

Please sign in to comment.