This is an automated email from the ASF dual-hosted git repository. szaszm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 248953e9628528ee7df13b0280a1b38b9b0d75b9 Author: Martin Zink <[email protected]> AuthorDate: Thu Oct 6 12:49:15 2022 +0200 MINIFICPP-1947 add EXCLUDE_FROM_DEFAULT_BUILD to linter Currently we build the whole solution on windows which linters are part of. MINIFICPP-1575 intruduced an ENABLE_LINTER cmake option to disable linter, so it can be built on windows without python. But on the CI we currently run the linters twice (once implicitly in the build step, and once again explicitly by the linter step, this also means a linter failure shows up as a build failure in the CI which can be confusing at a glance) If we set the EXCLUDE_FROM_DEFAULT_BUILD target option on all linter targets, the linters wont be built implicitly by the build step, this also means we can rid of the ENABLE_LINTER cmake option. Closes #1427 Signed-off-by: Marton Szasz <[email protected]> --- .github/workflows/ci.yml | 6 +++--- CMakeLists.txt | 42 +++++++++++++++++++++--------------------- cmake/Extensions.cmake | 11 +++++------ cmake/MiNiFiOptions.cmake | 3 +-- win_build_vs.bat | 4 +--- 5 files changed, 31 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e5e442c6..1aaf77db3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: run: cd ..\b && ctest --timeout 300 --parallel %NUMBER_OF_PROCESSORS% -C Release --output-on-failure shell: cmd - name: linter - run: cd ..\b && msbuild -maxCpuCount linter.vcxproj + run: cd ..\b && msbuild /verbosity:quiet -maxCpuCount linter.vcxproj shell: cmd ubuntu_20_04: name: "ubuntu-20.04" @@ -142,7 +142,7 @@ jobs: export CXXFLAGS="${CXXFLAGS} -stdlib=libc++" export LDFLAGS="${LDFLAGS} -stdlib=libc++" cmake -DUSE_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCI_BUILD=ON -DSTRICT_GSL_CHECKS=AUDIT -DFAIL_ON_WARNINGS=ON -DENABLE_AWS=ON -DENABLE_AZURE=ON -DENABLE_BUSTACHE=ON -DENABLE_COAP=ON \ - -DENABLE_ENCRYPT_CONFIG=ON -DENABLE_GPS=ON -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_LINTER=ON -DENABLE_MQTT=ON -DENABLE_NANOFI=ON -DENABLE_OPC=ON -DENABLE_OPENCV=ON \ + -DENABLE_ENCRYPT_CONFIG=ON -DENABLE_GPS=ON -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_MQTT=ON -DENABLE_NANOFI=ON -DENABLE_OPC=ON -DENABLE_OPENCV=ON \ -DENABLE_OPENWSMAN=ON -DENABLE_OPS=ON -DENABLE_PCAP=ON -DENABLE_PYTHON=ON -DENABLE_SENSORS=ON -DENABLE_SFTP=ON -DENABLE_SQL=ON -DENABLE_SYSTEMD=ON -DENABLE_TENSORFLOW=OFF \ -DENABLE_USB_CAMERA=ON -DENABLE_SCRIPTING=ON -DENABLE_LUA_SCRIPTING=ON -DENABLE_KUBERNETES=ON -DENABLE_GCP=ON -DENABLE_PROCFS=ON -DENABLE_PROMETHEUS=ON -DENABLE_ELASTICSEARCH=ON \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. @@ -196,7 +196,7 @@ jobs: run: | if [ -d ~/.ccache ]; then mv ~/.ccache .; fi mkdir build && cd build && cmake -DUSE_SHARED_LIBS=ON -DCI_BUILD=ON -DSTRICT_GSL_CHECKS=AUDIT -DFAIL_ON_WARNINGS=ON -DENABLE_AWS=ON -DENABLE_AZURE=ON -DENABLE_COAP=ON \ - -DENABLE_ENCRYPT_CONFIG=ON -DENABLE_GPS=ON -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_LINTER=ON -DENABLE_MQTT=ON -DENABLE_NANOFI=ON -DENABLE_OPC=ON -DENABLE_OPENCV=ON \ + -DENABLE_ENCRYPT_CONFIG=ON -DENABLE_GPS=ON -DENABLE_JNI=ON -DENABLE_LIBRDKAFKA=ON -DENABLE_MQTT=ON -DENABLE_NANOFI=ON -DENABLE_OPC=ON -DENABLE_OPENCV=ON \ -DENABLE_OPENWSMAN=ON -DENABLE_OPS=ON -DENABLE_PYTHON=ON -DENABLE_SENSORS=ON -DENABLE_SFTP=ON -DENABLE_SQL=ON -DENABLE_SYSTEMD=ON -DENABLE_TENSORFLOW=OFF \ -DENABLE_USB_CAMERA=ON -DENABLE_SCRIPTING=ON -DENABLE_LUA_SCRIPTING=ON -DENABLE_KUBERNETES=ON -DENABLE_GCP=ON -DENABLE_PROCFS=ON -DENABLE_PROMETHEUS=ON -DENABLE_ELASTICSEARCH=ON \ -DDOCKER_SKIP_TESTS=OFF -DDOCKER_BUILD_ONLY=ON -DDOCKER_CCACHE_DUMP_LOCATION=$HOME/.ccache .. && make centos diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d25f9a4a..cb79627e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -621,27 +621,27 @@ include(BuildDocs) # Create a custom build target that will run the linter. # Directories have their separate linter targets to be able to use better parallelization -if (ENABLE_LINTER) - get_property(extensions GLOBAL PROPERTY EXTENSION-LINTERS) - set(root_linted_dirs libminifi/include libminifi/src libminifi/test encrypt-config) - list(TRANSFORM root_linted_dirs PREPEND ${CMAKE_SOURCE_DIR}/) - - set(linted_dir_counter 1) - set(root_linter_target_names "") - - foreach(linted_dir ${root_linted_dirs}) - set(linter_target_name "root-linter-${linted_dir_counter}") - list(APPEND root_linter_target_names ${linter_target_name}) - add_custom_target("${linter_target_name}" - COMMAND python3 ${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/run_linter.py -q -i ${linted_dir} - ) - math(EXPR linted_dir_counter "${linted_dir_counter}+1") - endforeach() - - # Main linter target that depends on every other - add_custom_target(linter) - add_dependencies(linter ${root_linter_target_names} ${extensions}) -endif() +get_property(extensions GLOBAL PROPERTY EXTENSION-LINTERS) +set(root_linted_dirs libminifi/include libminifi/src libminifi/test encrypt-config) +list(TRANSFORM root_linted_dirs PREPEND ${CMAKE_SOURCE_DIR}/) + +set(linted_dir_counter 1) +set(root_linter_target_names "") + +foreach(linted_dir ${root_linted_dirs}) + set(linter_target_name "root-linter-${linted_dir_counter}") + list(APPEND root_linter_target_names ${linter_target_name}) + add_custom_target("${linter_target_name}" + COMMAND python3 ${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/run_linter.py -q -i ${linted_dir} + ) + set_target_properties(${linter_target_name} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) + math(EXPR linted_dir_counter "${linted_dir_counter}+1") +endforeach() + +# Main linter target that depends on every other +add_custom_target(linter) +add_dependencies(linter ${root_linter_target_names} ${extensions}) +set_target_properties(linter PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) if(NOT WIN32) diff --git a/cmake/Extensions.cmake b/cmake/Extensions.cmake index 5df9e53fb..da8a17916 100644 --- a/cmake/Extensions.cmake +++ b/cmake/Extensions.cmake @@ -102,12 +102,11 @@ function(registerTest dirName) endfunction(registerTest) macro(register_extension_linter target-name) - if(ENABLE_LINTER) - get_property(extensions GLOBAL PROPERTY EXTENSION-LINTERS) - set_property(GLOBAL APPEND PROPERTY EXTENSION-LINTERS "${target-name}") - add_custom_target(${target-name} - COMMAND python3 ${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/run_linter.py -q -i ${CMAKE_CURRENT_LIST_DIR}/) - endif() + get_property(extensions GLOBAL PROPERTY EXTENSION-LINTERS) + set_property(GLOBAL APPEND PROPERTY EXTENSION-LINTERS "${target-name}") + add_custom_target(${target-name} + COMMAND python3 ${CMAKE_SOURCE_DIR}/thirdparty/google-styleguide/run_linter.py -q -i ${CMAKE_CURRENT_LIST_DIR}/) + set_target_properties(${target-name} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) endmacro() function(get_component_name extension-name output) diff --git a/cmake/MiNiFiOptions.cmake b/cmake/MiNiFiOptions.cmake index a4429e499..cfca8b213 100644 --- a/cmake/MiNiFiOptions.cmake +++ b/cmake/MiNiFiOptions.cmake @@ -29,7 +29,6 @@ function(add_minifi_dependent_option OPTION_NAME OPTION_DESCRIPTION OPTION_VALUE endfunction() add_minifi_option(CI_BUILD "Build is used for CI." OFF) -add_minifi_option(ENABLE_LINTER "Create linter components" ON) add_minifi_option(SKIP_TESTS "Skips building all tests." OFF) add_minifi_option(DOCKER_BUILD_ONLY "Disables all targets except docker build scripts. Ideal for systems without an up-to-date compiler." OFF) add_minifi_option(DOCKER_SKIP_TESTS "Skip building tests in docker image targets." ON) @@ -128,7 +127,7 @@ endif() function(get_minifi_docker_options RET_VALUE) set(MINIFI_DOCKER_OPTIONS_STR ${MINIFI_EXTERNAL_DOCKER_OPTIONS_STR}) foreach(MINIFI_OPTION ${MINIFI_OPTIONS}) - if (MINIFI_OPTION STREQUAL "CI_BUILD" OR MINIFI_OPTION STREQUAL "ENABLE_LINTER" OR MINIFI_OPTION STREQUAL "SKIP_TESTS" OR MINIFI_OPTION STREQUAL "DOCKER_BUILD_ONLY" OR MINIFI_OPTION STREQUAL "DOCKER_SKIP_TESTS") + if (MINIFI_OPTION STREQUAL "CI_BUILD" OR MINIFI_OPTION STREQUAL "SKIP_TESTS" OR MINIFI_OPTION STREQUAL "DOCKER_BUILD_ONLY" OR MINIFI_OPTION STREQUAL "DOCKER_SKIP_TESTS") continue() endif() set(MINIFI_DOCKER_OPTIONS_STR "${MINIFI_DOCKER_OPTIONS_STR} -D${MINIFI_OPTION}=${${MINIFI_OPTION}}") diff --git a/win_build_vs.bat b/win_build_vs.bat index 88572536d..39ef9b62c 100755 --- a/win_build_vs.bat +++ b/win_build_vs.bat @@ -52,7 +52,6 @@ set cpack=OFF set installer_merge_modules=OFF set strict_gsl_checks= set redist= -set build_linter=OFF set build_nanofi=OFF set build_opencv=OFF set build_prometheus=OFF @@ -99,7 +98,6 @@ for %%x in (%*) do ( if [%%~x] EQU [/DD] set cmake_build_type=Debug if [%%~x] EQU [/CI] set "strict_gsl_checks=-DSTRICT_GSL_CHECKS=AUDIT" & set test_custom_wel_provider=ON if [%%~x] EQU [/NONFREEUCRT] set "redist=-DMSI_REDISTRIBUTE_UCRT_NONASL=ON" - if [%%~x] EQU [/L] set build_linter=ON if [%%~x] EQU [/RO] set real_odbc=ON if [%%~x] EQU [/NINJA] set generator="Ninja" ) @@ -121,7 +119,7 @@ cmake -G %generator% -A %build_platform% -DINSTALLER_MERGE_MODULES=%installer_me -DENABLE_MQTT=%enable_mqtt% -DENABLE_OPC=%enable_opc% -DENABLE_OPENWSMAN=%enable_openwsman% -DENABLE_OPS=%enable_ops% -DENABLE_PCAP=%enable_pcap% ^ -DENABLE_SCRIPTING=%enable_scripting% -DENABLE_SENSORS=%enable_sensors% -DENABLE_TENSORFLOW=%enable_tensorflow% -DENABLE_USB_CAMERA=%enable_usb_camera% ^ -DBUILD_ROCKSDB=ON -DFORCE_WINDOWS=ON -DUSE_SYSTEM_UUID=OFF -DDISABLE_LIBARCHIVE=OFF -DEXCLUDE_BOOST=ON -DENABLE_WEL=ON -DFAIL_ON_WARNINGS=OFF -DSKIP_TESTS=%skiptests% ^ - %strict_gsl_checks% %redist% -DENABLE_LINTER=%build_linter% %EXTRA_CMAKE_ARGUMENTS% "%scriptdir%" && %buildcmd% + %strict_gsl_checks% %redist% %EXTRA_CMAKE_ARGUMENTS% "%scriptdir%" && %buildcmd% IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL% if [%cpack%] EQU [ON] ( cpack -C %cmake_build_type%
