From b44c8b125f67bcdcfc639ff76c8d3e1cdf586ed6 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 20 Mar 2018 12:27:00 +1100 Subject: [PATCH] cmake: Style cleanup, add cmake linter to gitlab CI --- .gitlab-ci.yml | 6 ++++++ components/app_trace/CMakeLists.txt | 2 +- components/bt/CMakeLists.txt | 4 ++-- tools/cmake/crosstool_version_check.cmake | 8 ++++---- tools/cmake/idf_functions.cmake | 14 +++++++------- tools/cmake/project.cmake | 2 +- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a0e579ea1..d18cfa8a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -234,6 +234,12 @@ build_docs: - make html - ../check_doc_warnings.sh +verify_cmake_style: + stage: build + image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG + script: + tools/cmake/run_cmake_lint.sh + test_nvs_on_host: stage: test image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index ebdfd941c..fec9b921d 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -1,7 +1,7 @@ set(COMPONENT_SRCDIRS "." "gcov") set(COMPONENT_ADD_INCLUDEDIRS "include") -if (CONFIG_SYSVIEW_ENABLE) +if(CONFIG_SYSVIEW_ENABLE) list(APPEND COMPONENT_ADD_INCLUDEDIRS sys_view/Config sys_view/SEGGER diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index f802be0f1..9431645e8 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -15,7 +15,7 @@ if(CONFIG_BLUEDROID_ENABLED) bluedroid/hci/include bluedroid/osi/include bluedroid/external/sbc/decoder/include - bluedroid/external/sbc/encoder/include + bluedroid/external/sbc/encoder/include bluedroid/btc/profile/esp/blufi/include bluedroid/btc/profile/esp/include bluedroid/btc/profile/std/a2dp/include @@ -51,7 +51,7 @@ if(CONFIG_BLUEDROID_ENABLED) bluedroid/main bluedroid/osi bluedroid/external/sbc/decoder/srce - bluedroid/external/sbc/encoder/srce + bluedroid/external/sbc/encoder/srce bluedroid/btc/core bluedroid/btc/profile/esp/blufi bluedroid/btc/profile/std/gap diff --git a/tools/cmake/crosstool_version_check.cmake b/tools/cmake/crosstool_version_check.cmake index f55f121d3..d572a82a7 100644 --- a/tools/cmake/crosstool_version_check.cmake +++ b/tools/cmake/crosstool_version_check.cmake @@ -18,10 +18,10 @@ function(crosstool_version_check expected_ctng_version) string(REGEX MATCH "crosstool-ng-[0-9a-g\\.-]+" ctng_version "${toolchain_stderr}") string(REPLACE "crosstool-ng-" "" ctng_version "${ctng_version}") - # We use FIND to match version instead of STREQUAL because some toolchains are built - # with longer git hash strings than others. This will match any version which starts with - # the expected version string. - string(FIND "${ctng_version}" "${expected_ctng_version}" found_expected_version) + # We use FIND to match version instead of STREQUAL because some toolchains are built + # with longer git hash strings than others. This will match any version which starts with + # the expected version string. + string(FIND "${ctng_version}" "${expected_ctng_version}" found_expected_version) if(NOT ctng_version) message(WARNING "Xtensa toolchain ${CMAKE_C_COMPILER} does not appear to be built with crosstool-ng. " "${ctng_version_warning}") diff --git a/tools/cmake/idf_functions.cmake b/tools/cmake/idf_functions.cmake index 923478231..e88e980af 100644 --- a/tools/cmake/idf_functions.cmake +++ b/tools/cmake/idf_functions.cmake @@ -18,7 +18,7 @@ macro(idf_set_global_variables) # (cmake calls this CMAKE_SOURCE_DIR, keeping old name for compatibility.) set(PROJECT_PATH "${CMAKE_SOURCE_DIR}") - # Note: Unlike older build system, "main" is no longer a component. See build docs for details. + # Note: Unlike older build system, "main" is no longer a component. See build docs for details. set_default(COMPONENT_DIRS "${PROJECT_PATH}/components ${EXTRA_COMPONENT_DIRS} ${IDF_PATH}/components") spaces2list(COMPONENT_DIRS) @@ -97,12 +97,12 @@ function(idf_set_global_compiler_options) add_compile_options("-I${CMAKE_BINARY_DIR}") # for sdkconfig.h # Enable ccache if it's on the path - if(NOT CCACHE_DISABLE) - find_program(CCACHE_FOUND ccache) - if(CCACHE_FOUND) - message(STATUS "ccache will be used for faster builds") - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - endif() + if(NOT CCACHE_DISABLE) + find_program(CCACHE_FOUND ccache) + if(CCACHE_FOUND) + message(STATUS "ccache will be used for faster builds") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + endif() endif() endfunction() diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index b9fe126b9..115963c56 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -7,7 +7,7 @@ set(IDF_PATH "$ENV{IDF_PATH}") if(NOT IDF_PATH) # Documentation says you should set IDF_PATH in your environment, but we # can infer it here if it's not set. - set(IDF_PATH ${CMAKE_CURRENT_LIST_DIR}) + set(IDF_PATH ${CMAKE_CURRENT_LIST_DIR}) endif() file(TO_CMAKE_PATH "${IDF_PATH}" IDF_PATH) set($ENV{IDF_PATH} "${IDF_PATH}")