Skip to content
Open
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
67 changes: 26 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,47 @@
name: Build

on: [push,pull_request]
on: [push, pull_request]

env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
# C.UTF-8 is always available without locale-gen and keeps LaTeX byte-clean.
LC_ALL: C.UTF-8
LANG: C.UTF-8

jobs:
build-publish-pdf:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install build dependencies
# System TeX: conda-forge texlive-core is engine-only, so a real LaTeX
# distribution comes from apt. ghostscript, ImageMagick 7, Pygments, cmake
# and ninja are provided by the pixi 'build' environment.
- name: Install system TeX
run: |
sudo apt-get update && sudo apt-get install -y \
apt-utils \
build-essential \
ccache \
cmake \
curl \
git \
ninja-build \
python3
# Using --no-install-recommends greatly reduces the installed packages
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
texlive-latex-base \
texlive-latex-extra
sudo apt-get install -y \
dvipng \
ghostscript \
locales \
imagemagick \
python3 \
python3-pygments \
texlive-latex-extra \
texlive-latex-recommended \
tex4ht \
texlive-fonts-recommended
sudo echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
sudo locale-gen
sudo sed -i 's/none/read|write/' /etc/ImageMagick-6/policy.xml
texlive-fonts-recommended \
dvipng \
tex4ht
sudo apt-get clean

- name: Build
- name: Set up pixi
uses: prefix-dev/setup-pixi@v0.9.6
with:
environments: build
cache: true

- name: Build the Software Guide
run: pixi run build

- name: Collect PDFs
run: |
mkdir build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel -DSuperBuild_ITKSoftwareGuide_USE_GIT_PROTOCOL:BOOL=OFF ..
ninja
cp ./ITKSoftwareGuide-build/SoftwareGuide/Latex/ITKSoftwareGuide-Book1.pdf ../InsightSoftwareGuide-Book1.pdf
cp ./ITKSoftwareGuide-build/SoftwareGuide/Latex/ITKSoftwareGuide-Book2.pdf ../InsightSoftwareGuide-Book2.pdf
cp build/ITKSoftwareGuide-build/SoftwareGuide/Latex/ITKSoftwareGuide-Book1.pdf InsightSoftwareGuide-Book1.pdf
cp build/ITKSoftwareGuide-build/SoftwareGuide/Latex/ITKSoftwareGuide-Book2.pdf InsightSoftwareGuide-Book2.pdf

- name: Publish ITK Software Guide Book 1 artifact
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Utilities/.chktexrc
.pixi/
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# .pre-commit-config.yaml
# See https://pre-commit.com ; install with: pixi run -e pre-commit pre-commit-install
# Skip a hook for one commit with: SKIP=<id> git commit ...

default_stages: [pre-commit]
exclude: '^(XFigOriginals/|.*/Art/|.*\.(eps|fig|dia|gnup|jpg|jpeg|png|pdf))$'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
args: ['--maxkb=1024']
- id: check-merge-conflict
- id: check-case-conflict
- id: mixed-line-ending

- repo: local
hooks:
# LaTeX lint (advisory) — migrated from Utilities/latex_linter.sh.
# Runs per staged .tex file; prints findings but never blocks the commit.
- id: chktex
name: 'chktex (LaTeX lint, advisory)'
entry: Utilities/Hooks/chktex-lint.sh
language: system
files: '\.tex$'
verbose: true

