diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 4a19f9a3..11867d42 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -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. + 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 + # 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 \ + "${{ 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 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 diff --git a/nifti2/nifti2_io.c b/nifti2/nifti2_io.c index 24341e8e..15bb3f78 100644 --- a/nifti2/nifti2_io.c +++ b/nifti2/nifti2_io.c @@ -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" ); @@ -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" ); diff --git a/niftilib/nifti1_io.c b/niftilib/nifti1_io.c index 1c843bfd..46a0c59e 100644 --- a/niftilib/nifti1_io.c +++ b/niftilib/nifti1_io.c @@ -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" );