Skip to content

STYLE: Add SPDX license identifiers to all ITK source files#6063

Merged
hjmjohnson merged 0 commit intoInsightSoftwareConsortium:copilot/generate-sbom-at-build-timefrom
hjmjohnson:spdx-file-headers
Apr 18, 2026
Merged

STYLE: Add SPDX license identifiers to all ITK source files#6063
hjmjohnson merged 0 commit intoInsightSoftwareConsortium:copilot/generate-sbom-at-build-timefrom
hjmjohnson:spdx-file-headers

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Add machine-readable SPDX headers to all 5,503 ITK-owned source files following VTK's convention. This completes Phase 2 of the SBOM roadmap (#4302), complementing the SBOM generation in #5817.

Format (matching VTK)

C/C++ files:

// SPDX-FileCopyrightText: Copyright NumFOCUS
// SPDX-License-Identifier: Apache-2.0
/*=========================================================================
 *  Copyright NumFOCUS
 *  ...existing Apache-2.0 block...
 *=========================================================================*/

Python files:

# SPDX-FileCopyrightText: Copyright NumFOCUS
# SPDX-License-Identifier: Apache-2.0
# ==========================================================================
#   Copyright NumFOCUS
#   ...existing Apache-2.0 block...
Scope
  • 5,503 files modified (.h, .hxx, .cxx, .txx, .py, .cmake, CMakeLists.txt)
  • Only files containing "Copyright NumFOCUS" are touched
  • ThirdParty code is excluded
  • Utilities/KWStyle/ITKHeader.h template updated to enforce SPDX on new files
  • Migration script at Utilities/Maintenance/AddSPDXHeaders.py for reuse
Why both SPDX lines and existing header?

The existing 17-line Apache-2.0 block is the human-readable legal notice. The SPDX lines are the machine-readable equivalent, parseable by REUSE, scancode-toolkit, fossology, and other license compliance tools. Both forms are standard practice — VTK, CMake, KDE, and FSFE projects use this dual approach.

@hjmjohnson hjmjohnson requested a review from dzenanz April 15, 2026 02:04
@github-actions github-actions Bot added the type:Style Style changes: no logic impact (indentation, comments, naming) label Apr 15, 2026
@hjmjohnson hjmjohnson force-pushed the spdx-file-headers branch 2 times, most recently from 21b931c to 1d05a10 Compare April 15, 2026 11:33
@hjmjohnson hjmjohnson marked this pull request as ready for review April 15, 2026 14:43
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 15, 2026

Too many files changed for review. (3000 files found, 100 file limit)

@hjmjohnson hjmjohnson marked this pull request as draft April 15, 2026 19:36
@hjmjohnson hjmjohnson force-pushed the spdx-file-headers branch 3 times, most recently from 929f4ff to 99398c8 Compare April 17, 2026 01:43
@hjmjohnson hjmjohnson changed the base branch from main to copilot/generate-sbom-at-build-time April 17, 2026 01:43
@hjmjohnson hjmjohnson force-pushed the copilot/generate-sbom-at-build-time branch from b765be7 to 2dee212 Compare April 17, 2026 08:56
@hjmjohnson hjmjohnson force-pushed the spdx-file-headers branch 2 times, most recently from 4229b7d to 8a49700 Compare April 18, 2026 12:42
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Apr 18, 2026
Adds Utilities/Maintenance/AddSPDXHeaders.py: a Python 3.10+ script
that prepends the two SPDX lines

    // SPDX-FileCopyrightText: Copyright NumFOCUS
    // SPDX-License-Identifier: Apache-2.0

to ITK-owned source files following VTK's convention. Python, CMake,
and shell files use the equivalent `#`-prefix syntax.

This is the tool that produced the 5,698-file diff in the companion
PR InsightSoftwareConsortium#6063. The script is idempotent, skips files that already carry
an SPDX header, and handles the following edge cases:

 * shebang preservation (Python scripts)
 * UTF-8 BOM preservation (BOM stays at byte 0)
 * CRLF line-ending detection and preservation
 * needs_spdx() scans only the first 50 lines so scripts that
   legitimately mention SPDX-License-Identifier in their docstrings
   (including this script itself) are correctly identified

Usage modes:

    # Walk the whole ITK source tree:
    python3 AddSPDXHeaders.py [--dry-run] [ITK_SOURCE_DIR]

    # Operate on a specific file list (for pre-commit integration):
    python3 AddSPDXHeaders.py --files <file1> <file2> ...

    # Check-only mode: exit non-zero if any file needs SPDX:
    python3 AddSPDXHeaders.py --check --files <file1> <file2> ...

Hooking the script into pre-commit comes in a subsequent commit.
The matching KWStyle template update landed with the per-file SPDX
tagging in PR InsightSoftwareConsortium#6063.
@hjmjohnson hjmjohnson merged commit 8a49700 into InsightSoftwareConsortium:copilot/generate-sbom-at-build-time Apr 18, 2026
1 of 9 checks passed
@hjmjohnson hjmjohnson force-pushed the copilot/generate-sbom-at-build-time branch from 2dee212 to 61332b1 Compare April 18, 2026 12:43
@hjmjohnson
Copy link
Copy Markdown
Member Author

This PR was auto-closed as "merged" by GitHub when a force-push to hjmjohnson:spdx-file-headers (during a cleanup-phase-1 reorganization) made its head an ancestor of the updated base branch copilot/generate-sbom-at-build-time. No content from this PR landed in main — the closure is a GitHub artifact of the branch-rewrite cascade, not a real merge.

Replaced by #6084 — same content (bulk SPDX tagging on 5,698 files + KWStyle template update), now correctly targeting main and paired with the reorganized #5817 (SBOM infrastructure).

All review discussion should move to #6084.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Style Style changes: no logic impact (indentation, comments, naming)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant