Merge branch 'reduce-version-deps' into calamares

This is a developers quality-of-life fix: reduce the amount
of recompilation that is done after running cmake. Since KDevelop
runs cmake in the background regularly, this was causing 4 files
to be rebuilt every run that don't *really* need to be rebuilt.
This commit is contained in:
Adriaan de Groot 2020-07-29 10:09:46 +02:00
commit 37c236cfe7
8 changed files with 40 additions and 65 deletions

View File

@ -537,7 +537,11 @@ if( CALAMARES_VERSION_RC )
set( CALAMARES_VERSION ${CALAMARES_VERSION}rc${CALAMARES_VERSION_RC} ) set( CALAMARES_VERSION ${CALAMARES_VERSION}rc${CALAMARES_VERSION_RC} )
endif() 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/" ) if( NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/" )
include( CMakeDateStamp ) include( CMakeDateStamp )
set( CALAMARES_VERSION_DATE "${CMAKE_DATESTAMP_YEAR}${CMAKE_DATESTAMP_MONTH}${CMAKE_DATESTAMP_DAY}" ) set( CALAMARES_VERSION_DATE "${CMAKE_DATESTAMP_YEAR}${CMAKE_DATESTAMP_MONTH}${CMAKE_DATESTAMP_DAY}" )

View File

@ -22,50 +22,15 @@
include( CMakeParseArguments ) 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 "<RCC version='1.0'></RCC>"
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 # Internal macro for adding the C++ / Qt translations to the
# build and install tree. Should be called only once, from # build and install tree. Should be called only once, from
# src/calamares/CMakeLists.txt. # src/calamares/CMakeLists.txt.
macro(add_calamares_translations language) macro(add_calamares_translations language)
list( APPEND CALAMARES_LANGUAGES ${ARGV} ) list( APPEND CALAMARES_LANGUAGES ${ARGV} )
set( calamares_i18n_qrc_content "<!DOCTYPE RCC><RCC version=\"1.0\">\n" ) set( calamares_i18n_qrc_content "" )
# calamares and qt language files # calamares and qt language files
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<qresource prefix=\"/lang\">\n" )
foreach( lang ${CALAMARES_LANGUAGES} ) foreach( lang ${CALAMARES_LANGUAGES} )
foreach( tlsource "calamares_${lang}" "tz_${lang}" ) foreach( tlsource "calamares_${lang}" "tz_${lang}" )
if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" ) if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
@ -75,31 +40,19 @@ macro(add_calamares_translations language)
endforeach() endforeach()
endforeach() endforeach()
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}</qresource>\n" )
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}</RCC>\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_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_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx ) set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
# Copy the QRC file to the output directory configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
add_custom_command(
OUTPUT ${trans_infile} qt5_add_translation(QM_FILES ${TS_FILES})
COMMAND ${CMAKE_COMMAND} -E copy ${trans_srcfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_srcfile}
)
# Run the resource compiler (rcc_options should already be set) # Run the resource compiler (rcc_options should already be set)
add_custom_command( add_custom_command(
OUTPUT ${trans_outfile} OUTPUT ${trans_outfile}
COMMAND "${Qt5Core_RCC_EXECUTABLE}" 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} MAIN_DEPENDENCY ${trans_infile}
DEPENDS ${QM_FILES} DEPENDS ${QM_FILES}
) )

View File

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/lang">
@calamares_i18n_qrc_content@
</qresource>
</RCC>

View File

@ -34,9 +34,8 @@ include_directories(
# Translations # Translations
include( CalamaresAddTranslations ) include( CalamaresAddTranslations )
add_calamares_translations( ${CALAMARES_TRANSLATION_LANGUAGES} ) 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} ) target_include_directories( calamares_bin PRIVATE ${CMAKE_SOURCE_DIR} )
set_target_properties(calamares_bin set_target_properties(calamares_bin
PROPERTIES PROPERTIES
@ -45,6 +44,7 @@ set_target_properties(calamares_bin
) )
calamares_automoc( calamares_bin ) calamares_automoc( calamares_bin )
calamares_autouic( calamares_bin ) calamares_autouic( calamares_bin )
calamares_autorcc( calamares_bin )
target_link_libraries( calamares_bin target_link_libraries( calamares_bin
PRIVATE PRIVATE

View File

@ -27,8 +27,10 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CalamaresConfig.h.in configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CalamaresConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/CalamaresConfig.h ) ${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 ) ${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_PRIVATE_LIBRARIES "" )
set( OPTIONAL_PUBLIC_LIBRARIES "" ) set( OPTIONAL_PUBLIC_LIBRARIES "" )

View File

@ -4,7 +4,7 @@
#cmakedefine CALAMARES_ORGANIZATION_NAME "${CALAMARES_ORGANIZATION_NAME}" #cmakedefine CALAMARES_ORGANIZATION_NAME "${CALAMARES_ORGANIZATION_NAME}"
#cmakedefine CALAMARES_ORGANIZATION_DOMAIN "${CALAMARES_ORGANIZATION_DOMAIN}" #cmakedefine CALAMARES_ORGANIZATION_DOMAIN "${CALAMARES_ORGANIZATION_DOMAIN}"
#cmakedefine CALAMARES_APPLICATION_NAME "${CALAMARES_APPLICATION_NAME}" #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_SHORT "${CALAMARES_VERSION_SHORT}"
#cmakedefine CALAMARES_VERSION_MAJOR "${CALAMARES_VERSION_MAJOR}" #cmakedefine CALAMARES_VERSION_MAJOR "${CALAMARES_VERSION_MAJOR}"

View File

@ -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

View File

@ -3,6 +3,7 @@
* SPDX-FileCopyrightText: 2010-2011 Christian Muehlhaeuser <muesli@tomahawk-player.org> * SPDX-FileCopyrightText: 2010-2011 Christian Muehlhaeuser <muesli@tomahawk-player.org>
* SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org> * SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
* SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org> * SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
* *
* *
* Calamares is free software: you can redistribute it and/or modify * 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 * You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
* *
* SPDX-License-Identifier: GPL-3.0-or-later
* License-Filename: LICENSE
*
*/ */
#include "Logger.h" #include "Logger.h"
#include <fstream> #include "CalamaresVersionX.h"
#include <iostream> #include "utils/Dirs.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
@ -35,10 +33,10 @@
#include <QTime> #include <QTime>
#include <QVariant> #include <QVariant>
#include "CalamaresVersion.h" #include <fstream>
#include "utils/Dirs.h" #include <iostream>
#define LOGFILE_SIZE 1024 * 256 static constexpr const int LOGFILE_SIZE = 1024 * 256;
static std::ofstream logfile; static std::ofstream logfile;
static unsigned int s_threshold = static unsigned int s_threshold =