mirror of
https://github.com/microsoft/WSL.git
synced 2026-04-10 16:43:40 -05:00
* Replace pre-commit hook with CMake-generated clang-format check Replace the old pre-commit hook that shelled out to PowerShell and never blocked commits (-NoFail) with a CMake-generated hook that calls clang-format directly on staged C/C++ files. - Add tools/hooks/pre-commit.in as a CMake template - CMake resolves the clang-format path at configure time via LLVM_INSTALL_DIR, matching the existing FormatSource.ps1.in pattern - Hook blocks commits on formatting errors, skips gracefully if clang-format is not available (cmake not yet run) - ~5x faster than the old PowerShell approach (~0.5s vs ~2.6s) * Make pre-commit hook behavior configurable via WSL_PRE_COMMIT_MODE Add WSL_PRE_COMMIT_MODE CMake cache variable with three modes: - warn (default): report formatting issues without blocking commit - error: block commit when formatting issues are found - fix: auto-format files and re-stage them Also addresses PR feedback: - Generate hook into build tree, copy to source tree for out-of-source builds - Use repo-local tools/clang-format.exe instead of LLVM_INSTALL_DIR path - Use @ONLY in configure_file to avoid shell variable substitution issues - Document modes in dev-loop.md and UserConfig.cmake.sample Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
53 lines
3.0 KiB
Plaintext
53 lines
3.0 KiB
Plaintext
# Sample user configuration
|
|
|
|
message(STATUS "Loading user configuration")
|
|
|
|
# Uncomment to enable development packages (smaller, faster to install)
|
|
# # Note: .vhd files fail to mount via symlink / hardlink, so COPY is needed.
|
|
# set(WSL_DEV_BINARY_PATH "C:/wsldev")
|
|
|
|
if(WSL_DEV_BINARY_PATH)
|
|
file(MAKE_DIRECTORY ${WSL_DEV_BINARY_PATH})
|
|
file(CREATE_LINK "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/kernel" "${WSL_DEV_BINARY_PATH}/kernel" SYMBOLIC)
|
|
file(COPY_FILE "${WSLG_SOURCE_DIR}/${TARGET_PLATFORM}/system.vhd" "${WSL_DEV_BINARY_PATH}/system.vhd" ONLY_IF_DIFFERENT)
|
|
file(COPY_FILE "${KERNEL_SOURCE_DIR}/bin/${TARGET_PLATFORM}/modules.vhd" "${WSL_DEV_BINARY_PATH}/modules.vhd" ONLY_IF_DIFFERENT)
|
|
|
|
# read-only VHDs need to be world readable to mount successfully.
|
|
execute_process(
|
|
COMMAND icacls.exe "${WSL_DEV_BINARY_PATH}/system.vhd" "/grant:r" "Everyone:(R)" /Q
|
|
COMMAND icacls.exe "${WSL_DEV_BINARY_PATH}/modules.vhd" "/grant:r" "Everyone:(R)" /Q
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|
COMMAND_ERROR_IS_FATAL ANY)
|
|
|
|
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/msrdc.exe" "${WSL_DEV_BINARY_PATH}/msrdc.exe" SYMBOLIC)
|
|
file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg.rdp" "${WSL_DEV_BINARY_PATH}/wslg.rdp" SYMBOLIC)
|
|
file(CREATE_LINK "${WSLG_SOURCE_DIR}/wslg_desktop.rdp" "${WSL_DEV_BINARY_PATH}/wslg_desktop.rdp" SYMBOLIC)
|
|
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdclientax.dll" "${WSL_DEV_BINARY_PATH}/rdclientax.dll" SYMBOLIC)
|
|
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdpnanoTransport.dll" "${WSL_DEV_BINARY_PATH}/rdpnanoTransport.dll" SYMBOLIC)
|
|
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/RdpWinStlHelper.dll" "${WSL_DEV_BINARY_PATH}/RdpWinStlHelper.dll" SYMBOLIC)
|
|
file(CREATE_LINK "${MSAL_SOURCE_DIR}/${TARGET_PLATFORM}/msal.wsl.proxy.exe" "${WSL_DEV_BINARY_PATH}/msal.wsl.proxy.exe" SYMBOLIC)
|
|
file(CREATE_LINK "${DIRECT3D_SOURCE_DIR}/lib/${TARGET_PLATFORM}" "${WSL_DEV_BINARY_PATH}/lib" SYMBOLIC)
|
|
|
|
foreach(LANG ${SUPPORTED_LANGS})
|
|
file(CREATE_LINK "${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/${LANG}" "${WSL_DEV_BINARY_PATH}/${LANG}" SYMBOLIC)
|
|
endforeach()
|
|
endif()
|
|
|
|
# # Uncomment to skip building, packaging and installing wslsettings
|
|
# set(WSL_BUILD_WSL_SETTINGS false)
|
|
|
|
# # Uncomment to generate a "thin" MSI package which builds and installs faster
|
|
# set(WSL_BUILD_THIN_PACKAGE true)
|
|
|
|
# # Uncomment to install the package as part of the build
|
|
# set(WSL_POST_BUILD_COMMAND "powershell;-ExecutionPolicy;Bypass;-NoProfile;-NonInteractive;./tools/deploy/deploy-to-host.ps1")
|
|
|
|
# # Uncomment to reduce the verbosity of the appx package build
|
|
# set(WSL_SILENT_APPX_BUILD true)
|
|
|
|
# # Uncomment to change the pre-commit hook behavior (default: warn)
|
|
# # warn - report formatting issues without blocking the commit
|
|
# # error - block the commit when formatting issues are found
|
|
# # fix - automatically fix formatting and re-stage files
|
|
# set(WSL_PRE_COMMIT_MODE "warn")
|