📄 pbuilder_pbx.cpp
字号:
t << "\t\t\t" << "productInstallPath = \"" << project->first("DESTDIR") << "\";" << "\n"; t << "\t\t" << "};" << "\n"; //DEBUG/RELEASE QString active_buildstyle;#if 0 for(int as_release = 0; as_release < 2; as_release++)#else bool as_release = !project->isActiveConfig("debug");#endif { QMap<QString, QString> settings; settings.insert("COPY_PHASE_STRIP", (as_release ? "YES" : "NO")); if(as_release) settings.insert("GCC_GENERATE_DEBUGGING_SYMBOLS", "NO"); QString name; if(pbVersion >= 42) name = (as_release ? "Release" : "Debug"); else name = (as_release ? "Deployment" : "Development"); if(pbVersion >= 42) { QString key = keyFor("QMAKE_PBX_BUILDCONFIG_" + name); project->variables()["QMAKE_PBX_BUILDCONFIGS"].append(key); t << "\t\t" << key << " = {" << "\n" << "\t\t\t" << "isa = XCBuildConfiguration;" << "\n" << "\t\t\t" << "buildSettings = {" << "\n"; for(QMap<QString, QString>::Iterator set_it = settings.begin(); set_it != settings.end(); ++set_it) t << "\t\t\t\t" << set_it.key() << " = \"" << set_it.data() << "\";\n"; t << "\t\t\t" << "};" << "\n" << "\t\t\t" << "name = " << name << ";" << "\n" << "\t\t" << "};" << "\n"; } QString key = keyFor("QMAKE_PBX_BUILDSTYLE_" + name); if(project->isActiveConfig("debug") != (bool)as_release) { project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key); active_buildstyle = name; } else if(pbVersion >= 42) { project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key); } t << "\t\t" << key << " = {" << "\n" << "\t\t\t" << "buildRules = (" << "\n" << "\t\t\t" << ");" << "\n" << "\t\t\t" << "buildSettings = {" << "\n"; for(QMap<QString, QString>::Iterator set_it = settings.begin(); set_it != settings.end(); ++set_it) t << "\t\t\t\t" << set_it.key() << " = \"" << set_it.data() << "\";\n"; t << "\t\t\t" << "};" << "\n" << "\t\t\t" << "isa = PBXBuildStyle;" << "\n" << "\t\t\t" << "name = " << name << ";" << "\n" << "\t\t" << "};" << "\n"; } if(pbVersion >= 42) { t << "\t\t" << keyFor("QMAKE_PBX_BUILDCONFIG_LIST") << " = {" << "\n" << "\t\t\t" << "isa = XCConfigurationList;" << "\n" << "\t\t\t" << "buildConfigurations = (" << "\n" << varGlue("QMAKE_PBX_BUILDCONFIGS", "\t\t\t\t", ",\n\t\t\t\t", "\n") << "\t\t\t" << ");" << "\n" << "\t\t\t" << "defaultConfigurationIsVisible = 0;" << "\n" << "\t\t\t" << "defaultConfigurationIsName = " << active_buildstyle << ";" << "\n" << "\t\t" << "};" << "\n"; } //ROOT t << "\t\t" << keyFor("QMAKE_PBX_ROOT") << " = {" << "\n" << "\t\t\t" << "buildStyles = (" << "\n" << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n") << "\t\t\t" << ");" << "\n" << "\t\t\t" << "hasScannedForEncodings = 1;" << "\n" << "\t\t\t" << "isa = PBXProject;" << "\n" << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n" << "\t\t\t" << "projectDirPath = \"\";" << "\n" << "\t\t\t" << "targets = (" << "\n" << varGlue("QMAKE_PBX_TARGETS", "\t\t\t\t", ",\n\t\t\t\t", "\n") << "\t\t\t" << ");" << "\n" << "\t\t" << "};" << "\n"; //FOOTER t << "\t" << "};" << "\n" << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n" << "}" << endl; if(project->isActiveConfig("generate_pbxbuild_makefile")) { QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"), QDir::currentDirPath()); QFile mkwrapf(mkwrap); if(mkwrapf.open(IO_WriteOnly | IO_Translate)) { debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1()); QTextStream mkwrapt(&mkwrapf); writeHeader(mkwrapt); const char *cleans = "uiclean mocclean preprocess_clean "; mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n" << "all:" << "\n\t" << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << "\n" << "install: all" << "\n\t" << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << " install\n" << "distclean clean: preprocess_clean" << "\n\t" << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << " clean" << "\n" << (!did_preprocess ? cleans : "") << ":" << "\n"; if(did_preprocess) mkwrapt << cleans << ":" << "\n\t" << "make -f " << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@" << endl; } } return TRUE;}QStringProjectBuilderMakefileGenerator::fixQuotes(const QString &val){ QString ret(val); ret = ret.replace(QRegExp("('|\\\\|\")"), "\\\\1"); return ret;}QStringProjectBuilderMakefileGenerator::fixEnvs(const QString &file){ QRegExp reg_var("\\$\\((.*)\\)"); for(int rep = 0; (rep = reg_var.search(file, rep)) != -1; ) { if(project->variables()["QMAKE_PBX_VARS"].findIndex(reg_var.cap(1)) == -1) project->variables()["QMAKE_PBX_VARS"].append(reg_var.cap(1)); rep += reg_var.matchedLength(); } return file;}QStringProjectBuilderMakefileGenerator::fixEnvsList(const QString &where){ QString ret; const QStringList &l = project->variables()[where]; for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { fixEnvs((*it)); if(!ret.isEmpty()) ret += " "; ret += fixQuotes((*it)); } return ret;}QStringProjectBuilderMakefileGenerator::keyFor(const QString &block){#if 1 //This make this code much easier to debug.. if(project->isActiveConfig("no_pb_munge_key")) return block;#endif QString ret; if(!keys.contains(block)) { ret = qtMD5(block.utf8()).left(24).upper(); keys.insert(block, ret); } else { ret = keys[block]; } return ret;}boolProjectBuilderMakefileGenerator::openOutput(QFile &file) const{ if(QDir::isRelativePath(file.name())) file.setName(Option::output_dir + file.name()); //pwd when qmake was run QFileInfo fi(file); if(fi.extension() != "pbxproj" || file.name().isEmpty()) { QString output = file.name(); if(fi.isDir()) output += QDir::separator(); if(!output.endsWith(projectSuffix())) { if(file.name().isEmpty() || fi.isDir()) output += project->first("TARGET"); output += projectSuffix() + QDir::separator(); } else if(output[(int)output.length() - 1] != QDir::separator()) { output += QDir::separator(); } output += QString("project.pbxproj"); file.setName(output); } bool ret = UnixMakefileGenerator::openOutput(file); ((ProjectBuilderMakefileGenerator*)this)->pbx_dir = Option::output_dir.section(Option::dir_sep, 0, -1); Option::output_dir = pbx_dir.section(Option::dir_sep, 0, -2); return ret;}/* This function is such a hack it is almost pointless, but it eliminates the warning message from ProjectBuilder that the project file is for an older version. I guess this could be used someday if the format of the output is dependant upon the version of ProjectBuilder as well.*/intProjectBuilderMakefileGenerator::pbuilderVersion() const{ QString ret; if(project->isEmpty("QMAKE_PBUILDER_VERSION")) { QString version, version_plist = project->first("QMAKE_PBUILDER_VERSION_PLIST"); if(version_plist.isEmpty()) { if(QFile::exists("/Developer/Applications/Xcode.app/Contents/version.plist")) version_plist = "/Developer/Applications/Xcode.app/Contents/version.plist"; else version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist"; } else { version_plist = version_plist.replace(QRegExp("\""), ""); } QFile version_file(version_plist); if (version_file.open(IO_ReadOnly)) { debug_msg(1, "pbuilder: version.plist: Reading file: %s", version_plist.latin1()); QTextStream plist(&version_file); bool in_dict = false; QString current_key; QRegExp keyreg("^<key>(.*)</key>$"), stringreg("^<string>(.*)</string>$"); while(!plist.atEnd()) { QString line = plist.readLine().stripWhiteSpace(); if(line == "<dict>") in_dict = true; else if(line == "</dict>") in_dict = false; else if(in_dict) { if(keyreg.exactMatch(line)) current_key = keyreg.cap(1); else if(current_key == "CFBundleShortVersionString" && stringreg.exactMatch(line)) version = stringreg.cap(1); } } version_file.close(); } else { debug_msg(1, "pbuilder: version.plist: Failure to open %s", version_plist.latin1()); } if(version.isEmpty() && version_plist.contains("Xcode")) { ret = "39"; } else { if(version.startsWith("2.")) ret = "42"; else if(version == "1.5") ret = "39"; else if(version == "1.1") ret = "34"; } } else { ret = project->first("QMAKE_PBUILDER_VERSION"); } if(!ret.isEmpty()) { bool ok; int int_ret = ret.toInt(&ok); if(ok) { debug_msg(1, "pbuilder: version.plist: Got version: %d", int_ret); return int_ret; } } debug_msg(1, "pbuilder: version.plist: Fallback to default version"); return 34; //my fallback}intProjectBuilderMakefileGenerator::reftypeForFile(const QString &where){ int ret = 0; //absolute is the default.. if(QDir::isRelativePath(where)) ret = 4; //relative return ret;}QStringProjectBuilderMakefileGenerator::projectSuffix() const{ const int pbVersion = pbuilderVersion(); if(pbVersion >= 42) return ".xcodeproj"; else if(pbVersion >= 38) return ".xcode"; return ".pbproj";}QStringProjectBuilderMakefileGenerator::pbxbuild(){ if(QFile::exists("/usr/bin/pbbuild")) return "pbbuild"; if(QFile::exists("/usr/bin/xcodebuild")) return "xcodebuild"; return (pbuilderVersion() >= 38 ? "xcodebuild" : "pbxbuild");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -