1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "qtprojectparameters.h"
35 #include <utils/codegeneration.h>
37 #include <QtCore/QTextStream>
38 #include <QtCore/QDir>
39 #include <QtCore/QCoreApplication>
40 #include <QtCore/QDateTime>
41 #include <QtCore/QDebug>
43 namespace Qt4ProjectManager {
46 // ----------- QtProjectParameters
47 QtProjectParameters::QtProjectParameters()
52 QString QtProjectParameters::projectPath() const
56 rc += QDir::separator();
61 void QtProjectParameters::writeProFile(QTextStream &str) const
63 if (!selectedModules.isEmpty())
64 str << "QT += " << selectedModules << "\n\n";
65 if (!deselectedModules.isEmpty())
66 str << "QT -= " << deselectedModules << "\n\n";
67 const QString &effectiveTarget = target.isEmpty() ? fileName : target;
68 if (!effectiveTarget.isEmpty())
69 str << "TARGET = " << effectiveTarget << '\n';
72 // Mac: Command line apps should not be bundles
73 str << "CONFIG += console\nCONFIG -= app_bundle\n\n";
75 str << "TEMPLATE = app\n";
78 str << "TEMPLATE = lib\nCONFIG += staticlib\n";
81 str << "TEMPLATE = lib\n\nDEFINES += " << libraryMacro(fileName) << '\n';
84 str << "TEMPLATE = lib\nCONFIG += plugin\n";
90 if (!targetDirectory.isEmpty())
91 str << "\nDESTDIR = " << targetDirectory << '\n';
94 void QtProjectParameters::writeProFileHeader(QTextStream &str)
96 const QChar hash = QLatin1Char ('#');
97 const QChar nl = QLatin1Char('\n');
98 const QChar blank = QLatin1Char(' ');
99 // Format as '#-------\n# <Header> \n#---------'
100 QString header = QLatin1String(" Project created by ");
101 header += QCoreApplication::applicationName();
103 header += QDateTime::currentDateTime().toString(Qt::ISODate);
104 const QString line = QString(header.size(), QLatin1Char('-'));
105 str << hash << line << nl << hash << nl << hash << header << nl
106 << hash <<nl << hash << line << nl << nl;
110 QString createMacro(const QString &name, const QString &suffix)
112 QString rc = name.toUpper();
113 const int extensionPosition = rc.indexOf(QLatin1Char('.'));
114 if (extensionPosition != -1)
115 rc.truncate(extensionPosition);
117 return Utils::fileNameToCppIdentifier(rc);
120 QString QtProjectParameters::exportMacro(const QString &projectName)
122 return createMacro(projectName, QLatin1String("SHARED_EXPORT"));
125 QString QtProjectParameters::libraryMacro(const QString &projectName)
127 return createMacro(projectName, QLatin1String("_LIBRARY"));
130 } // namespace Internal
131 } // namespace Qt4ProjectManager