forked from Lainports/freebsd-ports
Special thanks to Luca Pizzamiglio <luca.pizzamiglio at gmail.com> for working on the update to 4.3.0, which made going to 4.3.1 much easier.
106 lines
3.7 KiB
Text
106 lines
3.7 KiB
Text
commit 6b95b832d72696df0278ac7b9d290c96b798ef07
|
|
Author: Milian Wolff <mail@milianw.de>
|
|
Date: Tue Apr 17 11:14:02 2012 +0200
|
|
|
|
Fix gcc include-path and macro computation on machines with old GCC.
|
|
|
|
Whe default to calling GCC with -std=c++0x and fallback to a call
|
|
without that argument when the former fails.
|
|
|
|
BUG: 298252
|
|
|
|
diff --git a/languages/cpp/setuphelpers.cpp b/languages/cpp/setuphelpers.cpp
|
|
index d3ced10..59bb850 100644
|
|
--- languages/cpp/setuphelpers.cpp
|
|
+++ languages/cpp/setuphelpers.cpp
|
|
@@ -31,12 +31,13 @@
|
|
using namespace KDevelop;
|
|
|
|
namespace CppTools {
|
|
-QStringList gccSetupStandardIncludePaths();
|
|
-const QVector<rpp::pp_macro*>& gccStandardMacros();
|
|
|
|
#ifdef _MSC_VER
|
|
QStringList msvcSetupStandardIncludePaths();
|
|
const QVector<rpp::pp_macro*>& msvcStandardMacros();
|
|
+#else
|
|
+QStringList gccSetupStandardIncludePaths();
|
|
+const QVector<rpp::pp_macro*>& gccStandardMacros();
|
|
#endif
|
|
|
|
QStringList setupStandardIncludePaths()
|
|
diff --git a/languages/cpp/setuphelpers_gcc.cpp b/languages/cpp/setuphelpers_gcc.cpp
|
|
index 5b8fdda..83c6052 100644
|
|
--- languages/cpp/setuphelpers_gcc.cpp
|
|
+++ languages/cpp/setuphelpers_gcc.cpp
|
|
@@ -40,7 +40,7 @@ using namespace KDevelop;
|
|
|
|
namespace CppTools {
|
|
|
|
-QStringList gccSetupStandardIncludePaths()
|
|
+QStringList gccSetupStandardIncludePaths(bool withStdCpp0x)
|
|
{
|
|
QStringList includePaths;
|
|
|
|
@@ -59,7 +59,12 @@ QStringList gccSetupStandardIncludePaths()
|
|
// /usr/lib/gcc/i486-linux-gnu/4.1.2/include
|
|
// /usr/include
|
|
// End of search list.
|
|
- proc <<"gcc" << "-std=c++0x" <<"-xc++" <<"-E" <<"-v" <<NULL_DEVICE;
|
|
+ proc << "gcc";
|
|
+ if (withStdCpp0x) {
|
|
+ // see also: https://bugs.kde.org/show_bug.cgi?id=298252
|
|
+ proc << "-std=c++0x";
|
|
+ }
|
|
+ proc << "-xc++" << "-E" << "-v" << NULL_DEVICE;
|
|
|
|
// We'll use the following constants to know what we're currently parsing.
|
|
const short parsingInitial = 0;
|
|
@@ -100,6 +105,9 @@ QStringList gccSetupStandardIncludePaths()
|
|
}
|
|
}
|
|
}
|
|
+ } else if (withStdCpp0x) {
|
|
+ // fallback to include-path computation without -std=c++0x arg for old gcc versions
|
|
+ return gccSetupStandardIncludePaths(false);
|
|
} else {
|
|
kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
|
|
}
|
|
@@ -107,7 +115,12 @@ QStringList gccSetupStandardIncludePaths()
|
|
return includePaths;
|
|
}
|
|
|
|
-QVector<rpp::pp_macro*> computeGccStandardMacros()
|
|
+QStringList gccSetupStandardIncludePaths()
|
|
+{
|
|
+ return gccSetupStandardIncludePaths(true);
|
|
+}
|
|
+
|
|
+QVector<rpp::pp_macro*> computeGccStandardMacros(bool withStdCpp0x = true)
|
|
{
|
|
QVector<rpp::pp_macro*> ret;
|
|
//Get standard macros from gcc
|
|
@@ -117,7 +130,12 @@ QVector<rpp::pp_macro*> computeGccStandardMacros()
|
|
// The output of the following gcc commands is several line in the format:
|
|
// "#define MACRO [definition]", where definition may or may not be present.
|
|
// Parsing each line sequentially, we can easily build the macro set.
|
|
- proc <<"gcc" << "-std=c++0x" <<"-xc++" <<"-E" <<"-dM" <<NULL_DEVICE;
|
|
+ proc << "gcc";
|
|
+ if (withStdCpp0x) {
|
|
+ // see also: https://bugs.kde.org/show_bug.cgi?id=298252
|
|
+ proc << "-std=c++0x";
|
|
+ }
|
|
+ proc << "-xc++" << "-E" << "-dM" <<NULL_DEVICE;
|
|
|
|
if (proc.execute(5000) == 0) {
|
|
QString line;
|
|
@@ -141,6 +159,9 @@ QVector<rpp::pp_macro*> computeGccStandardMacros()
|
|
}
|
|
}
|
|
}
|
|
+ } else if (withStdCpp0x) {
|
|
+ // fallback to macro computation without -std=c++0x arg for old gcc versions
|
|
+ return computeGccStandardMacros(false);
|
|
} else {
|
|
kDebug(9007) <<"Unable to read standard c++ macro definitions from gcc:" <<QString(proc.readAll()) ;
|
|
}
|