~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to qcm/conf.qcm

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-07-01 21:49:34 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140701214934-gt4dkgm94byi4vnn
Tags: 0.15-1
* New upstream version
* set debhelper compat level to 9
* set Standards-Version to 3.9.5 (no further changes)
* add lintian override regarding license-problem-non-free-RFC
* use qconf to regenerate configure script
* implement hardening using buildflags instead of hardening-wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
-----END QCMOD-----
5
5
*/
6
6
 
7
 
//----------------------------------------------------------------------------
8
 
// qc_conf
9
 
//----------------------------------------------------------------------------
 
7
#include <QDateTime>
 
8
 
 
9
static bool psiGenerateFile(const QString &inFile, const QString &outFile, const QHash<QString,QString> &vars)
 
10
{
 
11
        QFile fin(inFile);
 
12
        QFile fout(outFile);
 
13
        if(!fin.open(QIODevice::ReadOnly | QIODevice::Text) || !fout.open(QIODevice::WriteOnly | QIODevice::Truncate))
 
14
                return false;
 
15
 
 
16
        QTextStream tin(&fin);
 
17
        QTextStream tout(&fout);
 
18
        while(!tin.atEnd())
 
19
        {
 
20
                QString line = tin.readLine();
 
21
 
 
22
                QHashIterator<QString,QString> it(vars);
 
23
                while(it.hasNext())
 
24
                {
 
25
                        it.next();
 
26
                        line.replace("@@" + it.key() + "@@", it.value());
 
27
                }
 
28
 
 
29
                tout << line << endl;
 
30
        }
 
31
 
 
32
        return true;
 
33
}
 
34
 
 
35
static QString psiGetVersion()
 
36
{
 
37
        QString str;
 
38
 
 
39
        {
 
40
                QFile file("version");
 
41
                if(file.open(QIODevice::ReadOnly | QIODevice::Text))
 
42
                {
 
43
                        QTextStream ts(&file);
 
44
                        if(!ts.atEnd())
 
45
                                str = ts.readLine();
 
46
                }
 
47
 
 
48
                if(str.isEmpty())
 
49
                        str = "UnknownVersion";
 
50
        }
 
51
 
 
52
        QDateTime now = QDateTime::currentDateTime();
 
53
        QString nowstr = QString().sprintf("%04d%02d%02d", now.date().year(), now.date().month(), now.date().day());
 
54
        str.replace("@@DATE@@", nowstr);
 
55
        return str;
 
56
}
 
57
 
10
58
class qc_conf : public ConfObj
11
59
{
12
60
public:
16
64
        QString checkString() const { return QString(); }
17
65
        bool exec()
18
66
        {
19
 
#ifdef Q_OS_WIN
20
 
                return true;
21
 
#else
 
67
                QString version = psiGetVersion();
 
68
                QHash<QString,QString> vars;
 
69
                vars["VERSION"] = version;
 
70
 
 
71
                psiGenerateFile("mac/Info.plist.in", "mac/Info.plist", vars);
 
72
 
 
73
#ifndef Q_OS_WIN
22
74
                conf->addExtra(QString("PSI_LIBDIR=%1/psi").arg(conf->getenv("LIBDIR")));
23
75
                conf->addExtra(QString("PSI_DATADIR=%1/psi").arg(conf->getenv("DATADIR")));
 
76
#endif
24
77
 
25
78
                QFile file("src/config.h");
26
79
                if ( file.open(QIODevice::WriteOnly | QIODevice::Text) ) {
27
80
                        QTextStream stream( &file );
 
81
#ifndef Q_OS_WIN
28
82
                        stream << "#define PSI_LIBDIR \"" << conf->getenv("LIBDIR") << "/psi\"" << endl;
29
83
                        stream << "#define PSI_DATADIR \"" << conf->getenv("DATADIR") << "/psi\"" << endl;
 
84
#endif
 
85
                        stream << "#define PSI_VERSION \"" << version << "\"" << endl;
30
86
                }
31
87
 
32
88
                conf->addDefine("HAVE_CONFIG");
33
89
 
34
90
                return true;
35
 
#endif
36
91
        }
37
92
};