1# SPDX-License-Identifier: BSD-3-Clause 2 3# Looks for defconfig files in arch directories where kconfig.cmake looks too. 4set(DEFCONFIGS_DIRECTORY "${PROJECT_SOURCE_DIR}/src/arch/${ARCH}/configs") 5file(GLOB DEFCONFIG_PATHS "${DEFCONFIGS_DIRECTORY}/*_defconfig") 6 7# Adds dependency on defconfigs directory 8set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${DEFCONFIGS_DIRECTORY}) 9 10# Adds target for every defconfig, so you we can use it like make *_defconfig 11foreach(defconfig_path ${DEFCONFIG_PATHS}) 12 get_filename_component(defconfig_name ${defconfig_path} NAME) 13 add_custom_target( 14 ${defconfig_name} 15 COMMAND ${CMAKE_COMMAND} -E copy 16 ${defconfig_path} 17 ${DOT_CONFIG_PATH} 18 COMMAND ${CMAKE_COMMAND} -E env 19 srctree=${PROJECT_SOURCE_DIR} 20 CC_VERSION_TEXT=${CC_VERSION_TEXT} 21 ARCH=${ARCH} 22 ${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/olddefconfig.py 23 ${PROJECT_SOURCE_DIR}/Kconfig 24 WORKING_DIRECTORY ${GENERATED_DIRECTORY} 25 COMMENT "Applying olddefconfig with ${defconfig_name}" 26 VERBATIM 27 USES_TERMINAL 28 ) 29endforeach() 30 31set(OVERRIDE_DEFCONFIGS_DIRECTORY "${DEFCONFIGS_DIRECTORY}/override") 32file(GLOB OVERRIDE_DEFCONFIGS_PATHS "${OVERRIDE_DEFCONFIGS_DIRECTORY}/*.config") 33 34foreach(config_path ${OVERRIDE_DEFCONFIGS_PATHS}) 35 get_filename_component(config_name ${config_path} NAME_WE) 36 add_custom_target( 37 "${config_name}_overridedefconfig" 38 COMMAND ${CMAKE_COMMAND} -E copy 39 ${config_path} 40 ${PROJECT_BINARY_DIR}/override.config 41 COMMAND ${CMAKE_COMMAND} -E env 42 srctree=${PROJECT_SOURCE_DIR} 43 CC_VERSION_TEXT=${CC_VERSION_TEXT} 44 ARCH=${ARCH} 45 ${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/overrideconfig.py 46 ${PROJECT_SOURCE_DIR}/Kconfig 47 ${PROJECT_BINARY_DIR}/override.config 48 WORKING_DIRECTORY ${GENERATED_DIRECTORY} 49 COMMENT "Applying overrideconfig with ${config_name}" 50 VERBATIM 51 USES_TERMINAL 52 ) 53endforeach() 54