diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b6f03fea..43ca1bc56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -537,7 +537,11 @@ if( CALAMARES_VERSION_RC ) set( CALAMARES_VERSION ${CALAMARES_VERSION}rc${CALAMARES_VERSION_RC} ) endif() -# additional info for non-release builds +# Additional info for non-release builds. The "extended" version information +# with date and git information (commit, dirty status) is used only +# by CalamaresVersionX.h, which is included by consumers that need a full +# version number with all that information; normal consumers can include +# CalamaresVersion.h with more stable numbers. if( NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/" ) include( CMakeDateStamp ) set( CALAMARES_VERSION_DATE "${CMAKE_DATESTAMP_YEAR}${CMAKE_DATESTAMP_MONTH}${CMAKE_DATESTAMP_DAY}" ) diff --git a/CMakeModules/CalamaresAddTranslations.cmake b/CMakeModules/CalamaresAddTranslations.cmake index bb15fb122..5015301d2 100644 --- a/CMakeModules/CalamaresAddTranslations.cmake +++ b/CMakeModules/CalamaresAddTranslations.cmake @@ -22,50 +22,15 @@ include( CMakeParseArguments ) -if( NOT _rcc_version_support_checked ) - set( _rcc_version_support_checked TRUE ) - - # Extract the executable name - get_property( _rcc_executable - TARGET ${Qt5Core_RCC_EXECUTABLE} - PROPERTY IMPORTED_LOCATION - ) - if( NOT _rcc_executable ) - # Weird, probably now uses Qt5::rcc which is wrong too - set( _rcc_executable ${Qt5Core_RCC_EXECUTABLE} ) - endif() - - # Try an empty RCC file with explicit format-version - execute_process( - COMMAND echo "" - COMMAND ${Qt5Core_RCC_EXECUTABLE} --format-version 1 --list - - RESULT_VARIABLE _rcc_version_rv - ERROR_VARIABLE _rcc_version_dump - ) - if ( _rcc_version_rv EQUAL 0 ) - # Supported: force to the reproducible version - set( _rcc_version_support --format-version 1 ) - else() - # Older Qt versions (5.7, 5.8) don't support setting the - # rcc format-version, so won't be reproducible if they - # default to version 2. - set( _rcc_version_support "" ) - endif() - unset( _rcc_version_rv ) - unset( _rcc_version_dump ) -endif() - - # Internal macro for adding the C++ / Qt translations to the # build and install tree. Should be called only once, from # src/calamares/CMakeLists.txt. macro(add_calamares_translations language) list( APPEND CALAMARES_LANGUAGES ${ARGV} ) - set( calamares_i18n_qrc_content "\n" ) + set( calamares_i18n_qrc_content "" ) # calamares and qt language files - set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}\n" ) foreach( lang ${CALAMARES_LANGUAGES} ) foreach( tlsource "calamares_${lang}" "tz_${lang}" ) if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" ) @@ -75,31 +40,19 @@ macro(add_calamares_translations language) endforeach() endforeach() - set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}\n" ) - set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}\n" ) - - file( WRITE ${CMAKE_BINARY_DIR}/lang/calamares_i18n.qrc "${calamares_i18n_qrc_content}" ) - - qt5_add_translation(QM_FILES ${TS_FILES}) - - ## HACK HACK HACK - around rcc limitations to allow out of source-tree building set( trans_file calamares_i18n ) - set( trans_srcfile ${CMAKE_BINARY_DIR}/lang/${trans_file}.qrc ) set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc ) set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx ) - # Copy the QRC file to the output directory - add_custom_command( - OUTPUT ${trans_infile} - COMMAND ${CMAKE_COMMAND} -E copy ${trans_srcfile} ${trans_infile} - MAIN_DEPENDENCY ${trans_srcfile} - ) + configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY ) + + qt5_add_translation(QM_FILES ${TS_FILES}) # Run the resource compiler (rcc_options should already be set) add_custom_command( OUTPUT ${trans_outfile} COMMAND "${Qt5Core_RCC_EXECUTABLE}" - ARGS ${rcc_options} ${_rcc_version_support} -name ${trans_file} -o ${trans_outfile} ${trans_infile} + ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile} MAIN_DEPENDENCY ${trans_infile} DEPENDS ${QM_FILES} ) diff --git a/lang/calamares_i18n.qrc.in b/lang/calamares_i18n.qrc.in new file mode 100644 index 000000000..1f0ac1604 --- /dev/null +++ b/lang/calamares_i18n.qrc.in @@ -0,0 +1,5 @@ + + +@calamares_i18n_qrc_content@ + + diff --git a/src/calamares/CMakeLists.txt b/src/calamares/CMakeLists.txt index b632567b8..ff91904e2 100644 --- a/src/calamares/CMakeLists.txt +++ b/src/calamares/CMakeLists.txt @@ -34,9 +34,8 @@ include_directories( # Translations include( CalamaresAddTranslations ) add_calamares_translations( ${CALAMARES_TRANSLATION_LANGUAGES} ) -qt5_add_resources( calamaresRc calamares.qrc ) -add_executable( calamares_bin ${calamaresSources} ${calamaresRc} ${trans_outfile} ) +add_executable( calamares_bin ${calamaresSources} calamares.qrc ${trans_outfile} ) target_include_directories( calamares_bin PRIVATE ${CMAKE_SOURCE_DIR} ) set_target_properties(calamares_bin PROPERTIES @@ -45,6 +44,7 @@ set_target_properties(calamares_bin ) calamares_automoc( calamares_bin ) calamares_autouic( calamares_bin ) +calamares_autorcc( calamares_bin ) target_link_libraries( calamares_bin PRIVATE diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 56bacb32a..8e209f8a3 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -27,8 +27,10 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CalamaresConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h ) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/../calamares/CalamaresVersion.h.in +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CalamaresVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersion.h ) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CalamaresVersionX.h.in + ${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersionX.h ) set( OPTIONAL_PRIVATE_LIBRARIES "" ) set( OPTIONAL_PUBLIC_LIBRARIES "" ) diff --git a/src/calamares/CalamaresVersion.h.in b/src/libcalamares/CalamaresVersion.h.in similarity index 92% rename from src/calamares/CalamaresVersion.h.in rename to src/libcalamares/CalamaresVersion.h.in index 4ac7ee1d1..54a44888a 100644 --- a/src/calamares/CalamaresVersion.h.in +++ b/src/libcalamares/CalamaresVersion.h.in @@ -4,7 +4,7 @@ #cmakedefine CALAMARES_ORGANIZATION_NAME "${CALAMARES_ORGANIZATION_NAME}" #cmakedefine CALAMARES_ORGANIZATION_DOMAIN "${CALAMARES_ORGANIZATION_DOMAIN}" #cmakedefine CALAMARES_APPLICATION_NAME "${CALAMARES_APPLICATION_NAME}" -#cmakedefine CALAMARES_VERSION "${CALAMARES_VERSION}" +#cmakedefine CALAMARES_VERSION "${CALAMARES_VERSION_SHORT}" #cmakedefine CALAMARES_VERSION_SHORT "${CALAMARES_VERSION_SHORT}" #cmakedefine CALAMARES_VERSION_MAJOR "${CALAMARES_VERSION_MAJOR}" diff --git a/src/libcalamares/CalamaresVersionX.h.in b/src/libcalamares/CalamaresVersionX.h.in new file mode 100644 index 000000000..75b124c11 --- /dev/null +++ b/src/libcalamares/CalamaresVersionX.h.in @@ -0,0 +1,13 @@ +// Same as CalamaresVersion.h, but with a full-git-extended VERSION +// rather than the short (vM.m.p) semantic version. +#ifndef CALAMARES_VERSION_H + +// On purpose, do not define the guard, but let CalamaresVersion.h do it +// #define CALAMARES_VERSION_H + +#include "CalamaresVersion.h" + +#undef CALAMARES_VERSION +#cmakedefine CALAMARES_VERSION "${CALAMARES_VERSION}" + +#endif // CALAMARES_VERSION_H diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index 72885d53f..5a2149f44 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -3,6 +3,7 @@ * SPDX-FileCopyrightText: 2010-2011 Christian Muehlhaeuser * SPDX-FileCopyrightText: 2014 Teo Mrnjavac * SPDX-FileCopyrightText: 2017 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later * * * Calamares is free software: you can redistribute it and/or modify @@ -18,15 +19,12 @@ * You should have received a copy of the GNU General Public License * along with Calamares. If not, see . * - * SPDX-License-Identifier: GPL-3.0-or-later - * License-Filename: LICENSE - * */ #include "Logger.h" -#include -#include +#include "CalamaresVersionX.h" +#include "utils/Dirs.h" #include #include @@ -35,10 +33,10 @@ #include #include -#include "CalamaresVersion.h" -#include "utils/Dirs.h" +#include +#include -#define LOGFILE_SIZE 1024 * 256 +static constexpr const int LOGFILE_SIZE = 1024 * 256; static std::ofstream logfile; static unsigned int s_threshold =