Skip to content

Commit c0454b9

Browse files
authored
Add check for path limit in Windows (#2472)
***NO_CI***
1 parent f5983cc commit c0454b9

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

CMake/binutils.common.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,3 +672,23 @@ macro(nf_clear_common_output_files_nanoclr)
672672
)
673673

674674
endmacro()
675+
676+
# function to check the path limit in Windows
677+
function(nf_check_path_limits)
678+
679+
# only need to check in Windows
680+
if (WIN32)
681+
set(FILESYSTEM_REG_PATH "HKLM\\SYSTEM\\CurrentControlSet\\Control\\FileSystem")
682+
683+
cmake_host_system_information(RESULT WIN_LONG_PATH_OPTION QUERY WINDOWS_REGISTRY ${FILESYSTEM_REG_PATH} VALUE LongPathsEnabled)
684+
if(${WIN_LONG_PATH_OPTION} EQUAL 0)
685+
message(STATUS "******* WARNING ******\n\nWindows path limit is too short.\nPlease enable long paths in Windows registry.\nSee https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later\n\n")
686+
687+
# try setting limits to overcome this
688+
set(CMAKE_OBJECT_PATH_MAX 260)
689+
set(CMAKE_OBJECT_NAME_MAX 255)
690+
endif()
691+
692+
endif()
693+
694+
endfunction()

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
3737
include(binutils.common)
3838
include(binutils.ESP32)
3939

40+
nf_check_path_limits()
41+
4042
######################################################
4143
# set build type to release if not specified otherwise
4244
if(NOT CMAKE_BUILD_TYPE)

azure-pipelines-templates/build-preparations.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ steps:
1818
}
1919
errorActionPreference: 'stop'
2020
failOnStderr: 'true'
21+
22+
- task: PowerShell@2
23+
displayName: Enable long paths
24+
inputs:
25+
targetType: 'inline'
26+
script: New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

azure-pipelines-templates/download-install-esp32-build-components.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ steps:
7373
# need to access the PATH collection, which seems to always be the last on in the collection
7474
$varsCount = $envars_raw.Count
7575
# go through the output and grab what has to be appended to the PATH
76-
# need to remove the entry for IDF CMake because it's using an older version of CMake, OK to remove after they update it to >2.23.0
77-
$newPath = $envars_raw[$varsCount - 1].ToString().Replace('PATH=', '').Replace(';%PATH%', '').Replace('C:\Users\VssAdministrator\.espressif\tools\cmake\3.20.3\bin;', '')
76+
# need to remove the entry for IDF CMake because it's using an older version of CMake, OK to remove after they update it to >3.24.0
77+
$newPath = $envars_raw[$varsCount - 1].ToString().Replace('PATH=', '').Replace(';%PATH%', '').Replace('C:\Users\VssAdministrator\.espressif\tools\cmake\3.23.1\bin;', '')
7878
7979
# append to path
8080
Write-Host "##vso[task.prependpath]$newPath"

0 commit comments

Comments
 (0)