Warning, /games/ksirk/ksirk/iris/qcm/buildmode.qcm is written in an unsupported language. File is not indexed.
0001 /*
0002 -----BEGIN QCMOD-----
0003 name: buildmode
0004 section: project
0005 arg: release,Build with debugging turned off (default).
0006 arg: debug,Build with debugging turned on.
0007 arg: debug-and-release,Build two versions, with and without debugging turned on (mac only).
0008 arg: no-separate-debug-info,Do not store debug information in a separate file (default for mac).
0009 arg: separate-debug-info,Strip debug information into a separate .debug file (default for non-mac).
0010 arg: no-framework,Do not build as a Mac framework.
0011 arg: framework,Build as a Mac framework (default).
0012 -----END QCMOD-----
0013 */
0014
0015 #define QC_BUILDMODE
0016 bool qc_buildmode_release = false;
0017 bool qc_buildmode_debug = false;
0018 bool qc_buildmode_framework = false;
0019 bool qc_buildmode_separate_debug_info = false;
0020
0021 class qc_buildmode : public ConfObj
0022 {
0023 public:
0024 qc_buildmode(Conf *c) : ConfObj(c) {}
0025 QString name() const { return "buildmode"; }
0026 QString shortname() const { return "buildmode"; }
0027
0028 // no output
0029 QString checkString() const { return QString(); }
0030
0031 bool exec()
0032 {
0033 // first, parse out the options
0034 bool opt_release = false;
0035 bool opt_debug = false;
0036 bool opt_debug_and_release = false;
0037 bool opt_no_framework = false;
0038 bool opt_framework = false;
0039 bool opt_no_separate_debug_info = false;
0040 bool opt_separate_debug_info = false;
0041
0042 if(conf->getenv("QC_RELEASE") == "Y")
0043 opt_release = true;
0044 if(conf->getenv("QC_DEBUG") == "Y")
0045 opt_debug = true;
0046 if(conf->getenv("QC_DEBUG_AND_RELEASE") == "Y")
0047 opt_debug_and_release = true;
0048 if(conf->getenv("QC_NO_FRAMEWORK") == "Y")
0049 opt_no_framework = true;
0050 if(conf->getenv("QC_FRAMEWORK") == "Y")
0051 opt_framework = true;
0052 if(conf->getenv("QC_NO_SEPARATE_DEBUG_INFO") == "Y")
0053 opt_no_separate_debug_info = true;
0054 if(conf->getenv("QC_SEPARATE_DEBUG_INFO") == "Y")
0055 opt_separate_debug_info = true;
0056
0057 bool staticmode = false;
0058 if(conf->getenv("QC_STATIC") == "Y")
0059 staticmode = true;
0060
0061 #ifndef Q_OS_MAC
0062 if(opt_debug_and_release)
0063 {
0064 printf("\nError: The --debug-and-release option is for mac only.\n");
0065 exit(1);
0066 }
0067
0068 if(opt_framework)
0069 {
0070 printf("\nError: The --framework option is for mac only.\n");
0071 exit(1);
0072 }
0073 #endif
0074
0075 if(opt_framework && opt_debug)
0076 {
0077 printf("\nError: Cannot use both --framework and --debug.\n");
0078 exit(1);
0079 }
0080
0081 // sanity check exclusive options
0082 int x;
0083
0084 // build mode
0085 x = 0;
0086 if(opt_release)
0087 ++x;
0088 if(opt_debug)
0089 ++x;
0090 if(opt_debug_and_release)
0091 ++x;
0092 if(x > 1)
0093 {
0094 printf("\nError: Use only one of --release, --debug, or --debug-and-release.\n");
0095 exit(1);
0096 }
0097
0098 // framework
0099 if(opt_framework && staticmode)
0100 {
0101 printf("\nError: Cannot use both --framework and --static.\n");
0102 exit(1);
0103 }
0104
0105 x = 0;
0106 if(opt_no_framework)
0107 ++x;
0108 if(opt_framework)
0109 ++x;
0110 if(x > 1)
0111 {
0112 printf("\nError: Use only one of --framework or --no-framework.\n");
0113 exit(1);
0114 }
0115
0116 // debug info
0117 x = 0;
0118 if(opt_no_separate_debug_info)
0119 ++x;
0120 if(opt_separate_debug_info)
0121 ++x;
0122 if(x > 1)
0123 {
0124 printf("\nError: Use only one of --separate-debug-info or --no-separate-debug-info\n");
0125 exit(1);
0126 }
0127
0128 // now process the options
0129
0130 if(opt_release)
0131 qc_buildmode_release = true;
0132 else if(opt_debug)
0133 qc_buildmode_debug = true;
0134 else if(opt_debug_and_release)
0135 {
0136 qc_buildmode_release = true;
0137 qc_buildmode_debug = true;
0138 }
0139 else // default
0140 qc_buildmode_release = true;
0141
0142 if(opt_framework)
0143 qc_buildmode_framework = true;
0144 else if(opt_no_framework)
0145 {
0146 // nothing to do
0147 }
0148 else // default
0149 {
0150 if(!staticmode && !opt_debug)
0151 qc_buildmode_framework = true;
0152 }
0153
0154 if(opt_separate_debug_info)
0155 qc_buildmode_separate_debug_info = true;
0156 else if(opt_no_separate_debug_info)
0157 {
0158 // nothing to do
0159 }
0160 else // default
0161 {
0162 #ifndef Q_OS_MAC
0163 qc_buildmode_separate_debug_info = true;
0164 #endif
0165 }
0166
0167 // make the string
0168 QStringList opts;
0169 QString other;
0170
0171 if(qc_buildmode_release && qc_buildmode_debug)
0172 {
0173 opts += "debug_and_release";
0174 opts += "build_all";
0175 }
0176 else if(qc_buildmode_release)
0177 opts += "release";
0178 else // qc_buildmode_debug
0179 opts += "debug";
0180
0181 #ifdef Q_OS_MAC
0182 if(qc_buildmode_framework)
0183 opts += "lib_bundle";
0184 #endif
0185
0186 if(qc_buildmode_separate_debug_info)
0187 {
0188 opts += "separate_debug_info";
0189 other += "QMAKE_CFLAGS += -g\n";
0190 other += "QMAKE_CXXFLAGS += -g\n";
0191 }
0192
0193 QString str = QString("CONFIG += ") + opts.join(" ") + '\n';
0194 conf->addExtra(str);
0195
0196 if(!other.isEmpty())
0197 conf->addExtra(other);
0198
0199 return true;
0200 }
0201 };