2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the qmake application of the Qt Toolkit.
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-09-19 12:28:29 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "projectgenerator.h"
|
|
|
|
#include "option.h"
|
|
|
|
#include <qdatetime.h>
|
|
|
|
#include <qdir.h>
|
|
|
|
#include <qfile.h>
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
#include <qregexp.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
QString project_builtin_regx() //calculate the builtin regular expression..
|
|
|
|
{
|
|
|
|
QString ret;
|
|
|
|
QStringList builtin_exts;
|
|
|
|
builtin_exts << Option::c_ext << Option::ui_ext << Option::yacc_ext << Option::lex_ext << ".ts" << ".xlf" << ".qrc";
|
|
|
|
builtin_exts += Option::h_ext + Option::cpp_ext;
|
|
|
|
for(int i = 0; i < builtin_exts.size(); ++i) {
|
|
|
|
if(!ret.isEmpty())
|
|
|
|
ret += "; ";
|
|
|
|
ret += QString("*") + builtin_exts[i];
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-11 18:04:42 +00:00
|
|
|
ProjectGenerator::ProjectGenerator() : MakefileGenerator()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ProjectGenerator::init()
|
|
|
|
{
|
|
|
|
int file_count = 0;
|
|
|
|
verifyCompilers();
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
project->loadSpec();
|
|
|
|
project->evaluateFeatureFile("default_pre.prf");
|
|
|
|
project->evaluateFeatureFile("default_post.prf");
|
|
|
|
project->evaluateConfigFeatures();
|
2012-04-23 16:08:16 +00:00
|
|
|
project->values("CONFIG").clear();
|
2012-08-03 17:35:54 +00:00
|
|
|
Option::postProcessProject(project);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProValueMap &v = project->variables();
|
2012-09-05 16:29:19 +00:00
|
|
|
QString templ = Option::globals->user_template.isEmpty() ? QString("app") : Option::globals->user_template;
|
|
|
|
if (!Option::globals->user_template_prefix.isEmpty())
|
|
|
|
templ.prepend(Option::globals->user_template_prefix);
|
2011-04-27 10:05:43 +00:00
|
|
|
v["TEMPLATE_ASSIGN"] += templ;
|
|
|
|
|
|
|
|
//the scary stuff
|
|
|
|
if(project->first("TEMPLATE_ASSIGN") != "subdirs") {
|
|
|
|
QString builtin_regex = project_builtin_regx();
|
|
|
|
QStringList dirs = Option::projfile::project_dirs;
|
|
|
|
if(Option::projfile::do_pwd) {
|
|
|
|
if(!v["INCLUDEPATH"].contains("."))
|
|
|
|
v["INCLUDEPATH"] += ".";
|
|
|
|
dirs.prepend(qmake_getpwd());
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < dirs.count(); ++i) {
|
|
|
|
QString dir, regex, pd = dirs.at(i);
|
|
|
|
bool add_depend = false;
|
|
|
|
if(exists(pd)) {
|
|
|
|
QFileInfo fi(fileInfo(pd));
|
|
|
|
if(fi.isDir()) {
|
|
|
|
dir = pd;
|
|
|
|
add_depend = true;
|
|
|
|
if(dir.right(1) != Option::dir_sep)
|
|
|
|
dir += Option::dir_sep;
|
2012-05-04 18:02:35 +00:00
|
|
|
if (Option::recursive) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QStringList files = QDir(dir).entryList(QDir::Files);
|
2014-04-29 12:17:33 +00:00
|
|
|
for (int i = 0; i < files.count(); i++)
|
|
|
|
dirs.append(dir + files[i] + QDir::separator() + builtin_regex);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
regex = builtin_regex;
|
|
|
|
} else {
|
|
|
|
QString file = pd;
|
|
|
|
int s = file.lastIndexOf(Option::dir_sep);
|
|
|
|
if(s != -1)
|
|
|
|
dir = file.left(s+1);
|
|
|
|
if(addFile(file)) {
|
|
|
|
add_depend = true;
|
|
|
|
file_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { //regexp
|
|
|
|
regex = pd;
|
|
|
|
}
|
|
|
|
if(!regex.isEmpty()) {
|
|
|
|
int s = regex.lastIndexOf(Option::dir_sep);
|
|
|
|
if(s != -1) {
|
|
|
|
dir = regex.left(s+1);
|
|
|
|
regex = regex.right(regex.length() - (s+1));
|
|
|
|
}
|
2012-05-04 18:02:35 +00:00
|
|
|
if (Option::recursive) {
|
2014-04-29 10:42:54 +00:00
|
|
|
QStringList entries = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
|
|
|
for (int i = 0; i < entries.count(); i++)
|
|
|
|
dirs.append(dir + entries[i] + QDir::separator() + regex);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regex));
|
|
|
|
for(int i = 0; i < (int)files.count(); i++) {
|
|
|
|
QString file = dir + files[i];
|
|
|
|
if (addFile(file)) {
|
|
|
|
add_depend = true;
|
|
|
|
file_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(add_depend && !dir.isEmpty() && !v["DEPENDPATH"].contains(dir, Qt::CaseInsensitive)) {
|
|
|
|
QFileInfo fi(fileInfo(dir));
|
|
|
|
if(fi.absoluteFilePath() != qmake_getpwd())
|
|
|
|
v["DEPENDPATH"] += fileFixify(dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!file_count) { //shall we try a subdir?
|
|
|
|
QStringList knownDirs = Option::projfile::project_dirs;
|
|
|
|
if(Option::projfile::do_pwd)
|
|
|
|
knownDirs.prepend(".");
|
|
|
|
const QString out_file = fileFixify(Option::output.fileName());
|
|
|
|
for(int i = 0; i < knownDirs.count(); ++i) {
|
|
|
|
QString pd = knownDirs.at(i);
|
|
|
|
if(exists(pd)) {
|
|
|
|
QString newdir = pd;
|
|
|
|
QFileInfo fi(fileInfo(newdir));
|
|
|
|
if(fi.isDir()) {
|
2016-12-12 11:57:47 +00:00
|
|
|
newdir = fileFixify(newdir, FileFixifyFromOutdir);
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &subdirs = v["SUBDIRS"];
|
2011-04-27 10:05:43 +00:00
|
|
|
if(exists(fi.filePath() + QDir::separator() + fi.fileName() + Option::pro_ext) &&
|
|
|
|
!subdirs.contains(newdir, Qt::CaseInsensitive)) {
|
|
|
|
subdirs.append(newdir);
|
|
|
|
} else {
|
|
|
|
QStringList profiles = QDir(newdir).entryList(QStringList("*" + Option::pro_ext), QDir::Files);
|
|
|
|
for(int i = 0; i < (int)profiles.count(); i++) {
|
|
|
|
QString nd = newdir;
|
|
|
|
if(nd == ".")
|
|
|
|
nd = "";
|
2015-10-10 08:00:32 +00:00
|
|
|
else if (!nd.isEmpty() && !nd.endsWith(QDir::separator()))
|
2011-04-27 10:05:43 +00:00
|
|
|
nd += QDir::separator();
|
|
|
|
nd += profiles[i];
|
|
|
|
fileFixify(nd);
|
2014-04-29 12:17:33 +00:00
|
|
|
if (!subdirs.contains(nd, Qt::CaseInsensitive) && !out_file.endsWith(nd))
|
2011-04-27 10:05:43 +00:00
|
|
|
subdirs.append(nd);
|
|
|
|
}
|
|
|
|
}
|
2012-05-04 18:02:35 +00:00
|
|
|
if (Option::recursive) {
|
2014-04-29 10:42:54 +00:00
|
|
|
QStringList dirs = QDir(newdir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int i = 0; i < (int)dirs.count(); i++) {
|
|
|
|
QString nd = fileFixify(newdir + QDir::separator() + dirs[i]);
|
2014-04-29 10:42:54 +00:00
|
|
|
if (!knownDirs.contains(nd, Qt::CaseInsensitive))
|
2011-04-27 10:05:43 +00:00
|
|
|
knownDirs.append(nd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { //regexp
|
|
|
|
QString regx = pd, dir;
|
|
|
|
int s = regx.lastIndexOf(Option::dir_sep);
|
|
|
|
if(s != -1) {
|
|
|
|
dir = regx.left(s+1);
|
|
|
|
regx = regx.right(regx.length() - (s+1));
|
|
|
|
}
|
2014-04-29 10:42:54 +00:00
|
|
|
QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regx),
|
|
|
|
QDir::Dirs | QDir::NoDotAndDotDot);
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &subdirs = v["SUBDIRS"];
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int i = 0; i < (int)files.count(); i++) {
|
|
|
|
QString newdir(dir + files[i]);
|
|
|
|
QFileInfo fi(fileInfo(newdir));
|
2014-04-29 10:42:54 +00:00
|
|
|
{
|
2011-04-27 10:05:43 +00:00
|
|
|
newdir = fileFixify(newdir);
|
|
|
|
if(exists(fi.filePath() + QDir::separator() + fi.fileName() + Option::pro_ext) &&
|
|
|
|
!subdirs.contains(newdir)) {
|
|
|
|
subdirs.append(newdir);
|
|
|
|
} else {
|
|
|
|
QStringList profiles = QDir(newdir).entryList(QStringList("*" + Option::pro_ext), QDir::Files);
|
|
|
|
for(int i = 0; i < (int)profiles.count(); i++) {
|
|
|
|
QString nd = newdir + QDir::separator() + files[i];
|
|
|
|
fileFixify(nd);
|
|
|
|
if(files[i] != "." && files[i] != ".." && !subdirs.contains(nd, Qt::CaseInsensitive)) {
|
|
|
|
if(newdir + files[i] != Option::output_dir + Option::output.fileName())
|
|
|
|
subdirs.append(nd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-04 18:02:35 +00:00
|
|
|
if (Option::recursive && !knownDirs.contains(newdir, Qt::CaseInsensitive))
|
2011-04-27 10:05:43 +00:00
|
|
|
knownDirs.append(newdir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-06 10:21:38 +00:00
|
|
|
v["TEMPLATE_ASSIGN"] = ProStringList("subdirs");
|
2011-04-27 10:05:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//setup deplist
|
|
|
|
QList<QMakeLocalFileName> deplist;
|
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &d = v["DEPENDPATH"];
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int i = 0; i < d.size(); ++i)
|
2012-09-06 10:21:38 +00:00
|
|
|
deplist.append(QMakeLocalFileName(d[i].toQString()));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
setDependencyPaths(deplist);
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &h = v["HEADERS"];
|
2011-04-27 10:05:43 +00:00
|
|
|
bool no_qt_files = true;
|
2012-08-20 11:04:39 +00:00
|
|
|
static const char *srcs[] = { "SOURCES", "YACCSOURCES", "LEXSOURCES", "FORMS", 0 };
|
|
|
|
for (int i = 0; srcs[i]; i++) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &l = v[srcs[i]];
|
2011-04-27 10:05:43 +00:00
|
|
|
QMakeSourceFileInfo::SourceFileType type = QMakeSourceFileInfo::TYPE_C;
|
|
|
|
QMakeSourceFileInfo::addSourceFiles(l, QMakeSourceFileInfo::SEEK_DEPS, type);
|
|
|
|
for(int i = 0; i < l.size(); ++i) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QStringList tmp = QMakeSourceFileInfo::dependencies(l.at(i).toQString());
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!tmp.isEmpty()) {
|
|
|
|
for(int dep_it = 0; dep_it < tmp.size(); ++dep_it) {
|
|
|
|
QString dep = tmp[dep_it];
|
|
|
|
dep = fixPathToQmake(dep);
|
|
|
|
QString file_dir = dep.section(Option::dir_sep, 0, -2),
|
|
|
|
file_no_path = dep.section(Option::dir_sep, -1);
|
|
|
|
if(!file_dir.isEmpty()) {
|
|
|
|
for(int inc_it = 0; inc_it < deplist.size(); ++inc_it) {
|
|
|
|
QMakeLocalFileName inc = deplist[inc_it];
|
|
|
|
if(inc.local() == file_dir && !v["INCLUDEPATH"].contains(inc.real(), Qt::CaseInsensitive))
|
|
|
|
v["INCLUDEPATH"] += inc.real();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(no_qt_files && file_no_path.indexOf(QRegExp("^q[a-z_0-9].h$")) != -1)
|
|
|
|
no_qt_files = false;
|
|
|
|
QString h_ext;
|
|
|
|
for(int hit = 0; hit < Option::h_ext.size(); ++hit) {
|
|
|
|
if(dep.endsWith(Option::h_ext.at(hit))) {
|
|
|
|
h_ext = Option::h_ext.at(hit);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!h_ext.isEmpty()) {
|
|
|
|
for(int cppit = 0; cppit < Option::cpp_ext.size(); ++cppit) {
|
|
|
|
QString src(dep.left(dep.length() - h_ext.length()) +
|
|
|
|
Option::cpp_ext.at(cppit));
|
|
|
|
if(exists(src)) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &srcl = v["SOURCES"];
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!srcl.contains(src, Qt::CaseInsensitive))
|
|
|
|
srcl.append(src);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(dep.endsWith(Option::lex_ext) &&
|
|
|
|
file_no_path.startsWith(Option::lex_mod)) {
|
|
|
|
addConfig("lex_included");
|
|
|
|
}
|
|
|
|
if(!h.contains(dep, Qt::CaseInsensitive))
|
|
|
|
h += dep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//strip out files that are actually output from internal compilers (ie temporary files)
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
|
|
|
|
for (ProStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) {
|
|
|
|
QString tmp_out = project->first(ProKey(*it + ".output")).toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(tmp_out.isEmpty())
|
|
|
|
continue;
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList var_out = project->values(ProKey(*it + ".variable_out"));
|
2011-04-27 10:05:43 +00:00
|
|
|
bool defaults = var_out.isEmpty();
|
|
|
|
for(int i = 0; i < var_out.size(); ++i) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProString v = var_out.at(i);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(v.startsWith("GENERATED_")) {
|
|
|
|
defaults = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(defaults) {
|
|
|
|
var_out << "SOURCES";
|
|
|
|
var_out << "HEADERS";
|
|
|
|
var_out << "FORMS";
|
|
|
|
}
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &tmp = project->values(ProKey(*it + ".input"));
|
|
|
|
for (ProStringList::ConstIterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
|
|
|
|
ProStringList &inputs = project->values((*it2).toKey());
|
|
|
|
for (ProStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
|
2014-11-20 15:20:16 +00:00
|
|
|
QString path = replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString(), NoShell);
|
2011-04-27 10:05:43 +00:00
|
|
|
path = fixPathToQmake(path).section('/', -1);
|
|
|
|
for(int i = 0; i < var_out.size(); ++i) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProString v = var_out.at(i);
|
|
|
|
ProStringList &list = project->values(v.toKey());
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int src = 0; src < list.size(); ) {
|
|
|
|
if(list[src] == path || list[src].endsWith("/" + path))
|
|
|
|
list.removeAt(src);
|
|
|
|
else
|
|
|
|
++src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ProjectGenerator::writeMakefile(QTextStream &t)
|
|
|
|
{
|
|
|
|
t << "######################################################################" << endl;
|
2012-09-12 17:27:09 +00:00
|
|
|
t << "# Automatically generated by qmake (" QMAKE_VERSION_STR ") " << QDateTime::currentDateTime().toString() << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
t << "######################################################################" << endl << endl;
|
2017-02-03 17:12:52 +00:00
|
|
|
if (!Option::globals->extra_cmds[QMakeEvalBefore].isEmpty())
|
|
|
|
t << Option::globals->extra_cmds[QMakeEvalBefore] << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
t << getWritableVar("TEMPLATE_ASSIGN", false);
|
|
|
|
if(project->first("TEMPLATE_ASSIGN") == "subdirs") {
|
|
|
|
t << endl << "# Directories" << "\n"
|
|
|
|
<< getWritableVar("SUBDIRS");
|
|
|
|
} else {
|
2012-02-24 08:10:52 +00:00
|
|
|
//figure out target
|
|
|
|
QString ofn = QFileInfo(static_cast<QFile *>(t.device())->fileName()).completeBaseName();
|
|
|
|
if (ofn.isEmpty() || ofn == "-")
|
|
|
|
ofn = "unknown";
|
2012-09-06 10:21:38 +00:00
|
|
|
project->values("TARGET_ASSIGN") = ProStringList(ofn);
|
2012-02-24 08:10:52 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
t << getWritableVar("TARGET_ASSIGN")
|
|
|
|
<< getWritableVar("CONFIG", false)
|
|
|
|
<< getWritableVar("CONFIG_REMOVE", false)
|
|
|
|
<< getWritableVar("INCLUDEPATH") << endl;
|
|
|
|
|
2016-12-13 13:18:23 +00:00
|
|
|
t << "# The following define makes your compiler warn you if you use any\n"
|
|
|
|
"# feature of Qt which has been marked as deprecated (the exact warnings\n"
|
2016-10-24 19:04:37 +00:00
|
|
|
"# depend on your compiler). Please consult the documentation of the\n"
|
|
|
|
"# deprecated API in order to know how to port your code away from it.\n"
|
|
|
|
"DEFINES += QT_DEPRECATED_WARNINGS\n"
|
|
|
|
"\n"
|
|
|
|
"# You can also make your code fail to compile if you use deprecated APIs.\n"
|
|
|
|
"# In order to do so, uncomment the following line.\n"
|
|
|
|
"# You can also select to disable deprecated APIs only up to a certain version of Qt.\n"
|
|
|
|
"#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0\n\n";
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
t << "# Input" << "\n";
|
|
|
|
t << getWritableVar("HEADERS")
|
|
|
|
<< getWritableVar("FORMS")
|
|
|
|
<< getWritableVar("LEXSOURCES")
|
|
|
|
<< getWritableVar("YACCSOURCES")
|
|
|
|
<< getWritableVar("SOURCES")
|
|
|
|
<< getWritableVar("RESOURCES")
|
|
|
|
<< getWritableVar("TRANSLATIONS");
|
|
|
|
}
|
2017-02-03 17:12:52 +00:00
|
|
|
if (!Option::globals->extra_cmds[QMakeEvalAfter].isEmpty())
|
|
|
|
t << Option::globals->extra_cmds[QMakeEvalAfter] << endl;
|
2011-04-27 10:05:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ProjectGenerator::addConfig(const QString &cfg, bool add)
|
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
ProKey where = "CONFIG";
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!add)
|
|
|
|
where = "CONFIG_REMOVE";
|
2012-04-23 16:08:16 +00:00
|
|
|
if (!project->values(where).contains(cfg)) {
|
|
|
|
project->values(where) += cfg;
|
2011-04-27 10:05:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ProjectGenerator::addFile(QString file)
|
|
|
|
{
|
2015-04-13 19:18:36 +00:00
|
|
|
file = fileFixify(file, FileFixifyToIndir);
|
2011-04-27 10:05:43 +00:00
|
|
|
QString dir;
|
|
|
|
int s = file.lastIndexOf(Option::dir_sep);
|
|
|
|
if(s != -1)
|
|
|
|
dir = file.left(s+1);
|
|
|
|
if(file.mid(dir.length(), Option::h_moc_mod.length()) == Option::h_moc_mod)
|
|
|
|
return false;
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProKey where;
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int cppit = 0; cppit < Option::cpp_ext.size(); ++cppit) {
|
|
|
|
if(file.endsWith(Option::cpp_ext[cppit])) {
|
|
|
|
where = "SOURCES";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(where.isEmpty()) {
|
|
|
|
for(int hit = 0; hit < Option::h_ext.size(); ++hit)
|
|
|
|
if(file.endsWith(Option::h_ext.at(hit))) {
|
|
|
|
where = "HEADERS";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(where.isEmpty()) {
|
|
|
|
for(int cit = 0; cit < Option::c_ext.size(); ++cit) {
|
|
|
|
if(file.endsWith(Option::c_ext[cit])) {
|
|
|
|
where = "SOURCES";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(where.isEmpty()) {
|
|
|
|
if(file.endsWith(Option::ui_ext))
|
|
|
|
where = "FORMS";
|
|
|
|
else if(file.endsWith(Option::lex_ext))
|
|
|
|
where = "LEXSOURCES";
|
|
|
|
else if(file.endsWith(Option::yacc_ext))
|
|
|
|
where = "YACCSOURCES";
|
|
|
|
else if(file.endsWith(".ts") || file.endsWith(".xlf"))
|
|
|
|
where = "TRANSLATIONS";
|
|
|
|
else if(file.endsWith(".qrc"))
|
|
|
|
where = "RESOURCES";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString newfile = fixPathToQmake(fileFixify(file));
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &endList = project->values(where);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!endList.contains(newfile, Qt::CaseInsensitive)) {
|
|
|
|
endList += newfile;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
2012-09-06 10:21:38 +00:00
|
|
|
ProjectGenerator::getWritableVar(const char *vk, bool)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProKey v(vk);
|
|
|
|
ProStringList &vals = project->values(v);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(vals.isEmpty())
|
|
|
|
return "";
|
|
|
|
|
|
|
|
// If values contain spaces, ensure that they are quoted
|
2012-09-06 10:21:38 +00:00
|
|
|
for (ProStringList::iterator it = vals.begin(); it != vals.end(); ++it) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if ((*it).contains(' ') && !(*it).startsWith(' '))
|
2012-09-06 10:21:38 +00:00
|
|
|
*it = "\"" + *it + "\"";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString ret;
|
|
|
|
if(v.endsWith("_REMOVE"))
|
|
|
|
ret = v.left(v.length() - 7) + " -= ";
|
|
|
|
else if(v.endsWith("_ASSIGN"))
|
|
|
|
ret = v.left(v.length() - 7) + " = ";
|
|
|
|
else
|
|
|
|
ret = v + " += ";
|
2012-05-18 18:00:23 +00:00
|
|
|
QString join = vals.join(' ');
|
2011-04-27 10:05:43 +00:00
|
|
|
if(ret.length() + join.length() > 80) {
|
|
|
|
QString spaces;
|
|
|
|
for(int i = 0; i < ret.length(); i++)
|
|
|
|
spaces += " ";
|
|
|
|
join = vals.join(" \\\n" + spaces);
|
|
|
|
}
|
|
|
|
return ret + join + "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ProjectGenerator::openOutput(QFile &file, const QString &build) const
|
|
|
|
{
|
|
|
|
QString outdir;
|
|
|
|
if(!file.fileName().isEmpty()) {
|
|
|
|
QFileInfo fi(fileInfo(file.fileName()));
|
|
|
|
if(fi.isDir())
|
|
|
|
outdir = fi.path() + QDir::separator();
|
|
|
|
}
|
|
|
|
if(!outdir.isEmpty() || file.fileName().isEmpty()) {
|
|
|
|
QString dir = qmake_getpwd();
|
|
|
|
int s = dir.lastIndexOf('/');
|
|
|
|
if(s != -1)
|
|
|
|
dir = dir.right(dir.length() - (s + 1));
|
|
|
|
file.setFileName(outdir + dir + Option::pro_ext);
|
|
|
|
}
|
|
|
|
return MakefileGenerator::openOutput(file, build);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
ProjectGenerator::fixPathToQmake(const QString &file)
|
|
|
|
{
|
|
|
|
QString ret = file;
|
|
|
|
if(Option::dir_sep != QLatin1String("/"))
|
2014-11-27 14:02:50 +00:00
|
|
|
ret.replace(Option::dir_sep, QLatin1String("/"));
|
2011-04-27 10:05:43 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|