Created
May 25, 2020 07:25
-
-
Save suy/69f7a3ae7701fed27b8fd5bc19a19cb2 to your computer and use it in GitHub Desktop.
A simple tool to sort and print in a more human readable form the compiler output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtCore> | |
static void dump(const char* name, const QStringList& variable) { | |
QTextStream out(stdout); | |
out << variable.count() << " " << name << endl; | |
foreach (const QString& item, variable) { | |
out << " " << item << endl; | |
} | |
} | |
int main(int argc, char* argv[]) | |
{ | |
QCoreApplication application(argc, argv); | |
QStringList defines; | |
QStringList libraries; | |
QStringList libraryPaths; | |
QStringList includes; | |
QStringList objects; | |
foreach (const QString& element, application.arguments()) { | |
if (element.startsWith("-D")) | |
defines << element; | |
if (element.startsWith("-l")) | |
libraries << element; | |
if (element.startsWith("-L")) | |
libraryPaths << element; | |
if (element.startsWith("-I")) | |
includes << element; | |
if (element.endsWith(".o")) | |
objects << element; | |
} | |
qSort(defines); | |
qSort(libraries); | |
qSort(libraryPaths); | |
qSort(includes); | |
qSort(objects); | |
dump("defines", defines); | |
dump("libraries", libraries); | |
dump("library paths", libraryPaths); | |
dump("includes", includes); | |
dump("objects", objects); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick paste. The code is old, and I did not bother to fix the usage of deprecated
qSort
, or port to range-for instead offoreach
.Usage:
cat /tmp/compiler-cli.txt | xargs ./compiler-command-line-helper