From 7d92d4893e239bf585b8f421db13ee5ffc91d00b Mon Sep 17 00:00:00 2001 From: Peter van der Perk Date: Thu, 12 Jan 2023 16:17:12 +0100 Subject: [PATCH] VSCode C/C++ include path and config hints --- .vscode/.gitignore | 1 + platforms/common/CMakeLists.txt | 6 +++++ .../common/c_cpp_properties.json.in | 10 +++++--- .../common/c_cpp_properties.json.nuttx.in | 24 +++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) rename .vscode/c_cpp_properties.json => platforms/common/c_cpp_properties.json.in (52%) create mode 100644 platforms/common/c_cpp_properties.json.nuttx.in diff --git a/.vscode/.gitignore b/.vscode/.gitignore index 9c5e791626..54fa58b697 100644 --- a/.vscode/.gitignore +++ b/.vscode/.gitignore @@ -4,6 +4,7 @@ compile_commands.json # generated by cmake launch.json +c_cpp_properties.json # C/C++ extension does some local caching in this folder ipch/ diff --git a/platforms/common/CMakeLists.txt b/platforms/common/CMakeLists.txt index 11e0628a8d..a6e06b9d47 100644 --- a/platforms/common/CMakeLists.txt +++ b/platforms/common/CMakeLists.txt @@ -63,4 +63,10 @@ endif() add_subdirectory(px4_work_queue) add_subdirectory(work_queue) +if("${PX4_PLATFORM}" MATCHES "nuttx") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/c_cpp_properties.json.nuttx.in ${PX4_SOURCE_DIR}/.vscode/c_cpp_properties.json @ONLY) +else() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/c_cpp_properties.json.in ${PX4_SOURCE_DIR}/.vscode/c_cpp_properties.json @ONLY) +endif() + px4_add_unit_gtest(SRC board_identity_test.cpp LINKLIBS px4_platform) diff --git a/.vscode/c_cpp_properties.json b/platforms/common/c_cpp_properties.json.in similarity index 52% rename from .vscode/c_cpp_properties.json rename to platforms/common/c_cpp_properties.json.in index 9292c68182..e7a2d70574 100644 --- a/.vscode/c_cpp_properties.json +++ b/platforms/common/c_cpp_properties.json.in @@ -3,14 +3,18 @@ { "name": "PX4", "includePath": [ - "${workspaceFolder}/**" + "${workspaceFolder}/**", ], "defines": [], "macFrameworkPath": [], "configurationProvider": "ms-vscode.cmake-tools", "cppStandard": "c++14", - "cStandard": "c11" + "cStandard": "c11", + "forcedInclude": [ + "@PX4_BINARY_DIR@/px4_boardconfig.h", + "@PX4_SOURCE_DIR@/platforms/common/include/px4_platform_common/defines.h" + ] } ], "version": 4 -} \ No newline at end of file +} diff --git a/platforms/common/c_cpp_properties.json.nuttx.in b/platforms/common/c_cpp_properties.json.nuttx.in new file mode 100644 index 0000000000..188e811572 --- /dev/null +++ b/platforms/common/c_cpp_properties.json.nuttx.in @@ -0,0 +1,24 @@ +{ + "configurations": [ + { + "name": "PX4", + "includePath": [ + "${workspaceFolder}/**", + "@PX4_BOARD_DIR@/src", + "@PX4_SOURCE_DIR@/platforms/nuttx/src/px4/@PX4_CHIP_MANUFACTURER@/@PX4_CHIP@/include", + "@PX4_SOURCE_DIR@/platforms/nuttx/NuttX/nuttx/include/" + ], + "defines": [], + "macFrameworkPath": [], + "configurationProvider": "ms-vscode.cmake-tools", + "cppStandard": "c++14", + "cStandard": "c11", + "dotConfig": "@PX4_BINARY_DIR@/NuttX/nuttx/.config", + "forcedInclude": [ + "@PX4_BINARY_DIR@/px4_boardconfig.h", + "@PX4_SOURCE_DIR@/platforms/common/include/px4_platform_common/defines.h" + ] + } + ], + "version": 4 +}