1# SPDX-License-Identifier: BSD-3-Clause 2 3# Links git hooks, if there are no other hooks already 4 5if(NOT EXISTS "${SOF_ROOT_SOURCE_DIRECTORY}/.git") 6 return() 7endif() 8 9if(NOT CMAKE_HOST_UNIX) 10 execute_process( 11 COMMAND sh -c echo 12 RESULT_VARIABLE sh_result 13 OUTPUT_QUIET 14 ERROR_QUIET 15 ) 16 17 if(NOT (sh_result STREQUAL "0")) 18 return() 19 endif() 20endif() 21 22set(pre_commit_hook "${SOF_ROOT_SOURCE_DIRECTORY}/.git/hooks/pre-commit") 23set(post_commit_hook "${SOF_ROOT_SOURCE_DIRECTORY}/.git/hooks/post-commit") 24 25if(NOT EXISTS ${pre_commit_hook}) 26 message(STATUS "Linking git pre-commit hook") 27 execute_process(COMMAND ln -s -f -T ../../scripts/sof-pre-commit-hook.sh ${pre_commit_hook}) 28endif() 29 30if(NOT EXISTS ${post_commit_hook}) 31 message(STATUS "Linking git post-commit hook") 32 execute_process(COMMAND ln -s -f -T ../../scripts/sof-post-commit-hook.sh ${post_commit_hook}) 33endif() 34