# Enforce the ITK commit-message prefix (BUG:/COMP:/DOC:/ENH:/PERF:/STYLE:/WIP:).
# Reuses the authoritative native hook so the rule lives in one place.
- id: commit-prefix
name: 'commit message prefix'
entry: Utilities/Hooks/commit-msg
language: system
stages: [commit-msg]
18 changes: 0 additions & 18 deletions Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ set(CMAKE_MODULE_PATH
include(PreventInSourceBuilds)
include(PreventInBuildInstalls)

#-----------------------------------------------------------------------------
# Platform check
#-----------------------------------------------------------------------------
set(PLATFORM_CHECK true)
if(PLATFORM_CHECK)
# See CMake/Modules/Platform/Darwin.cmake)
# 6.x == Mac OSX 10.2 (Jaguar)
# 7.x == Mac OSX 10.3 (Panther)
# 8.x == Mac OSX 10.4 (Tiger)
# 9.x == Mac OSX 10.5 (Leopard)
# 10.x == Mac OSX 10.6 (Snow Leopard)
if (DARWIN_MAJOR_VERSION LESS "9")
message(FATAL_ERROR "Only Mac OSX >= 10.5 are supported !")
endif()
endif()


#-----------------------------------------------------------------------------
if(NOT COMMAND SETIFEMPTY)
macro(SETIFEMPTY)
Expand Down Expand Up @@ -93,4 +76,3 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
endif()

2 changes: 1 addition & 1 deletion ITKSoftwareGuide.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(CMAKE_MODULE_PATH
)

#-----------------------------------------------------------------------------
set(MINIMUM_ITK_VERSION 5)
set(MINIMUM_ITK_VERSION 6)
find_package(ITK ${MINIMUM_ITK_VERSION} REQUIRED)
if(Slicer_BUILD_${PROJECT_NAME})
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # Incorporate with Slicer nicely
Expand Down
9 changes: 4 additions & 5 deletions SoftwareGuide/Art/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
file(GLOB PNGandJPG_IMAGES *.jpg *.png)
file(GLOB EPS_IMAGES *.eps)

find_package(ImageMagick 6 COMPONENTS convert REQUIRED)
if(NOT ImageMagick_convert_EXECUTABLE)
message("ImageMagick convert utility was not found. Please pass to advanced mode and provide its full path")
endif()
# ImageMagick 7: resolve the unified 'magick' driver. Its 'convert' subcommand
# accepts the legacy operator-before-input ordering (e.g. -flip) used below.
find_program(ImageMagick_convert_EXECUTABLE NAMES magick REQUIRED)
# Convert an image from some file format to EPS for inclusion in Latex using
# ImageMagick. This image is an input image. A separate macro is necessary
# because input images do not have any dependencies
Expand All @@ -30,7 +29,7 @@ foreach(ImageFile ${PNGandJPG_IMAGES})
set(OutputEPSFile "${OutputEPSFilePath}/${ImageFileNoExt}.eps")
add_custom_command(
OUTPUT ${OutputEPSFile}
COMMAND ${ImageMagick_convert_EXECUTABLE}
COMMAND ${ImageMagick_convert_EXECUTABLE} convert
${EPS_INPUT_CONVERT_FLAGS}
${ImageFile}
${EPS_OUTPUT_CONVERT_FLAGS}
Expand Down
3 changes: 1 addition & 2 deletions SoftwareGuide/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
# in PNG/XFIG/JPEG/EPS format.
#
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
cmake_policy(VERSION 3.22.1)

project(SoftwareGuide C)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH})

find_package(ITK 5 REQUIRED)
find_package(ITK 6 REQUIRED)

set(PDF_QUALITY_LEVEL "Screen" CACHE STRING "PDF Quality. Options are: Screen, Printer, PrePress")
#
Expand Down
5 changes: 2 additions & 3 deletions SoftwareGuide/Cover/Source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
cmake_policy(VERSION 3.10.2)
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)

project(VWSegmentation)

