]> granicus.if.org Git - esp-idf/commitdiff
cmake: Write configuration & component metadata to project_description.json
authorAngus Gratton <angus@espressif.com>
Thu, 5 Apr 2018 07:26:28 +0000 (17:26 +1000)
committerAngus Gratton <gus@projectgus.com>
Sun, 29 Apr 2018 23:59:20 +0000 (09:59 +1000)
tools/cmake/kconfig.cmake
tools/cmake/project.cmake
tools/cmake/project_description.json.in
tools/cmake/utilities.cmake

index 277568959695717544a9f9d14290d6b29a76f4b1..cc21563054e7ab3ffb4dfe759296646683694e0e 100644 (file)
@@ -52,6 +52,11 @@ function(kconfig_process_config)
         set(defaults_arg --defaults "${SDKCONFIG_DEFAULTS}")
     endif()
 
+    # Set these in the parent scope, so that they can be written to project_description.json
+    set(kconfigs "${kconfigs}")
+    set(COMPONENT_KCONFIGS "${kconfigs}" PARENT_SCOPE)
+    set(COMPONENT_KCONFIGS_PROJBUILD "${kconfigs_projbuild}" PARENT_SCOPE)
+
     set(confgen_basecommand
         ${PYTHON} ${IDF_PATH}/tools/kconfig_new/confgen.py
         --kconfig ${ROOT_KCONFIG}
index 115963c56ba6342c21877be8e28f21893bb2c97e..26be56edab4608bd72968c6f37aee7b39f5f8b57 100644 (file)
@@ -108,8 +108,12 @@ macro(project name)
     idf_add_executable()
 
     # Write project description JSON file
+    make_json_list("${BUILD_COMPONENTS}" build_components_json)
+    make_json_list("${BUILD_COMPONENT_PATHS}" build_component_paths_json)
     configure_file("${IDF_PATH}/tools/cmake/project_description.json.in"
         "${CMAKE_BINARY_DIR}/project_description.json")
+    unset(build_components_json)
+    unset(build_component_paths_json)
 
     #
     # Finish component registration (add cross-dependencies, make
index 1acffbd6270bd9dcfef08bea830bcc4105c2f26d..878dce3b3ad2b3bc49d4204132806b3216cc84a6 100644 (file)
@@ -3,9 +3,16 @@
     "project_path":       "${PROJECT_PATH}",
     "build_dir":          "${CMAKE_BINARY_DIR}",
     "config_file":        "${SDKCONFIG}",
+    "config_defaults":    "${SDKCONFIG_DEFAULTS}",
     "app_elf":            "${PROJECT_NAME}.elf",
     "app_bin":            "${PROJECT_NAME}.bin",
     "git_revision":       "${IDF_VER}",
     "phy_data_partition": "${CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION}",
-    "monitor_baud" : "${CONFIG_MONITOR_BAUD}"
+    "monitor_baud" : "${CONFIG_MONITOR_BAUD}",
+    "config_environment" : {
+        "COMPONENT_KCONFIGS" : "${COMPONENT_KCONFIGS}",
+        "COMPONENT_KCONFIGS_PROJBUILD" : "${COMPONENT_KCONFIGS_PROJBUILD}"
+    },
+    "build_components" : ${build_components_json},
+    "build_component_paths" : ${build_component_paths_json}
 }
index f3c0c1981a58f7fe2a5eafd8c64043a5fa011d47..e9138518089c09127d083ec22be5a328243be002 100644 (file)
@@ -170,3 +170,9 @@ function(target_linker_script target scriptfile)
     # executable(s) the library is linked to. This is done manually in components.cmake.
     set_property(TARGET "${target}" APPEND PROPERTY LINK_DEPENDS "${abs_script}")
 endfunction()
+
+# Convert a CMake list to a JSON list and store it in a variable
+function(make_json_list list variable)
+    string(REPLACE ";" "\", \"" result "[ \"${list}\" ]")
+    set("${variable}" "${result}" PARENT_SCOPE)
+endfunction()