📄 pbuilder_pbx.cpp
字号:
mkt << "INCPATH = " << "-I" << specdir(); if(!project->isActiveConfig("no_include_pwd")) { QString pwd = escapeFilePath(fileFixify(qmake_getpwd())); if(pwd.isEmpty()) pwd = "."; mkt << " -I" << pwd; } { const QStringList &incs = project->values("INCLUDEPATH"); for(QStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) mkt << " " << "-I" << escapeFilePath((*incit)); } mkt << endl; mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl; mkt << "IMAGES = " << varList("QMAKE_IMAGE_COLLECTION") << endl; mkt << "PARSERS ="; if(!project->isEmpty("YACCSOURCES")) { QStringList &yaccs = project->values("YACCSOURCES"); for(QStringList::Iterator yit = yaccs.begin(); yit != yaccs.end(); ++yit) { QFileInfo fi(fileInfo((*yit))); mkt << " " << fi.path() << Option::dir_sep << fi.baseName() << Option::yacc_mod << Option::cpp_ext.first(); } } if(!project->isEmpty("LEXSOURCES")) { QStringList &lexs = project->values("LEXSOURCES"); for(QStringList::Iterator lit = lexs.begin(); lit != lexs.end(); ++lit) { QFileInfo fi(fileInfo((*lit))); mkt << " " << fi.path() << Option::dir_sep << fi.baseName() << Option::lex_mod << Option::cpp_ext.first(); } } mkt << "\n"; mkt << "preprocess: $(PARSERS) compilers" << endl; mkt << "clean preprocess_clean: parser_clean compiler_clean" << endl << endl; mkt << "parser_clean:" << "\n"; if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES")) mkt << "\t-rm -f $(PARSERS)" << "\n"; writeExtraTargets(mkt); if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) { mkt << "compilers:"; const QStringList &compilers = project->values("QMAKE_EXTRA_COMPILERS"); for(int compiler = 0; compiler < compilers.size(); ++compiler) { QString tmp_out = project->first(compilers.at(compiler) + ".output"); if(project->isEmpty(compilers.at(compiler) + ".output")) continue; const QStringList &inputs = project->values(compilers.at(compiler) + ".input"); for(int input = 0; input < inputs.size(); ++input) { if(project->isEmpty(inputs.at(input))) continue; const QStringList &files = project->values(inputs.at(input)); for(int file = 0, added = 0; file < files.size(); ++file) { if(!verifyExtraCompiler(compilers.at(compiler), files.at(file))) continue; if(added && !(added % 3)) mkt << "\\\n\t"; ++added; const QString file_name = fileFixify(files.at(file), Option::output_dir, Option::output_dir); mkt << " " << replaceExtraCompilerVariables(tmp_out, file_name, QString()); } } } mkt << endl; writeExtraCompilerTargets(mkt); writingUnixMakefileGenerator = false; } mkt.flush(); mkf.close(); } mkfile = fileFixify(mkfile, qmake_getpwd()); QString phase_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");// project->values("QMAKE_PBX_BUILDPHASES").append(phase_key); project->values("QMAKE_PBX_PRESCRIPT_BUILDPHASES").append(phase_key); t << "\t\t" << phase_key << " = {" << "\n" << "\t\t\t" << writeSettings("buildActionMask", "2147483647", SettingsNoQuote) << ";" << "\n" << "\t\t\t" << writeSettings("files", QStringList(), SettingsAsList, 4) << ";" << "\n" << "\t\t\t" << writeSettings("generatedFileNames", fixListForOutput("QMAKE_PBX_OBJ"), SettingsAsList, 4) << ";" << "\n" << "\t\t\t" << writeSettings("isa", "PBXShellScriptBuildPhase", SettingsNoQuote) << ";" << "\n" << "\t\t\t" << writeSettings("name", "Qt Preprocessors") << ";" << "\n" << "\t\t\t" << writeSettings("neededFileNames", fixListForOutput("QMAKE_PBX_OBJ"), SettingsAsList, 4) << ";" << "\n" << "\t\t\t" << writeSettings("shellPath", "/bin/sh") << ";" << "\n" << "\t\t\t" << writeSettings("shellScript", fixForOutput("make -C " + escapeFilePath(qmake_getpwd()) + " -f " + escapeFilePath(mkfile))) << ";" << "\n" << "\t\t" << "};" << "\n"; } //SOURCE BUILDPHASE if(!project->isEmpty("QMAKE_PBX_OBJ")) { QString grp = "Build Sources", key = keyFor(grp); project->values("QMAKE_PBX_BUILDPHASES").append(key); t << "\t\t" << key << " = {" << "\n" << "\t\t\t" << writeSettings("buildActionMask", "2147483647", SettingsNoQuote) << ";" << "\n" << "\t\t\t" << writeSettings("files", fixListForOutput("QMAKE_PBX_OBJ"), SettingsAsList, 4) << ";" << "\n" << "\t\t\t" << writeSettings("isa", "PBXSourcesBuildPhase", SettingsNoQuote) << ";" << "\n" << "\t\t\t" << writeSettings("name", grp) << ";" << "\n" << "\t\t" << "};" << "\n"; } if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES QStringList &libdirs = project->values("QMAKE_PBX_LIBPATHS"), &frameworkdirs = project->values("QMAKE_FRAMEWORKPATH"); QString libs[] = { "QMAKE_LFLAGS", "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKPATH_FLAGS", "QMAKE_LIBS", QString() }; for(int i = 0; !libs[i].isNull(); i++) { tmp = project->values(libs[i]); for(int x = 0; x < tmp.count();) { bool remove = false; QString library, name, opt = tmp[x].trimmed(); if(opt.length() >= 2 && (opt[0] == '"' || opt[0] == '\'') && opt[(int) opt.length()-1] == opt[0]) opt = opt.mid(1, opt.length()-2); if(opt.startsWith("-L")) { QString r = opt.right(opt.length() - 2); fixForOutput(r); libdirs.append(r); } else if(opt == "-prebind") { project->values("QMAKE_DO_PREBINDING").append("TRUE"); remove = true; } else if(opt.startsWith("-l")) { name = opt.right(opt.length() - 2); QString lib("lib" + name); for(QStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) { if(project->isActiveConfig("link_prl")) { /* This isn't real nice, but it is real useful. This looks in a prl for what the library will ultimately be called so we can stick it in the ProjectFile. If the prl format ever changes (not likely) then this will not really work. However, more concerning is that it will encode the version number in the Project file which might be a bad things in days to come? --Sam */ QString lib_file = (*lit) + Option::dir_sep + lib; if(QMakeMetaInfo::libExists(lib_file)) { QMakeMetaInfo libinfo; if(libinfo.readLib(lib_file)) { if(!libinfo.isEmpty("QMAKE_PRL_TARGET")) { library = (*lit) + Option::dir_sep + libinfo.first("QMAKE_PRL_TARGET"); debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)", opt.toLatin1().constData(), lib_file.toLatin1().constData(), library.toLatin1().constData()); remove = true; } } } } if(!remove) { QString extns[] = { ".dylib", ".so", ".a", QString() }; for(int n = 0; !remove && !extns[n].isNull(); n++) { QString tmp = (*lit) + Option::dir_sep + lib + extns[n]; if(exists(tmp)) { library = tmp; debug_msg(1, "pbuilder: Found library (%s) via %s", opt.toLatin1().constData(), library.toLatin1().constData()); remove = true; } } } } } else if(opt.startsWith("-F")) { QString r; if(opt.size() > 2) { r = opt.right(opt.length() - 2); } else { if(x == tmp.count()-1) break; r = tmp[++x]; } if(!r.isEmpty()) { fixForOutput(r); frameworkdirs.append(r); } } else if(opt == "-framework") { if(x == tmp.count()-1) break; const QString framework = tmp[x+1]; QStringList fdirs = frameworkdirs; fdirs << "/System/Library/Frameworks/" << "/Library/Frameworks/"; for(int fdir = 0; fdir < fdirs.count(); fdir++) { if(exists(fdirs[fdir] + QDir::separator() + framework + ".framework")) { tmp.removeAt(x); remove = true; library = fdirs[fdir] + Option::dir_sep + framework + ".framework"; break; } } } else if(opt.left(1) != "-") { if(exists(opt)) { remove = true; library = opt; } } if(!library.isEmpty()) { const int slsh = library.lastIndexOf(Option::dir_sep); if(name.isEmpty()) { if(slsh != -1) name = library.right(library.length() - slsh - 1); } if(slsh != -1) { const QString path = QFileInfo(library.left(slsh)).absoluteFilePath(); if(!path.isEmpty() && !libdirs.contains(path)) libdirs += path; } library = fileFixify(library); QString key = keyFor(library); bool is_frmwrk = (library.endsWith(".framework")); t << "\t\t" << key << " = {" << "\n" << "\t\t\t" << writeSettings("isa", (is_frmwrk ? "PBXFrameworkReference" : "PBXFileReference"), SettingsNoQuote) << ";" << "\n" << "\t\t\t" << writeSettings("name", escapeFilePath(name)) << ";" << "\n" << "\t\t\t" << writeSettings("path", escapeFilePath(library)) << ";" << "\n" << "\t\t\t" << writeSettings("refType", QString::number(reftypeForFile(library)), SettingsNoQuote) << ";" << "\n" << "\t\t" << "};" << "\n"; project->values("QMAKE_PBX_LIBRARIES").append(key); QString build_key = keyFor(library + ".BUILDABLE"); t << "\t\t" << build_key << " = {" << "\n" << "\t\t\t" << writeSettings("fileRef", key) << ";" << "\n" << "\t\t\t" << writeSettings("isa", "PBXBuildFile", SettingsNoQuote) << ";" << "\n" << "\t\t\t" << "settings = {" << "\n" << "\t\t\t" << "};" << "\n" << "\t\t" << "};" << "\n"; project->values("QMAKE_PBX_BUILD_LIBRARIES").append(build_key); } if(remove) tmp.removeAt(x); else x++; } project->values(libs[i]) = tmp; } } //SUBLIBS BUILDPHASE (just another makefile) if(!project->isEmpty("SUBLIBS")) { QString mkfile = pbx_dir + Option::dir_sep + "qt_sublibs.mak"; QFile mkf(mkfile); if(mkf.open(QIODevice::WriteOnly | QIODevice::Text)) { writingUnixMakefileGenerator = true; debug_msg(1, "pbuilder: Creating file: %s", mkfile.toLatin1().constData());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -