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

« back to all changes in this revision

Viewing changes to iris/qcm/buildmode.qcm

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
-----BEGIN QCMOD-----
 
3
name: buildmode
 
4
section: project
 
5
arg: release,Build with debugging turned off (default).
 
6
arg: debug,Build with debugging turned on.
 
7
arg: debug-and-release,Build two versions, with and without debugging turned on (mac only).
 
8
arg: no-separate-debug-info,Do not store debug information in a separate file (default for mac).
 
9
arg: separate-debug-info,Strip debug information into a separate .debug file (default for non-mac).
 
10
arg: no-framework,Do not build as a Mac framework.
 
11
arg: framework,Build as a Mac framework (default).
 
12
-----END QCMOD-----
 
13
*/
 
14
 
 
15
#define QC_BUILDMODE
 
16
bool qc_buildmode_release = false;
 
17
bool qc_buildmode_debug = false;
 
18
bool qc_buildmode_framework = false;
 
19
bool qc_buildmode_separate_debug_info = false;
 
20
 
 
21
class qc_buildmode : public ConfObj
 
22
{
 
23
public:
 
24
        qc_buildmode(Conf *c) : ConfObj(c) {}
 
25
        QString name() const { return "buildmode"; }
 
26
        QString shortname() const { return "buildmode"; }
 
27
 
 
28
        // no output
 
29
        QString checkString() const { return QString(); }
 
30
 
 
31
        bool exec()
 
32
        {
 
33
                // first, parse out the options
 
34
                bool opt_release = false;
 
35
                bool opt_debug = false;
 
36
                bool opt_debug_and_release = false;
 
37
                bool opt_no_framework = false;
 
38
                bool opt_framework = false;
 
39
                bool opt_no_separate_debug_info = false;
 
40
                bool opt_separate_debug_info = false;
 
41
 
 
42
                if(conf->getenv("QC_RELEASE") == "Y")
 
43
                        opt_release = true;
 
44
                if(conf->getenv("QC_DEBUG") == "Y")
 
45
                        opt_debug = true;
 
46
                if(conf->getenv("QC_DEBUG_AND_RELEASE") == "Y")
 
47
                        opt_debug_and_release = true;
 
48
                if(conf->getenv("QC_NO_FRAMEWORK") == "Y")
 
49
                        opt_no_framework = true;
 
50
                if(conf->getenv("QC_FRAMEWORK") == "Y")
 
51
                        opt_framework = true;
 
52
                if(conf->getenv("QC_NO_SEPARATE_DEBUG_INFO") == "Y")
 
53
                        opt_no_separate_debug_info = true;
 
54
                if(conf->getenv("QC_SEPARATE_DEBUG_INFO") == "Y")
 
55
                        opt_separate_debug_info = true;
 
56
 
 
57
                bool staticmode = false;
 
58
                if(conf->getenv("QC_STATIC") == "Y")
 
59
                        staticmode = true;
 
60
 
 
61
#ifndef Q_OS_MAC
 
62
                if(opt_debug_and_release)
 
63
                {
 
64
                        printf("\nError: The --debug-and-release option is for mac only.\n");
 
65
                        exit(1);
 
66
                }
 
67
 
 
68
                if(opt_framework)
 
69
                {
 
70
                        printf("\nError: The --framework option is for mac only.\n");
 
71
                        exit(1);
 
72
                }
 
73
#endif
 
74
 
 
75
                if(opt_framework && opt_debug)
 
76
                {
 
77
                        printf("\nError: Cannot use both --framework and --debug.\n");
 
78
                        exit(1);
 
79
                }
 
80
 
 
81
                // sanity check exclusive options
 
82
                int x;
 
83
 
 
84
                // build mode
 
85
                x = 0;
 
86
                if(opt_release)
 
87
                        ++x;
 
88
                if(opt_debug)
 
89
                        ++x;
 
90
                if(opt_debug_and_release)
 
91
                        ++x;
 
92
                if(x > 1)
 
93
                {
 
94
                        printf("\nError: Use only one of --release, --debug, or --debug-and-release.\n");
 
95
                        exit(1);
 
96
                }
 
97
 
 
98
                // framework
 
99
                if(opt_framework && staticmode)
 
100
                {
 
101
                        printf("\nError: Cannot use both --framework and --static.\n");
 
102
                        exit(1);
 
103
                }
 
104
 
 
105
                x = 0;
 
106
                if(opt_no_framework)
 
107
                        ++x;
 
108
                if(opt_framework)
 
109
                        ++x;
 
110
                if(x > 1)
 
111
                {
 
112
                        printf("\nError: Use only one of --framework or --no-framework.\n");
 
113
                        exit(1);
 
114
                }
 
115
 
 
116
                // debug info
 
117
                x = 0;
 
118
                if(opt_no_separate_debug_info)
 
119
                        ++x;
 
120
                if(opt_separate_debug_info)
 
121
                        ++x;
 
122
                if(x > 1)
 
123
                {
 
124
                        printf("\nError: Use only one of --separate-debug-info or --no-separate-debug-info\n");
 
125
                        exit(1);
 
126
                }
 
127
 
 
128
                // now process the options
 
129
 
 
130
                if(opt_release)
 
131
                        qc_buildmode_release = true;
 
132
                else if(opt_debug)
 
133
                        qc_buildmode_debug = true;
 
134
                else if(opt_debug_and_release)
 
135
                {
 
136
                        qc_buildmode_release = true;
 
137
                        qc_buildmode_debug = true;
 
138
                }
 
139
                else // default
 
140
                        qc_buildmode_release = true;
 
141
 
 
142
                if(opt_framework)
 
143
                        qc_buildmode_framework = true;
 
144
                else if(opt_no_framework)
 
145
                {
 
146
                        // nothing to do
 
147
                }
 
148
                else // default
 
149
                {
 
150
                        if(!staticmode && !opt_debug)
 
151
                                qc_buildmode_framework = true;
 
152
                }
 
153
 
 
154
                if(opt_separate_debug_info)
 
155
                        qc_buildmode_separate_debug_info = true;
 
156
                else if(opt_no_separate_debug_info)
 
157
                {
 
158
                        // nothing to do
 
159
                }
 
160
                else // default
 
161
                {
 
162
#ifndef Q_OS_MAC
 
163
                        qc_buildmode_separate_debug_info = true;
 
164
#endif
 
165
                }
 
166
 
 
167
                // make the string
 
168
                QStringList opts;
 
169
                QString other;
 
170
 
 
171
                if(qc_buildmode_release && qc_buildmode_debug)
 
172
                {
 
173
                        opts += "debug_and_release";
 
174
                        opts += "build_all";
 
175
                }
 
176
                else if(qc_buildmode_release)
 
177
                        opts += "release";
 
178
                else // qc_buildmode_debug
 
179
                        opts += "debug";
 
180
 
 
181
#ifdef Q_OS_MAC
 
182
                if(qc_buildmode_framework)
 
183
                        opts += "lib_bundle";
 
184
#endif
 
185
 
 
186
                if(qc_buildmode_separate_debug_info)
 
187
                {
 
188
                        opts += "separate_debug_info";
 
189
                        other += "QMAKE_CFLAGS += -g\n";
 
190
                        other += "QMAKE_CXXFLAGS += -g\n";
 
191
                }
 
192
 
 
193
                QString str = QString("CONFIG += ") + opts.join(" ") + '\n';
 
194
                conf->addExtra(str);
 
195
 
 
196
                if(!other.isEmpty())
 
197
                        conf->addExtra(other);
 
198
 
 
199
                return true;
 
200
        }
 
201
};