Repository navigation
buildsystem: kconfig and cmake #845
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
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
04bb58a
kconfig: add Kconfiglib
jajanusz 0e5ae01
kconfig: add initial Kconfig files
jajanusz b8810aa
cmake: add utility scripts
jajanusz 6cc9972
cmake: version script
jajanusz 230f326
cmake: add CMakeLists for firmware build
jajanusz 02ab869
rimage: remove config.h dependency
jajanusz b329d09
cmake: add rimage build
jajanusz d02e7af
cmake: bootloader build and meu support
jajanusz d64f9bd
cmake: add testbench host build
jajanusz 2361c7d
cmake: add CMakeLists for unit tests
jajanusz b1c022c
test: debugability: fix for full paths
jajanusz 342bf32
cmake: add doc CMakeLists
jajanusz cff2cf2
cmake: defconfigs support
jajanusz 7e29a01
buildsystem: remove autotools from sof
jajanusz c201b59
cmake: add overrideconfig
jajanusz c7590d5
cmake: vm rom build
jajanusz 3059d46
cmake: debug build support
jajanusz 3bb75f9
cmake: update xtensa-build-all.sh
jajanusz d2c4f8f
cmake: update host-build-all.sh
jajanusz e80713b
cmake: update qemu-check.sh
jajanusz fa3bc5a
icl: increase text section size
jajanusz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| cmake_minimum_required(VERSION 3.10) | ||
|
|
||
| if(NOT (${CMAKE_VERSION} VERSION_LESS "3.13.0")) | ||
| # CMake 3.13+ has less restrictive rules for target_link_libraries() | ||
| # Until we make 3.13 as required minimum version we want to | ||
| # use old behaviour for compatibility | ||
| cmake_policy(SET CMP0079 OLD) | ||
| endif() | ||
|
|
||
| # TODO: take `host` out of fw build | ||
| option(BUILD_HOST "Build host program" OFF) | ||
| option(BUILD_UNIT_TESTS "Build unit tests" OFF) | ||
|
|
||
| if(BUILD_HOST) | ||
| set(ARCH host) | ||
| else() | ||
| # firmware build supports only xtensa arch for now | ||
| set(ARCH xtensa) | ||
| endif() | ||
|
|
||
| # let user override built-in toolchains | ||
| if(DEFINED CMAKE_TOOLCHAIN_FILE) | ||
| set(TOOLCHAIN "${CMAKE_TOOLCHAIN_FILE}") | ||
| else() | ||
| include(scripts/cmake/${ARCH}-toolchain.cmake OPTIONAL) | ||
| endif() | ||
|
|
||
| include(scripts/cmake/misc.cmake) | ||
|
|
||
| project(SOF C ASM) | ||
|
|
||
| # most of other options are set on per-arch and per-target basis | ||
| set(CMAKE_ASM_FLAGS -DASSEMBLY) | ||
|
|
||
| # interface library that is used only as container for sof binary options | ||
| # other targets can use it to build with the same options | ||
| add_library(sof_options INTERFACE) | ||
|
|
||
| target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/include) | ||
|
|
||
| if(BUILD_HOST) | ||
| add_subdirectory(src) | ||
| # rest of this file is not needed for host build | ||
| return() | ||
| endif() | ||
|
|
||
| set(PYTHON3 python3) | ||
|
|
||
| # get compiler name and version | ||
| execute_process( | ||
| COMMAND ${CMAKE_C_COMPILER} --version | ||
| COMMAND head -n 1 | ||
| OUTPUT_VARIABLE CC_VERSION_TEXT | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| ) | ||
|
|
||
| set(GENERATED_DIRECTORY ${PROJECT_BINARY_DIR}/generated) | ||
| file(MAKE_DIRECTORY ${GENERATED_DIRECTORY}/include) | ||
|
|
||
| set(DOT_CONFIG_PATH ${GENERATED_DIRECTORY}/.config) | ||
| set(CONFIG_H_PATH ${GENERATED_DIRECTORY}/include/config.h) | ||
| set(VERSION_H_PATH ${GENERATED_DIRECTORY}/include/version.h) | ||
|
|
||
| include(scripts/cmake/version.cmake) | ||
| sof_add_version_h_rule(${PROJECT_SOURCE_DIR}/scripts/cmake/version.cmake) | ||
|
|
||
| include(scripts/cmake/defconfigs.cmake) | ||
|
|
||
| # cmake itself cannot depend on files that don't exist | ||
| # so to make it regenerate when .config file is created, | ||
| # we make it depend on containing directory | ||
| # NOTE: some filesystems may be unable to watch directory change, | ||
| # in that case cmake may need to be regenerated from CLI | ||
| set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS | ||
| ${GENERATED_DIRECTORY} ${DOT_CONFIG_PATH}) | ||
|
|
||
| if(EXISTS ${DOT_CONFIG_PATH}) | ||
| read_kconfig_config(${DOT_CONFIG_PATH}) | ||
| endif() | ||
|
|
||
| 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 | ||
| ) | ||
|
|
||
| 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_dependencies(sof_options genconfig) | ||
| target_include_directories(sof_options INTERFACE ${GENERATED_DIRECTORY}/include) | ||
|
|
||
| if(BUILD_UNIT_TESTS) | ||
| enable_testing() | ||
| add_subdirectory(src/arch/${ARCH}) | ||
| add_subdirectory(test) | ||
| # rest of this file is not needed for unit tests | ||
| return() | ||
| endif() | ||
|
|
||
| add_library(sof_ld_flags INTERFACE) | ||
| add_library(sof_ld_scripts INTERFACE) | ||
|
|
||
| # declare target with no sources to let cmake know about it | ||
| add_executable(sof "") | ||
| target_link_libraries(sof sof_options) | ||
| target_link_libraries(sof sof_ld_scripts) | ||
| target_link_libraries(sof sof_ld_flags) | ||
|
|
||
| add_subdirectory(src) | ||
|
|
||
| target_link_libraries(sof sof_lib) |
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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| mainmenu "SOF $(PROJECTVERSION) Configuration" | ||
|
|
||
| comment "Compiler: $(CC_VERSION_TEXT)" | ||
|
|
||
| config HOST_PTABLE | ||
| bool | ||
| default n | ||
|
|
||
| config TASK_HAVE_PRIORITY_MEDIUM | ||
| bool | ||
| default n | ||
|
|
||
| config BOOT_LOADER | ||
| bool | ||
| default n | ||
|
|
||
| config IRQ_MAP | ||
| bool | ||
| default n | ||
|
|
||
| config DMA_GW | ||
| bool | ||
| default n | ||
|
|
||
| config MEM_WND | ||
| bool | ||
| default n | ||
|
|
||
| source "src/Kconfig" | ||
|
|
||
| menu "Debug" | ||
|
|
||
| config GDB_DEBUG | ||
| bool "GDB Stub" | ||
| default n | ||
| help | ||
| Select for GDB debugging | ||
|
|
||
| config DEBUG_HEAP | ||
| bool "Heap debug" | ||
| default n | ||
| help | ||
| Select for enable heap alloc debugging | ||
|
|
||
| config DEBUG | ||
| bool "Debug build" | ||
| default n | ||
| help | ||
| Select for debug build | ||
|
|
||
| config BUILD_VM_ROM | ||
| bool "Build VM ROM" | ||
| default n | ||
| help | ||
| Select if you want to build VM ROM | ||
|
|
||
| endmenu | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
So I think the 6 above options are not user configurable but should be enabled/disabled by the platform selection (that same way Linux does this). e.g.
and the any platforms that use memory windows would select it
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.
I will make it like you wrote. It looks like these selects in Linux are used mostly for HAVE_* configs, because they declare capabilites of arch/platform, however I think in the future we should make Kconfig files less platform-oriented.
Problem is in how you define user. What you wrote is good for someone that want to run feature-customized version of FW on already defined platform, but for adding new platform with different HW capabilites it may become unmanagable.
Maybe we should aim for definitions based on multiple configs where you have base+diffs (something more like zephyr than linux).
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.
@jajanusz Might be easier to have a complete derived config for a platform/board, easier to read complete recipe. Base rather does not change, so no issue with multiple edits.
Another note: how about storing platform/board defs in /platforms, or /boards, not that deep under arch (what about heterogeneous plaforms)?
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.
@mmaka1 is right that storing it in arch may not be the best idea (even if it's how it's done in kernel)
@mmaka1 @lgirdwood We can always easily change things like these when PR is merged. Kconfig/Cmake are just tools, we can use them however we want for our project.
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.
Fwiw, Linux does store it's def_configs under arch//configs/ but I don't think we need to do this atm (as Linux easily has hundreds).
@jajanusz yeah, I'm keen to merge and sort out any integration issues after merging, that way all the others can try/test and provide feedback.
@mmaka1 do you approve ? if so I will merge.
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.
@jajanusz if you are also happy for merging now pls change the PR title to remove the DO NOT MERGE. Thanks.
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.
@lgirdwood
Still waiting for person responsible for CI to update Internal CI.
I'll let you know when it's done.