Fixed: choose filetransfer transport by priority (thanks Dealer_WeARE)
[iris.git] / qcm / buildmode.qcm
blob74da89bc05499daee3505e9980100651692d8893
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-----
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;
21 class qc_buildmode : public ConfObj
23 public:
24         qc_buildmode(Conf *c) : ConfObj(c) {}
25         QString name() const { return "buildmode"; }
26         QString shortname() const { return "buildmode"; }
28         // no output
29         QString checkString() const { return QString(); }
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;
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;
57                 bool staticmode = false;
58                 if(conf->getenv("QC_STATIC") == "Y")
59                         staticmode = true;
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                 }
68                 if(opt_framework)
69                 {
70                         printf("\nError: The --framework option is for mac only.\n");
71                         exit(1);
72                 }
73 #endif
75                 if(opt_framework && opt_debug)
76                 {
77                         printf("\nError: Cannot use both --framework and --debug.\n");
78                         exit(1);
79                 }
81                 // sanity check exclusive options
82                 int x;
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                 }
98                 // framework
99                 if(opt_framework && staticmode)
100                 {
101                         printf("\nError: Cannot use both --framework and --static.\n");
102                         exit(1);
103                 }
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                 }
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                 }
128                 // now process the options
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;
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                 }
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                 }
167                 // make the string
168                 QStringList opts;
169                 QString other;
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";
181 #ifdef Q_OS_MAC
182                 if(qc_buildmode_framework)
183                         opts += "lib_bundle";
184 #endif
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                 }
193                 QString str = QString("CONFIG += ") + opts.join(" ") + '\n';
194                 conf->addExtra(str);
196                 if(!other.isEmpty())
197                         conf->addExtra(other);
199                 return true;
200         }