Expand All @@ -22,5 +21,5 @@ set( operations

foreach( operation ${operations} )
add_executable( ${operation} ${operation}.cxx )
target_link_libraries( ${operation} ${ITK_INTERFACE_LIBRARIES} )
target_link_libraries( ${operation} ${ITK_LIBRARIES} )
endforeach()
28 changes: 8 additions & 20 deletions SoftwareGuide/Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
cmake_policy(VERSION 3.22.1)

project(Examples C)

Expand Down Expand Up @@ -29,27 +28,16 @@ set(RUN_EXAMPLES_SCRIPT "${SoftwareGuide_SOURCE_DIR}/Examples/RunExamples.py" CA


#
# Find ImageMagick tools
# This is used to convert image formats
# Find ImageMagick 7. Its 'convert' subcommand accepts the legacy
# operator-before-input ordering used by the EPS conversion commands.
#
#
# Find ImageMagick tools
# This is used to convert image formats
#
#include(${CMAKE_ROOT}/Modules/FindImageMagick.cmake)
find_package(ImageMagick 6 COMPONENTS convert REQUIRED)
if(NOT ImageMagick_convert_EXECUTABLE)
message("ImageMagick convert utility was not found. Please pass to advanced mode and provide its full path")
endif()
find_program(ImageMagick_convert_EXECUTABLE NAMES magick REQUIRED)



#
# Find Python executable
find_package(PythonInterp)
if( NOT PYTHONINTERP_FOUND )
message(FATAL_ERROR "Python executable was not found")
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter)
set(PYTHONCXXPARSER ${SoftwareGuide_SOURCE_DIR}/Examples/ParseCxxExamples.py)
if( NOT EXISTS ${PYTHONCXXPARSER} )
message(FATAL_ERROR "Missing script: ${SoftwareGuide_SOURCE_DIR}/Examples/ParseCxxExamples.py")
Expand Down Expand Up @@ -80,10 +68,10 @@ find_path(ITK_EXECUTABLES_DIR
)

message(STATUS "PRE_RUN_PYTHON ART GENERATION.")
message(STATUS "Running: ${PYTHON_EXECUTABLE} ${RUN_EXAMPLES_SCRIPT} --itkSource ${ITK_SOURCE_DIR} --itkBuildDir ${ITK_BINARY_DIR} --itkExecDir ${ITK_EXECUTABLES_DIR} --SWGuidBaseOutput ${SoftwareGuide_BINARY_DIR} "
message(STATUS "Running: ${Python3_EXECUTABLE} ${RUN_EXAMPLES_SCRIPT} --itkSource ${ITK_SOURCE_DIR} --itkBuildDir ${ITK_BINARY_DIR} --itkExecDir ${ITK_EXECUTABLES_DIR} --SWGuidBaseOutput ${SoftwareGuide_BINARY_DIR} "
)
add_custom_target(RunExamples ALL
COMMAND ${PYTHON_EXECUTABLE}
COMMAND ${Python3_EXECUTABLE}
${RUN_EXAMPLES_SCRIPT}
--itkSource ${ITK_SOURCE_DIR}
--itkBuildDir ${ITK_BINARY_DIR}
Expand Down Expand Up @@ -269,7 +257,7 @@ macro(CONVERT_INPUT_IMG SOME_IMG EPS_IMG IMAGEMAGICK_FLAGS)
if( NOT DEFINED \${EPS_IMG}_HAS_CUSTOM_COMMAND)
message(STATUS \"Converting \${SOME_IMG}\")
execute_process(
COMMAND \"${ImageMagick_convert_EXECUTABLE}\" \${FLAGS} -quality 100 \${EPS_INPUT_CONVERT_FLAGS} \"\${SOME_IMG}\" \${EPS_OUTPUT_CONVERT_FLAGS} \"\${EPS_IMG}\"
COMMAND \"${ImageMagick_convert_EXECUTABLE}\" convert \${FLAGS} -quality 100 \${EPS_INPUT_CONVERT_FLAGS} \"\${SOME_IMG}\" \${EPS_OUTPUT_CONVERT_FLAGS} \"\${EPS_IMG}\"
OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/ConvertImagesToEPSOutput.txt
ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/ConvertImagesToEPSError.txt
RESULT_VARIABLE _result
Expand Down Expand Up @@ -300,7 +288,7 @@ foreach(example ${ITK_EXAMPLES_SRCS})
set(TEX_FILE ${SoftwareGuide_BINARY_DIR}/Examples/${TEX_FILE_BASE}.tex)
add_custom_command(
OUTPUT ${TEX_FILE}
COMMAND ${PYTHON_EXECUTABLE}
COMMAND ${Python3_EXECUTABLE}
ARGS ${PYTHONCXXPARSER} ${example} ${TEX_FILE}
DEPENDS ${PYTHONCXXPARSER} ${example} ${${TEX_FILE_BASE}-DEPS}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ \subsection{CMakeLists.txt}
set(MyModule_LIBRARIES MyModule)

if(NOT ITK_SOURCE_DIR)
find_package(ITK 5 REQUIRED)
find_package(ITK 6 REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
include(ITKModuleExternal)
else()
Expand Down
28 changes: 3 additions & 25 deletions SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ include(CTest)
include(${CMAKE_CURRENT_SOURCE_DIR}/Common.cmake)

#-----------------------------------------------------------------------------
# Git protocole option
# External project clones use https (the git:// protocol was retired by GitHub).
#-----------------------------------------------------------------------------
option(${CMAKE_PROJECT_NAME}_USE_GIT_PROTOCOL "If behind a firewall turn this off to use http instead." OFF)
set(git_protocol "git")
if(NOT ${CMAKE_PROJECT_NAME}_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()
set(git_protocol "https")

find_package(Git REQUIRED)

Expand All @@ -40,32 +36,14 @@ endif()
# For earlier versions, we nullify the update state to prevent updates and
# undesirable rebuild.
option(FORCE_EXTERNAL_BUILDS "Force rebuilding of external project (if they are updated)" OFF)
if(CMAKE_VERSION VERSION_LESS 2.8.9 OR NOT FORCE_EXTERNAL_BUILDS)
if(NOT FORCE_EXTERNAL_BUILDS)
set(cmakeversion_external_update UPDATE_COMMAND)
set(cmakeversion_external_update_value "" )
else()
set(cmakeversion_external_update LOG_UPDATE )
set(cmakeversion_external_update_value 1)
endif()

#-----------------------------------------------------------------------------
# Platform check
#-----------------------------------------------------------------------------

set(PLATFORM_CHECK true)

if(PLATFORM_CHECK)
# See CMake/Modules/Platform/Darwin.cmake)
# 6.x == Mac OSX 10.2 (Jaguar)
# 7.x == Mac OSX 10.3 (Panther)
# 8.x == Mac OSX 10.4 (Tiger)
# 9.x == Mac OSX 10.5 (Leopard)
# 10.x == Mac OSX 10.6 (Snow Leopard)
if (DARWIN_MAJOR_VERSION LESS "9")
message(FATAL_ERROR "Only Mac OSX >= 10.5 are supported !")
endif()
endif()

#-----------------------------------------------------------------------------
# Superbuild option(s)
#-----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions SuperBuild/External_ITK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ProjectDependancyPush(CACHED_proj ${proj})
# SlicerMacroCheckExternalProjectDependency
set(extProjName ITK) #The find_package known name
set(proj ITK) #This local name
set(${extProjName}_REQUIRED_VERSION 4) #If a required version is necessary, then set this, else leave blank
set(${extProjName}_REQUIRED_VERSION 6) #If a required version is necessary, then set this, else leave blank

#if(${USE_SYSTEM_${extProjName}})
# unset(${extProjName}_DIR CACHE)
Expand Down Expand Up @@ -82,7 +82,7 @@ if(NOT ( DEFINED "${extProjName}_DIR" OR ( DEFINED "USE_SYSTEM_${extProjName}" A
# HACK This code fixes a loony problem with HDF5 -- it doesn't
# link properly if -fopenmp is used.
string(REPLACE "-fopenmp" "" ITK_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-fopenmp" "" ITK_CMAKE_CXX_FLAGS "${CMAKE_CX_FLAGS}")
string(REPLACE "-fopenmp" "" ITK_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

string(REPLACE ";" "^^" CMAKE_JOB_POOLS_ARG "${CMAKE_JOB_POOLS}")

Expand Down
3 changes: 1 addition & 2 deletions SuperBuild/External_RunExamples.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ if( NOT USE_SYSTEM_ITK)
set(${proj}_DEPENDENCIES ITK)
else()
set(${proj}_DEPENDENCIES "")
find_package(ITK 5 REQUIRED ITKReview )
include(${ITK_USE_FILE})
find_package(ITK 6 REQUIRED COMPONENTS ITKReview)
endif()

# Include dependent projects if any
Expand Down
18 changes: 18 additions & 0 deletions Utilities/Hooks/chktex-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Advisory LaTeX lint via chktex for staged .tex files.
# Never blocks the commit; prints findings so the author can fix new prose.
# Ignore-code policy mirrors Utilities/latex_linter.sh, plus 27 (cannot resolve
# \input across files) which is unavoidable noise when linting one staged file.

command -v chktex >/dev/null 2>&1 || {
echo "chktex not found on PATH (install TeX Live / MacTeX); skipping LaTeX lint." >&2
exit 0
}

IGNORE_WARNING_CODES="-n 1 -n 3 -n 8 -n 12 -n 13 -n 27 -n 36 -n 37"

# Filter the "Unable to open the TeX file" banner: per-file linting cannot see
# \input targets that live in the build tree, and that banner is not a finding.
chktex ${IGNORE_WARNING_CODES} --quiet "$@" 2>&1 |
grep -v 'Unable to open the TeX file' || true
exit 0
Loading
Loading