Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,121 @@ jobs:
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

minimal:
# The configuration a downstream project vendoring only the core
# reader selects. Nothing else in the matrix proves the tree still
# configures with the optional subdirectories switched off.
Comment on lines +74 to +76

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I need more coffee but I just don't grok these words...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hunk is a copy of #89's minimal job, where the comment now reads "The core-reader-only configuration a vendoring project selects." The copy leaves this PR when it is rebased after #89 merges.

name: minimal configuration (znzlib + niftilib only)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: >
cmake -B ${{ github.workspace }}/build
-DCMAKE_BUILD_TYPE=Release
-DUSE_NIFTI2_CODE=OFF
-DUSE_NIFTICDF_CODE=OFF
-DUSE_CIFTI_CODE=OFF
-DUSE_FSL_CODE=OFF
-DNIFTI_BUILD_APPLICATIONS=OFF
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ github.workspace }}/build
- name: Test
working-directory: ${{ github.workspace }}/build
# This configuration registers no tests at all, because the test
# programs live with the applications that are switched off here.
# --no-tests=ignore keeps that from being an error; the value of
# this job is that the tree still configures and builds.
run: ctest --output-on-failure --no-tests=ignore

oldest-cmake:
# Guards cmake_minimum_required. Every other runner carries a
# recent CMake, so a policy or command that needs a newer release
# than the project claims to support is invisible to them.
# PR #30 was exactly that: CMP0169 does not exist before 3.30 and

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't refer to PRs in the code comments, could be confusing vs upsteam vs the ITK fork.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This is a copy of #89's oldest-cmake job, whose comment no longer names a PR; the copy leaves this PR when it is rebased after #89 merges.

# setting it unconditionally was fatal on Ubuntu 24.04's 3.28.
name: oldest supported CMake
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build libexpat1-dev zlib1g-dev
- name: Show CMake version
run: cmake --version
- name: Configure CMake
run: >
cmake -G Ninja -B ${{ github.workspace }}/build
-DCMAKE_BUILD_TYPE=Release
-DUSE_CIFTI_CODE=ON
-DUSE_FSL_CODE=ON
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ github.workspace }}/build
- name: Test
working-directory: ${{ github.workspace }}/build
run: ctest --output-on-failure

exported-symbols:
# The exported symbol set is the ABI. Several open changes assert
# that they leave it untouched and nothing verified that claim, so
# this job diffs it against a committed baseline. An intentional
# change to the ABI updates the baseline in the same commit, which
# makes the change visible in review rather than implicit.
name: exported symbol baseline
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libexpat1-dev zlib1g-dev ninja-build
- name: Configure CMake
run: >
cmake -G Ninja -B ${{ github.workspace }}/build
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=ON
-DUSE_CIFTI_CODE=ON
-DUSE_FSL_CODE=ON
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ github.workspace }}/build
- name: Collect exported symbols
run: |
bash cmake/collect_exported_symbols.sh \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Google Carbon] minimal (line 73), oldest-cmake (line 101), and exported-symbols (line 128) belong to PR #89 — and exported-symbols fails here because cmake/collect_exported_symbols.sh and cmake/exported_symbols_linux.txt are not on this branch. Please drop lines 73–166 when rebasing onto master after #89 lands.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; these three jobs are #89's and will be dropped when this PR is rebased onto master after #89 merges.

"${{ github.workspace }}/build" \
/tmp/exported_symbols.txt
- name: Compare against the committed baseline
run: |
if ! diff -u cmake/exported_symbols_linux.txt /tmp/exported_symbols.txt; then
echo ""
echo "The exported symbol set changed."
echo "If that is intended, update cmake/exported_symbols_linux.txt"
echo "in this commit so the ABI change is visible in review:"
echo " bash cmake/collect_exported_symbols.sh <build-dir> cmake/exported_symbols_linux.txt"
exit 1
fi
echo "Exported symbols match the baseline."

missing-declarations:
# Clang checks C functions only under -Wmissing-prototypes; GCC under both.
name: no undeclared external functions (FSLSTYLE=${{ matrix.fslstyle }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
fslstyle: ["OFF", "ON"]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libexpat1-dev zlib1g-dev ninja-build
- name: Configure CMake
run: >
cmake -G Ninja -B ${{ github.workspace }}/build
-DCMAKE_BUILD_TYPE=Release
"-DCMAKE_C_FLAGS=-Werror=missing-declarations -Werror=missing-prototypes"
-DNIFTI_BUILD_APPLICATIONS=ON
-DUSE_CIFTI_CODE=ON
-DUSE_FSL_CODE=ON
-DFSLSTYLE=${{ matrix.fslstyle }}
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ github.workspace }}/build
4 changes: 2 additions & 2 deletions nifti2/nifti2_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -7859,7 +7859,7 @@ znzFile nifti_image_write_hdr_img2(nifti_image *nim, int write_opts,

#ifdef PIGZ
#ifdef HAVE_ZLIB
int doPigz2(nifti_image *nim, struct nifti_2_header nhdr, const nifti_brick_list * NBL) {
static int doPigz2(nifti_image *nim, struct nifti_2_header nhdr, const nifti_brick_list * NBL) {
FILE *pigzPipe;
char command[768];
strcpy(command, "pigz" );
Expand Down Expand Up @@ -7891,7 +7891,7 @@ int doPigz2(nifti_image *nim, struct nifti_2_header nhdr, const nifti_brick_list
return 0;
}

int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) {
static int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) {
FILE *pigzPipe;
char command[768];
strcpy(command, "pigz" );
Expand Down
34 changes: 1 addition & 33 deletions niftilib/nifti1_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -5776,39 +5776,7 @@ znzFile nifti_image_write_hdr_img2(nifti_image *nim, int write_opts,

#ifdef PIGZ
#ifdef HAVE_ZLIB
int doPigz2(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) {
FILE *pigzPipe;
char command[768];
strcpy(command, "pigz" );
strcat(command, " -n -f > \"");
strcat(command, nim->fname);
strcat(command, "\"");
#ifdef _MSC_VER
if (( pigzPipe = _popen(command, "w")) == NULL)
return -1;
#else
if (( pigzPipe = popen(command, "w")) == NULL)
return -1;
#endif
znzFile fp;
fp = (znzFile) calloc(1,sizeof(struct znzptr));
fp->zfptr = NULL;
fp->withz = 0;
fp->nzfptr = pigzPipe;
fwrite(&nhdr, sizeof(nhdr), 1, pigzPipe);
if( nim->nifti_type != NIFTI_FTYPE_ANALYZE )
nifti_write_extensions(fp,nim);
nifti_write_all_data(fp,nim,NBL);
#ifdef _MSC_VER
_pclose(pigzPipe);
#else
pclose(pigzPipe);
#endif
free(fp);
return 0;
}

int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) {
static int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) {
FILE *pigzPipe;
char command[768];
strcpy(command, "pigz" );
Expand Down
Loading