Commit 9795976a authored by jkobus's avatar jkobus Committed by Jarek Kobus

Handle MinGW case in Add Library Wizard

Task-number: QTCREATORBUG-10423
Task-number: QTCREATORBUG-7641
Task-number: QTCREATORBUG-6093
Task-number: QTCREATORBUG-9012

Change-Id: Ibd709735fd90d635f34e42367b188fce79013fb5
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 04eaf6cd
...@@ -78,7 +78,8 @@ public: ...@@ -78,7 +78,8 @@ public:
enum Platform { enum Platform {
LinuxPlatform = 0x01, LinuxPlatform = 0x01,
MacPlatform = 0x02, MacPlatform = 0x02,
WindowsPlatform = 0x04 WindowsMinGWPlatform = 0x04,
WindowsMSVCPlatform = 0x08
}; };
Q_DECLARE_FLAGS(Platforms, Platform) Q_DECLARE_FLAGS(Platforms, Platform)
......
...@@ -55,7 +55,8 @@ LibraryDetailsController::LibraryDetailsController( ...@@ -55,7 +55,8 @@ LibraryDetailsController::LibraryDetailsController(
QObject(parent), QObject(parent),
m_platforms(AddLibraryWizard::LinuxPlatform m_platforms(AddLibraryWizard::LinuxPlatform
| AddLibraryWizard::MacPlatform | AddLibraryWizard::MacPlatform
| AddLibraryWizard::WindowsPlatform), | AddLibraryWizard::WindowsMinGWPlatform
| AddLibraryWizard::WindowsMSVCPlatform),
m_linkageType(AddLibraryWizard::NoLinkage), m_linkageType(AddLibraryWizard::NoLinkage),
m_macLibraryType(AddLibraryWizard::NoLibraryType), m_macLibraryType(AddLibraryWizard::NoLibraryType),
m_proFile(proFile), m_proFile(proFile),
...@@ -156,7 +157,8 @@ void LibraryDetailsController::updateGui() ...@@ -156,7 +157,8 @@ void LibraryDetailsController::updateGui()
if (libraryDetailsWidget()->macCheckBox->isChecked()) if (libraryDetailsWidget()->macCheckBox->isChecked())
m_platforms |= AddLibraryWizard::MacPlatform; m_platforms |= AddLibraryWizard::MacPlatform;
if (libraryDetailsWidget()->winCheckBox->isChecked()) if (libraryDetailsWidget()->winCheckBox->isChecked())
m_platforms |= AddLibraryWizard::WindowsPlatform; m_platforms |= AddLibraryWizard::WindowsMinGWPlatform
| AddLibraryWizard::WindowsMSVCPlatform;
bool macLibraryTypeUpdated = false; bool macLibraryTypeUpdated = false;
if (!m_linkageRadiosVisible) { if (!m_linkageRadiosVisible) {
...@@ -409,6 +411,21 @@ static QString appendSeparator(const QString &aString) ...@@ -409,6 +411,21 @@ static QString appendSeparator(const QString &aString)
return aString + QLatin1Char('/'); return aString + QLatin1Char('/');
} }
static QString windowsScopes(AddLibraryWizard::Platforms scopes)
{
QString scopesString;
QTextStream str(&scopesString);
AddLibraryWizard::Platforms windowsPlatforms = scopes
& (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform);
if (windowsPlatforms == AddLibraryWizard::WindowsMinGWPlatform)
str << "win32-g++"; // mingw only
else if (windowsPlatforms == AddLibraryWizard::WindowsMSVCPlatform)
str << "win32:!win32-g++"; // msvc only
else if (windowsPlatforms)
str << "win32"; // both mingw and msvc
return scopesString;
}
static QString commonScopes(AddLibraryWizard::Platforms scopes, static QString commonScopes(AddLibraryWizard::Platforms scopes,
AddLibraryWizard::Platforms excludedScopes) AddLibraryWizard::Platforms excludedScopes)
{ {
...@@ -416,7 +433,8 @@ static QString commonScopes(AddLibraryWizard::Platforms scopes, ...@@ -416,7 +433,8 @@ static QString commonScopes(AddLibraryWizard::Platforms scopes,
QTextStream str(&scopesString); QTextStream str(&scopesString);
AddLibraryWizard::Platforms common = scopes | excludedScopes; AddLibraryWizard::Platforms common = scopes | excludedScopes;
bool unixLikeScopes = false; bool unixLikeScopes = false;
if (scopes & ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::WindowsPlatform)) { if (scopes & ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::WindowsMinGWPlatform
| AddLibraryWizard::WindowsMSVCPlatform)) {
unixLikeScopes = true; unixLikeScopes = true;
if (common & AddLibraryWizard::LinuxPlatform) { if (common & AddLibraryWizard::LinuxPlatform) {
str << "unix"; str << "unix";
...@@ -427,10 +445,12 @@ static QString commonScopes(AddLibraryWizard::Platforms scopes, ...@@ -427,10 +445,12 @@ static QString commonScopes(AddLibraryWizard::Platforms scopes,
str << "macx"; str << "macx";
} }
} }
if (scopes & AddLibraryWizard::WindowsPlatform) { AddLibraryWizard::Platforms windowsPlatforms = scopes
& (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform);
if (windowsPlatforms) {
if (unixLikeScopes) if (unixLikeScopes)
str << "|"; str << "|";
str << "win32"; str << windowsScopes(windowsPlatforms);
} }
return scopesString; return scopesString;
} }
...@@ -457,7 +477,8 @@ static QString generateLibsSnippet(AddLibraryWizard::Platforms platforms, ...@@ -457,7 +477,8 @@ static QString generateLibsSnippet(AddLibraryWizard::Platforms platforms,
if (macLibraryType == AddLibraryWizard::FrameworkType) // we will generate a separate -F -framework line if (macLibraryType == AddLibraryWizard::FrameworkType) // we will generate a separate -F -framework line
commonPlatforms &= ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::MacPlatform); commonPlatforms &= ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::MacPlatform);
if (useSubfolders || addSuffix) // we will generate a separate debug/release conditions if (useSubfolders || addSuffix) // we will generate a separate debug/release conditions
commonPlatforms &= ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::WindowsPlatform); commonPlatforms &= ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::WindowsMinGWPlatform
| AddLibraryWizard::WindowsMSVCPlatform);
AddLibraryWizard::Platforms diffPlatforms = platforms ^ commonPlatforms; AddLibraryWizard::Platforms diffPlatforms = platforms ^ commonPlatforms;
AddLibraryWizard::Platforms generatedPlatforms = 0; AddLibraryWizard::Platforms generatedPlatforms = 0;
...@@ -465,19 +486,22 @@ static QString generateLibsSnippet(AddLibraryWizard::Platforms platforms, ...@@ -465,19 +486,22 @@ static QString generateLibsSnippet(AddLibraryWizard::Platforms platforms,
QString snippetMessage; QString snippetMessage;
QTextStream str(&snippetMessage); QTextStream str(&snippetMessage);
if (diffPlatforms & AddLibraryWizard::WindowsPlatform) { AddLibraryWizard::Platforms windowsPlatforms = diffPlatforms
str << "win32:CONFIG(release, debug|release): LIBS += "; & (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform);
if (windowsPlatforms) {
QString windowsString = windowsScopes(windowsPlatforms);
str << windowsString << ":CONFIG(release, debug|release): LIBS += ";
if (useSubfolders) if (useSubfolders)
str << simpleLibraryPathSnippet << "release/ " << "-l" << libName << "\n"; str << simpleLibraryPathSnippet << "release/ " << "-l" << libName << "\n";
else if (addSuffix) else if (addSuffix)
str << appendSpaceIfNotEmpty(simpleLibraryPathSnippet) << "-l" << libName << "\n"; str << appendSpaceIfNotEmpty(simpleLibraryPathSnippet) << "-l" << libName << "\n";
str << "else:win32:CONFIG(debug, debug|release): LIBS += "; str << "else:" << windowsString << ":CONFIG(debug, debug|release): LIBS += ";
if (useSubfolders) if (useSubfolders)
str << simpleLibraryPathSnippet << "debug/ " << "-l" << libName << "\n"; str << simpleLibraryPathSnippet << "debug/ " << "-l" << libName << "\n";
else if (addSuffix) else if (addSuffix)
str << appendSpaceIfNotEmpty(simpleLibraryPathSnippet) << "-l" << libName << "d\n"; str << appendSpaceIfNotEmpty(simpleLibraryPathSnippet) << "-l" << libName << "d\n";
generatedPlatforms |= AddLibraryWizard::WindowsPlatform; generatedPlatforms |= windowsPlatforms;
} }
if (diffPlatforms & AddLibraryWizard::MacPlatform) { if (diffPlatforms & AddLibraryWizard::MacPlatform) {
if (generatedPlatforms) if (generatedPlatforms)
...@@ -521,28 +545,55 @@ static QString generatePreTargetDepsSnippet(AddLibraryWizard::Platforms platform ...@@ -521,28 +545,55 @@ static QString generatePreTargetDepsSnippet(AddLibraryWizard::Platforms platform
QTextStream str(&snippetMessage); QTextStream str(&snippetMessage);
str << "\n"; str << "\n";
AddLibraryWizard::Platforms generatedPlatforms = 0; AddLibraryWizard::Platforms generatedPlatforms = 0;
if (platforms & AddLibraryWizard::WindowsPlatform) { AddLibraryWizard::Platforms windowsPlatforms = platforms
& (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform);
AddLibraryWizard::Platforms commonPlatforms = platforms;
if (useSubfolders || addSuffix) // we will generate a separate debug/release conditions, otherwise mingw is unix like
commonPlatforms &= ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::WindowsMinGWPlatform);
commonPlatforms &= ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::WindowsMSVCPlatform); // this case is different from all platforms
if (windowsPlatforms) {
if (useSubfolders || addSuffix) { if (useSubfolders || addSuffix) {
str << "win32:CONFIG(release, debug|release): " if (windowsPlatforms & AddLibraryWizard::WindowsMinGWPlatform) {
<< preTargetDepsSnippet; str << "win32-g++:CONFIG(release, debug|release): "
if (useSubfolders) << preTargetDepsSnippet;
str << "release/" << libName << ".lib\n"; if (useSubfolders)
else if (addSuffix) str << "release/" << "lib" << libName << ".a\n";
str << libName << ".lib\n"; else if (addSuffix)
str << "lib" << libName << ".a\n";
str << "else:win32:CONFIG(debug, debug|release): "
<< preTargetDepsSnippet; str << "else:win32-g++:CONFIG(debug, debug|release): "
if (useSubfolders) << preTargetDepsSnippet;
str << "debug/" << libName << ".lib\n"; if (useSubfolders)
else if (addSuffix) str << "debug/" << "lib" << libName << ".a\n";
str << libName << "d.lib\n"; else if (addSuffix)
str << "lib" << libName << "d.a\n";
}
if (windowsPlatforms & AddLibraryWizard::WindowsMSVCPlatform) {
if (windowsPlatforms & AddLibraryWizard::WindowsMinGWPlatform)
str << "else:";
str << "win32:!win32-g++:CONFIG(release, debug|release): "
<< preTargetDepsSnippet;
if (useSubfolders)
str << "release/" << libName << ".lib\n";
else if (addSuffix)
str << libName << ".lib\n";
str << "else:win32:!win32-g++:CONFIG(debug, debug|release): "
<< preTargetDepsSnippet;
if (useSubfolders)
str << "debug/" << libName << ".lib\n";
else if (addSuffix)
str << libName << "d.lib\n";
}
generatedPlatforms |= windowsPlatforms;
} else { } else {
str << "win32: " << preTargetDepsSnippet << libName << ".lib\n"; if (windowsPlatforms & AddLibraryWizard::WindowsMSVCPlatform) {
str << "win32:!win32-g++ " << preTargetDepsSnippet << libName << ".lib\n";
generatedPlatforms |= AddLibraryWizard::WindowsMSVCPlatform; // mingw will be handled with common scopes
}
// mingw not generated yet, will be joined with unix like
} }
generatedPlatforms |= AddLibraryWizard::WindowsPlatform;
} }
AddLibraryWizard::Platforms commonPlatforms = platforms;
commonPlatforms &= ~QFlags<AddLibraryWizard::Platform>(AddLibraryWizard::WindowsPlatform);
if (commonPlatforms) { if (commonPlatforms) {
if (generatedPlatforms) if (generatedPlatforms)
str << "else:"; str << "else:";
...@@ -562,7 +613,7 @@ NonInternalLibraryDetailsController::NonInternalLibraryDetailsController( ...@@ -562,7 +613,7 @@ NonInternalLibraryDetailsController::NonInternalLibraryDetailsController(
if (creatorPlatform() == CreatorWindows) { if (creatorPlatform() == CreatorWindows) {
libraryDetailsWidget()->libraryPathChooser->setPromptDialogFilter( libraryDetailsWidget()->libraryPathChooser->setPromptDialogFilter(
QLatin1String("Library file (*.lib)")); QLatin1String("Library file (*.lib lib*.a)"));
setLinkageRadiosVisible(true); setLinkageRadiosVisible(true);
setRemoveSuffixVisible(true); setRemoveSuffixVisible(true);
} else { } else {
...@@ -646,7 +697,7 @@ QString NonInternalLibraryDetailsController::suggestedIncludePath() const ...@@ -646,7 +697,7 @@ QString NonInternalLibraryDetailsController::suggestedIncludePath() const
void NonInternalLibraryDetailsController::updateWindowsOptionsEnablement() void NonInternalLibraryDetailsController::updateWindowsOptionsEnablement()
{ {
bool ena = platforms() & AddLibraryWizard::WindowsPlatform; bool ena = platforms() & (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform);
if (creatorPlatform() == CreatorWindows) { if (creatorPlatform() == CreatorWindows) {
libraryDetailsWidget()->addSuffixCheckBox->setEnabled(ena); libraryDetailsWidget()->addSuffixCheckBox->setEnabled(ena);
ena = true; ena = true;
...@@ -725,6 +776,8 @@ QString NonInternalLibraryDetailsController::snippet() const ...@@ -725,6 +776,8 @@ QString NonInternalLibraryDetailsController::snippet() const
libName = fi.baseName(); libName = fi.baseName();
if (removeSuffix && !libName.isEmpty()) // remove last letter which needs to be "d" if (removeSuffix && !libName.isEmpty()) // remove last letter which needs to be "d"
libName = libName.left(libName.size() - 1); libName = libName.left(libName.size() - 1);
if (fi.completeSuffix() == QLatin1String("a")) // the mingw lib case
libName = libName.mid(3); // cut the "lib" prefix
} else if (creatorPlatform() == CreatorMac) { } else if (creatorPlatform() == CreatorMac) {
if (macLibraryType() == AddLibraryWizard::FrameworkType) if (macLibraryType() == AddLibraryWizard::FrameworkType)
libName = fi.baseName(); libName = fi.baseName();
...@@ -742,10 +795,11 @@ QString NonInternalLibraryDetailsController::snippet() const ...@@ -742,10 +795,11 @@ QString NonInternalLibraryDetailsController::snippet() const
// when we are on Win but we don't generate the code for Win // when we are on Win but we don't generate the code for Win
// we still need to remove "debug" or "release" subfolder // we still need to remove "debug" or "release" subfolder
const bool useSubfoldersCondition = (creatorPlatform() == CreatorWindows) const bool useSubfoldersCondition = (creatorPlatform() == CreatorWindows)
? true : platforms() & AddLibraryWizard::WindowsPlatform; ? true : platforms() & (AddLibraryWizard::WindowsMinGWPlatform
| AddLibraryWizard::WindowsMSVCPlatform);
if (useSubfoldersCondition) if (useSubfoldersCondition)
useSubfolders = libraryDetailsWidget()->useSubfoldersCheckBox->isChecked(); useSubfolders = libraryDetailsWidget()->useSubfoldersCheckBox->isChecked();
if (platforms() & AddLibraryWizard::WindowsPlatform) if (platforms() & (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform))
addSuffix = libraryDetailsWidget()->addSuffixCheckBox->isChecked() || removeSuffix; addSuffix = libraryDetailsWidget()->addSuffixCheckBox->isChecked() || removeSuffix;
} }
if (isIncludePathVisible()) { // generate also the path to lib if (isIncludePathVisible()) { // generate also the path to lib
...@@ -960,7 +1014,7 @@ void InternalLibraryDetailsController::updateWindowsOptionsEnablement() ...@@ -960,7 +1014,7 @@ void InternalLibraryDetailsController::updateWindowsOptionsEnablement()
if (creatorPlatform() == CreatorWindows) if (creatorPlatform() == CreatorWindows)
libraryDetailsWidget()->addSuffixCheckBox->setEnabled(true); libraryDetailsWidget()->addSuffixCheckBox->setEnabled(true);
libraryDetailsWidget()->winGroupBox->setEnabled(platforms() libraryDetailsWidget()->winGroupBox->setEnabled(platforms()
& AddLibraryWizard::WindowsPlatform); & (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform));
} }
void InternalLibraryDetailsController::updateProFile() void InternalLibraryDetailsController::updateProFile()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment