CMake: improve validator dependency-checking

The configvalidator has some extra Python dependencies. Cache
the restults of checking the dependencies (convenient for developers),
and also explain what's going on if the feature is switched off.
This commit is contained in:
Adriaan de Groot 2020-07-29 10:58:07 +02:00
parent 37c236cfe7
commit 33eab6e869

View File

@ -356,23 +356,33 @@ set_package_properties(
URL "https://python.org" URL "https://python.org"
PURPOSE "Python 3 interpreter for certain tests." PURPOSE "Python 3 interpreter for certain tests."
) )
set( _schema_explanation "" )
if ( PYTHONINTERP_FOUND ) if ( PYTHONINTERP_FOUND )
message(STATUS "Found Python 3 interpreter ${PYTHON_EXECUTABLE}")
if ( BUILD_SCHEMA_TESTING ) if ( BUILD_SCHEMA_TESTING )
# The configuration validator script has some dependencies, # The configuration validator script has some dependencies,
# and if they are not installed, don't run. If errors out # and if they are not installed, don't run. If errors out
# with exit(1) on missing dependencies. # with exit(1) on missing dependencies.
if ( CALAMARES_CONFIGVALIDATOR_CHECKED )
set( _validator_deps ${CALAMARES_CONFIGVALIDATOR_RESULT} )
else()
exec_program( ${PYTHON_EXECUTABLE} ARGS "${CMAKE_SOURCE_DIR}/ci/configvalidator.py" -x RETURN_VALUE _validator_deps ) exec_program( ${PYTHON_EXECUTABLE} ARGS "${CMAKE_SOURCE_DIR}/ci/configvalidator.py" -x RETURN_VALUE _validator_deps )
set( CALAMARES_CONFIGVALIDATOR_CHECKED TRUE CACHE INTERNAL "Dependencies for configvalidator checked" )
set( CALAMARES_CONFIGVALIDATOR_RESULT ${_validator_deps} CACHE INTERNAL "Result of configvalidator dependency check" )
endif()
# It should never succeed, but only returns 1 when the imports fail # It should never succeed, but only returns 1 when the imports fail
if ( _validator_deps EQUAL 1 ) if ( _validator_deps EQUAL 1 )
message(STATUS "BUILD_SCHEMA_TESTING dependencies are missing." ) set( _schema_explanation " Missing dependencies for configvalidator.py." )
set( BUILD_SCHEMA_TESTING OFF ) set( BUILD_SCHEMA_TESTING OFF )
endif() endif()
endif() endif()
else() else()
# Can't run schema tests without Python3. # Can't run schema tests without Python3.
set( _schema_explanation " Missing Python3." )
set( BUILD_SCHEMA_TESTING OFF ) set( BUILD_SCHEMA_TESTING OFF )
endif() endif()
add_feature_info( yaml-schema BUILD_SCHEMA_TESTING "Validate YAML (config files) with schema.${_schema_explanation}" )
find_package( PythonLibs ${PYTHONLIBS_VERSION} ) find_package( PythonLibs ${PYTHONLIBS_VERSION} )
set_package_properties( set_package_properties(
PythonLibs PROPERTIES PythonLibs PROPERTIES