Skip to content

Commit

Permalink
qmake: add QMAKE_EXPORTED_VARIABLES
Browse files Browse the repository at this point in the history
because QMAKE_EXTRA_VARIABLES sometimes just ain't enough.

Change-Id: I739e5b6510e4701ca0a86834e4f9a978d7ef1cf4
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
ossilator committed Jan 5, 2019
1 parent 2f4eea5 commit fff5991
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions qmake/generators/makefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,25 @@ MakefileGenerator::writeExtraVariables(QTextStream &t)
}
}

// This is a more powerful alternative to the above function.
// It's meant to be internal, as one can make quite a mess with it.
void
MakefileGenerator::writeExportedVariables(QTextStream &t)
{
const auto &vars = project->values("QMAKE_EXPORTED_VARIABLES");
if (vars.isEmpty())
return;
for (const auto &exp : vars) {
const ProString &name = project->first(ProKey(exp + ".name"));
const ProString &value = project->first(ProKey(exp + ".value"));
if (!value.isEmpty())
t << name << " = " << value << endl;
else
t << name << " =\n";
}
t << endl;
}

bool
MakefileGenerator::writeDummyMakefile(QTextStream &t)
{
Expand Down
1 change: 1 addition & 0 deletions qmake/generators/makefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class MakefileGenerator : protected QMakeSourceFileInfo
void writeHeader(QTextStream &t);
void writeSubDirs(QTextStream &t);
void writeMakeQmake(QTextStream &t, bool noDummyQmakeAll = false);
void writeExportedVariables(QTextStream &t);
void writeExtraVariables(QTextStream &t);
void writeExtraTargets(QTextStream &t);
void writeExtraCompilerTargets(QTextStream &t);
Expand Down
2 changes: 2 additions & 0 deletions qmake/generators/unix/unixmake2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)

ProStringList &bundledFiles = project->values("QMAKE_BUNDLED_FILES");

writeExportedVariables(t);

t << "####### Compiler, tools and options\n\n";
t << "CC = " << var("QMAKE_CC") << endl;
t << "CXX = " << var("QMAKE_CXX") << endl;
Expand Down
2 changes: 2 additions & 0 deletions qmake/generators/win32/winmakefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ void Win32MakefileGenerator::writeIncPart(QTextStream &t)

void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
{
writeExportedVariables(t);

t << "####### Compiler, tools and options\n\n";
t << "CC = " << var("QMAKE_CC") << endl;
t << "CXX = " << var("QMAKE_CXX") << endl;
Expand Down

0 comments on commit fff5991

Please sign in to comment.