summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGeneratorInitializer.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-08-31 14:32:14 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-09-07 15:53:19 (GMT)
commit37ef18a468149ba579b96a763ea3042a360652d7 (patch)
tree5e83e53948d42c288d473690886ba9c24f9bfc34 /Source/cmQtAutoGeneratorInitializer.cxx
parent761b3d79746ab91219d6478a021ba3a1c56f05c8 (diff)
downloadCMake-37ef18a468149ba579b96a763ea3042a360652d7.zip
CMake-37ef18a468149ba579b96a763ea3042a360652d7.tar.gz
CMake-37ef18a468149ba579b96a763ea3042a360652d7.tar.bz2
Autogen: Pass RCC build names and function names in info file
- The output file name of the `rcc` command get computed once in the AUTOGEN initializer and is passed in the info file. - The function name for the `-name` option of `rcc` gets computed once in the AUTOGEN initializer and is passed along with the other `rcc` options in the info file.
Diffstat (limited to 'Source/cmQtAutoGeneratorInitializer.cxx')
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx106
1 files changed, 61 insertions, 45 deletions
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 0333a55..c7747b8 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -580,40 +580,25 @@ static std::string RccGetExecutable(cmGeneratorTarget const* target,
static void SetupAutoTargetRcc(const cmQtAutoGenDigest& digest)
{
- cmGeneratorTarget const* target = digest.Target;
- cmMakefile* makefile = target->Target->GetMakefile();
std::vector<std::string> rccFiles;
- std::vector<std::string> rccInputs;
- std::vector<std::string> rccFileFiles;
- std::vector<std::string> rccFileOptions;
+ std::vector<std::string> rccBuilds;
+ std::vector<std::vector<std::string>> rccOptions;
+ std::vector<std::vector<std::string>> rccInputs;
for (const cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
- const std::string absFile = qrcDigest.QrcFile;
- // Register file
- rccFiles.push_back(absFile);
- // Register (known) resource files
- {
- std::string entriesList = "{";
- if (!qrcDigest.Generated) {
- entriesList += cmJoin(qrcDigest.Resources, cmQtAutoGen::listSep);
- }
- entriesList += "}";
- rccInputs.push_back(entriesList);
- }
- // rcc options for this qrc file
- if (!qrcDigest.Options.empty()) {
- rccFileFiles.push_back(absFile);
- rccFileOptions.push_back(
- cmJoin(qrcDigest.Options, cmQtAutoGen::listSep));
- }
+ rccFiles.push_back(qrcDigest.QrcFile);
+ rccBuilds.push_back(qrcDigest.RccFile);
+ rccOptions.push_back(qrcDigest.Options);
+ rccInputs.push_back(qrcDigest.Resources);
}
+ cmMakefile* makefile = digest.Target->Target->GetMakefile();
AddDefinitionEscaped(makefile, "_qt_rcc_executable",
- RccGetExecutable(target, digest.QtVersionMajor));
+ RccGetExecutable(digest.Target, digest.QtVersionMajor));
AddDefinitionEscaped(makefile, "_rcc_files", rccFiles);
+ AddDefinitionEscaped(makefile, "_rcc_builds", rccBuilds);
+ AddDefinitionEscaped(makefile, "_rcc_options", rccOptions);
AddDefinitionEscaped(makefile, "_rcc_inputs", rccInputs);
- AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles);
- AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions);
}
void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
@@ -746,6 +731,8 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
{
cmQtAutoGenDigestQrc qrcDigest;
qrcDigest.QrcFile = cmSystemTools::GetRealPath(fPath);
+ qrcDigest.QrcName =
+ cmSystemTools::GetFilenameWithoutLastExtension(qrcDigest.QrcFile);
qrcDigest.Generated = sf->GetPropertyAsBool("GENERATED");
// RCC options
{
@@ -822,36 +809,65 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
// Process qrc files
if (!digest.Qrcs.empty()) {
const bool QtV5 = (digest.QtVersionMajor == "5");
- const cmFilePathChecksum fpathCheckSum(makefile);
const std::string rcc = RccGetExecutable(target, digest.QtVersionMajor);
// Target rcc options
std::vector<std::string> optionsTarget;
cmSystemTools::ExpandListArgument(
GetSafeProperty(target, "AUTORCC_OPTIONS"), optionsTarget);
+ // Check if file name is unique
for (cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
- // RCC output file name
- {
- std::string rccFile = autogenBuildDir + "/";
- rccFile += fpathCheckSum.getPart(qrcDigest.QrcFile);
- rccFile += "/qrc_";
- rccFile +=
- cmSystemTools::GetFilenameWithoutLastExtension(qrcDigest.QrcFile);
- rccFile += ".cpp";
-
- AddGeneratedSource(target, rccFile, cmQtAutoGen::RCC);
- autogenProvides.push_back(rccFile);
- qrcDigest.RccFile = std::move(rccFile);
+ qrcDigest.Unique = true;
+ for (const cmQtAutoGenDigestQrc& qrcDig2 : digest.Qrcs) {
+ if ((&qrcDigest != &qrcDig2) &&
+ (qrcDigest.QrcName == qrcDig2.QrcName)) {
+ qrcDigest.Unique = false;
+ break;
+ }
}
- // RCC options
+ }
+ // Path checksum
+ {
+ const cmFilePathChecksum fpathCheckSum(makefile);
+ for (cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
+ qrcDigest.PathChecksum = fpathCheckSum.getPart(qrcDigest.QrcFile);
+ }
+ }
+ // RCC output file name
+ for (cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
+ std::string rccFile = autogenBuildDir + "/";
+ rccFile += qrcDigest.PathChecksum;
+ rccFile += "/qrc_";
+ rccFile += qrcDigest.QrcName;
+ rccFile += ".cpp";
+ qrcDigest.RccFile = std::move(rccFile);
+ }
+ // RCC options
+ for (cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
+ // Target options
+ std::vector<std::string> opts = optionsTarget;
+ // Merge computed "-name XYZ" option
{
- std::vector<std::string> opts = optionsTarget;
- if (!qrcDigest.Options.empty()) {
- cmQtAutoGen::RccMergeOptions(opts, qrcDigest.Options, QtV5);
+ std::string name = qrcDigest.QrcName;
+ // Replace '-' with '_'. The former is not valid for symbol names.
+ std::replace(name.begin(), name.end(), '-', '_');
+ if (!qrcDigest.Unique) {
+ name += "_";
+ name += qrcDigest.PathChecksum;
}
- qrcDigest.Options = std::move(opts);
+ std::vector<std::string> nameOpts;
+ nameOpts.emplace_back("-name");
+ nameOpts.emplace_back(std::move(name));
+ cmQtAutoGen::RccMergeOptions(opts, nameOpts, QtV5);
}
- // GENERATED or not
+ // Merge file option
+ cmQtAutoGen::RccMergeOptions(opts, qrcDigest.Options, QtV5);
+ qrcDigest.Options = std::move(opts);
+ }
+ for (cmQtAutoGenDigestQrc& qrcDigest : digest.Qrcs) {
+ // Register file at target
+ AddGeneratedSource(target, qrcDigest.RccFile, cmQtAutoGen::RCC);
+ autogenProvides.push_back(qrcDigest.RccFile);
if (qrcDigest.Generated) {
// Add GENERATED qrc file to the dependencies
autogenDepends.insert(qrcDigest.QrcFile);