Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
cmake: generate the complete .config at configuration time.#3821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,105 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Kconfig targets | ||
| include(${CMAKE_CURRENT_LIST_DIR}/defconfigs.cmake) | ||
| ### configure-time .config ### | ||
| if(NOT INIT_CONFIG_found) | ||
xiulipan marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| # 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") | ||
xiulipan marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| # - ".' 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 " | ||
xiulipan marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| "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 | ||
| @@ -33,24 +129,9 @@ add_custom_target( | ||
| file(GLOB_RECURSE KCONFIG_FILES "${SOF_ROOT_SOURCE_DIRECTORY}/Kconfig") | ||
| if(EXISTS ${DOT_CONFIG_PATH}) | ||
| # Update with olddefconfig only if config was previously generated | ||
| add_custom_command( | ||
| OUTPUT ${DOT_CONFIG_PATH} | ||
| 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 | ||
| DEPENDS ${KCONFIG_FILES} | ||
| WORKING_DIRECTORY ${GENERATED_DIRECTORY} | ||
| COMMENT "Regenerating .config with olddefconfig" | ||
| VERBATIM | ||
| USES_TERMINAL | ||
| ) | ||
| endif() | ||
| # 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this for make
xxx_defconfig?As we must provide a
INIT_CONFIGin CMAKE stageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a few reasons not to delete support for all the
make xxxconfigtargets:make xxxconfigis short and reconfigures only.config. No need for a very long CMake command line with TOOLCHAIN, ROOT_DIR etc.