forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkconfig.cmake
More file actions
192 lines (164 loc) · 5.33 KB
/
kconfig.cmake
File metadata and controls
192 lines (164 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# SPDX-License-Identifier: BSD-3-Clause
include(${CMAKE_CURRENT_LIST_DIR}/defconfigs.cmake)
### configure-time .config ###
if(NOT INIT_CONFIG_found)
# Brand new build directory, search for initial configuration
# Default value when no -DINIT_CONFIG on the command line
set(INIT_CONFIG "initial.config" CACHE STRING "Initial .config file")
# - ".' is the top source directory.
# - "src/arch/${arch}/configs" is for convenience and compatibility with
# defconfigs.cmake.
# - First found wins.
# - If two archs ever use the same platform_defconfig name then a full
# path must be used, e.g.: -DINIT_CONFIG=src/arch/myarch/collision_defconfig
set(init_config_search_list ".")
foreach(arch "xtensa" "host")
list(APPEND init_config_search_list "src/arch/${arch}/configs")
endforeach()
find_file(INIT_CONFIG_found
NAMES ${INIT_CONFIG}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH
PATHS ${init_config_search_list}
)
else() # old build directory
if (INIT_CONFIG)
message(WARNING
"IGNORING '-DINIT_CONFIG=${INIT_CONFIG}!!' "
"Using up-to-date ${INIT_CONFIG_found} instead."
)
endif()
endif() # new/old build directory
if(NOT INIT_CONFIG_found)
message(FATAL_ERROR
"Initial configuration missing, no ${INIT_CONFIG} found. "
"Provide a ${PROJECT_SOURCE_DIR}/initial.config file or specify some "
"other -DINIT_CONFIG=location relative to '${PROJECT_SOURCE_DIR}/' or "
"'${PROJECT_SOURCE_DIR}/src/arch/*/configs/'"
)
endif()
# Did someone or something remove our generated/.config?
if(NOT EXISTS ${INIT_CONFIG_found})
message(FATAL_ERROR "The file ${INIT_CONFIG_found} vanished!")
endif()
# Don't confuse this configure-time, .config generation with
# the build-time, autoconfig.h genconfig target below
message(STATUS
"(Re-)generating ${DOT_CONFIG_PATH}\n"
" and ${CONFIG_H_PATH}\n"
" from ${INIT_CONFIG_found}"
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E env
KCONFIG_CONFIG=${INIT_CONFIG_found}
srctree=${PROJECT_SOURCE_DIR}
CC_VERSION_TEXT=${CC_VERSION_TEXT}
ARCH=${ARCH}
${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/genconfig.py
--config-out=${DOT_CONFIG_PATH}
--header-path ${CONFIG_H_PATH}
${PROJECT_SOURCE_DIR}/Kconfig
WORKING_DIRECTORY ${GENERATED_DIRECTORY}
# Available only from CMake 3.18. Amazingly not the default.
# COMMAND_ERROR_IS_FATAL ANY
RESULT_VARIABLE _genret
)
if(${_genret})
message(FATAL_ERROR
"genconfig.py from ${INIT_CONFIG_found} to ${DOT_CONFIG_PATH} failed")
endif()
if(NOT ${INIT_CONFIG_found} STREQUAL ${DOT_CONFIG_PATH})
# Brand new build directory and config.
message(STATUS
"Done, future changes to ${INIT_CONFIG_found}\n"
" will be IGNORED by this build directory! The primary .config\n"
" file is now 'generated/.config' in the build directory."
)
endif()
# Now force CMake to forget about the initial config and to re-use our
# own private ${DOT_CONFIG_PATH} when it decides it must re-run itself.
unset(INIT_CONFIG CACHE)
set(INIT_CONFIG_found ${DOT_CONFIG_PATH} CACHE FILEPATH "active .config" FORCE)
### build-time Kconfig targets ###
add_custom_target(
menuconfig
COMMAND ${CMAKE_COMMAND} -E env
srctree=${PROJECT_SOURCE_DIR}
CC_VERSION_TEXT=${CC_VERSION_TEXT}
ARCH=${ARCH}
${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/menuconfig.py
${PROJECT_SOURCE_DIR}/Kconfig
WORKING_DIRECTORY ${GENERATED_DIRECTORY}
VERBATIM
USES_TERMINAL
)
add_custom_target(
overrideconfig
COMMAND ${CMAKE_COMMAND} -E env
srctree=${PROJECT_SOURCE_DIR}
CC_VERSION_TEXT=${CC_VERSION_TEXT}
ARCH=${ARCH}
${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/overrideconfig.py
${PROJECT_SOURCE_DIR}/Kconfig
${PROJECT_BINARY_DIR}/override.config
WORKING_DIRECTORY ${GENERATED_DIRECTORY}
VERBATIM
USES_TERMINAL
)
file(GLOB_RECURSE KCONFIG_FILES "${SOF_ROOT_SOURCE_DIRECTORY}/Kconfig")
# Don't confuse this build-time, .h target with the
# configure-time, .config genconfig above.
add_custom_command(
OUTPUT ${CONFIG_H_PATH}
COMMAND ${CMAKE_COMMAND} -E env
srctree=${PROJECT_SOURCE_DIR}
CC_VERSION_TEXT=${CC_VERSION_TEXT}
ARCH=${ARCH}
${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/genconfig.py
--header-path ${CONFIG_H_PATH}
${PROJECT_SOURCE_DIR}/Kconfig
DEPENDS ${DOT_CONFIG_PATH}
WORKING_DIRECTORY ${GENERATED_DIRECTORY}
COMMENT "Generating ${CONFIG_H_PATH}"
VERBATIM
USES_TERMINAL
)
add_custom_target(genconfig DEPENDS ${CONFIG_H_PATH})
add_custom_target(
olddefconfig
COMMAND ${CMAKE_COMMAND} -E env
srctree=${PROJECT_SOURCE_DIR}
CC_VERSION_TEXT=${CC_VERSION_TEXT}
ARCH=${ARCH}
${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/olddefconfig.py
${PROJECT_SOURCE_DIR}/Kconfig
WORKING_DIRECTORY ${GENERATED_DIRECTORY}
VERBATIM
USES_TERMINAL
)
add_custom_target(
alldefconfig
COMMAND ${CMAKE_COMMAND} -E env
srctree=${PROJECT_SOURCE_DIR}
CC_VERSION_TEXT=${CC_VERSION_TEXT}
ARCH=${ARCH}
${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/alldefconfig.py
${PROJECT_SOURCE_DIR}/Kconfig
WORKING_DIRECTORY ${GENERATED_DIRECTORY}
VERBATIM
USES_TERMINAL
)
add_custom_target(
savedefconfig
COMMAND ${CMAKE_COMMAND} -E env
srctree=${PROJECT_SOURCE_DIR}
CC_VERSION_TEXT=${CC_VERSION_TEXT}
ARCH=${ARCH}
${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/savedefconfig.py
${PROJECT_SOURCE_DIR}/Kconfig
${PROJECT_BINARY_DIR}/defconfig
WORKING_DIRECTORY ${GENERATED_DIRECTORY}
COMMENT "Saving minimal configuration to: ${PROJECT_BINARY_DIR}/defconfig"
VERBATIM
USES_TERMINAL
)