Skip to content

Commit bc8b850

Browse files
hjmjohnsonclaude
andcommitted
COMP: Shorten Windows build root to stay under ITK path limit
Instead of unconditionally skipping ITK's path length checks, shorten the build directory path on Windows using a directory junction. The repo name is stripped of its "ITK" prefix and truncated to 12 characters (e.g. ITKFixedPointInverseDisplacementField → FixedPointIn), then a junction D:\<short> → D:\a\<full-repo-name> provides a short root for ITK clone, build, and CTest dashboard directories. This keeps ITK's 50-character path validation active as a safety check while ensuring long-named remote module repos can build on Windows CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c423d5b commit bc8b850

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

.github/workflows/build-test-cxx.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ jobs:
7676
steps:
7777
- uses: actions/checkout@v4
7878

79+
- name: Shorten build root
80+
shell: bash
81+
run: |
82+
# Strip "ITK" prefix and truncate to 12 chars to keep
83+
# Windows build paths under ITK's 50-character limit.
84+
# e.g. ITKFixedPointInverseDisplacementField → FixedPointIn
85+
REPO_NAME="${GITHUB_REPOSITORY##*/}"
86+
SHORT_NAME="${REPO_NAME#ITK}"
87+
SHORT_NAME="${SHORT_NAME:0:12}"
88+
WS_PARENT="$(cd "${GITHUB_WORKSPACE}/.." && pwd)"
89+
echo "ITK_SHORT_NAME=${SHORT_NAME}" >> "$GITHUB_ENV"
90+
echo "ITK_BUILD_ROOT=${WS_PARENT}" >> "$GITHUB_ENV"
91+
92+
- name: Create short build root junction (Windows)
93+
if: runner.os == 'Windows'
94+
shell: pwsh
95+
run: |
96+
$target = Split-Path $env:GITHUB_WORKSPACE
97+
$shortRoot = "D:\$env:ITK_SHORT_NAME"
98+
if (-not (Test-Path $shortRoot)) {
99+
cmd /c mklink /J $shortRoot $target
100+
}
101+
echo "ITK_BUILD_ROOT=$shortRoot" | Out-File -Append -FilePath $env:GITHUB_ENV
102+
79103
- name: Free Disk Space (Ubuntu)
80104
if: matrix.os == 'ubuntu-22.04'
81105
uses: jlumbroso/free-disk-space@v1.3.1
@@ -118,7 +142,7 @@ jobs:
118142
119143
- name: Download ITK
120144
run: |
121-
cd ..
145+
cd "$ITK_BUILD_ROOT"
122146
git clone https://github.com/InsightSoftwareConsortium/ITK.git
123147
cd ITK
124148
git checkout ${{ inputs.itk-git-tag }}
@@ -127,7 +151,7 @@ jobs:
127151
if: matrix.os != 'windows-2022'
128152
shell: bash
129153
run: |
130-
cd ..
154+
cd "$ITK_BUILD_ROOT"
131155
mkdir ITK-build
132156
cd ITK-build
133157
MODULE_ARGS=""
@@ -152,7 +176,7 @@ jobs:
152176
shell: pwsh
153177
run: |
154178
Set-PSDebug -Trace 1
155-
cd ..
179+
cd $env:ITK_BUILD_ROOT
156180
& "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation
157181
mkdir ITK-build
158182
cd ITK-build
@@ -187,9 +211,9 @@ jobs:
187211
operating_system="${{ matrix.os }}"
188212
cat > dashboard.cmake << EOF
189213
set(CTEST_SITE "GitHubActions")
190-
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/.." CTEST_DASHBOARD_ROOT)
214+
file(TO_CMAKE_PATH "\$ENV{ITK_BUILD_ROOT}" CTEST_DASHBOARD_ROOT)
191215
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/" CTEST_SOURCE_DIRECTORY)
192-
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY)
216+
file(TO_CMAKE_PATH "\$ENV{ITK_BUILD_ROOT}/build" CTEST_BINARY_DIRECTORY)
193217
set(dashboard_source_name "${GITHUB_REPOSITORY}")
194218
if((ENV{GITHUB_REF_NAME} MATCHES "master" OR ENV{GITHUB_REF_NAME} MATCHES "main"))
195219
set(branch "-master")

0 commit comments

Comments
 (0)