📄 pbuilder_pbx.cpp
字号:
bool buildable = false; if(sources.at(source).keyName() == "SOURCES" || sources.at(source).keyName() == "GENERATED_SOURCES") buildable = true; QString file = files[f]; if(file.length() >= 2 && (file[0] == '"' || file[0] == '\'') && file[(int) file.length()-1] == file[0]) file = file.mid(1, file.length()-2); if(!sources.at(source).compilerName().isNull() && !verifyExtraCompiler(sources.at(source).compilerName(), file)) continue; if(file.endsWith(Option::prl_ext)) continue; bool in_root = true; QString src_key = keyFor(file), name = file; if(project->isActiveConfig("flat")) { QString flat_file = fileFixify(file, qmake_getpwd(), Option::output_dir, FileFixifyRelative); if(flat_file.indexOf(Option::dir_sep) != -1) { QStringList dirs = flat_file.split(Option::dir_sep); name = dirs.back(); } } else { QString flat_file = fileFixify(file, qmake_getpwd(), Option::output_dir, FileFixifyRelative); if(QDir::isRelativePath(flat_file) && flat_file.indexOf(Option::dir_sep) != -1) { QString last_grp("QMAKE_PBX_" + sources.at(source).groupName() + "_HEIR_GROUP"); QStringList dirs = flat_file.split(Option::dir_sep); name = dirs.back(); dirs.pop_back(); //remove the file portion as it will be added via src_key for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { QString new_grp(last_grp + Option::dir_sep + (*dir_it)), new_grp_key(keyFor(new_grp)); if(dir_it == dirs.begin()) { if(!src_list.contains(new_grp_key)) src_list.append(new_grp_key); } else { if(!groups[last_grp].contains(new_grp_key)) groups[last_grp] += new_grp_key; } last_grp = new_grp; } groups[last_grp] += src_key; in_root = false; } } if(in_root) src_list.append(src_key); //source reference t << "\t\t" << src_key << " = {" << "\n" << "\t\t\t" << "isa = PBXFileReference;" << "\n" << "\t\t\t" << "name = \"" << name << "\";" << "\n" << "\t\t\t" << "path = \"" << file << "\";" << "\n" << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n"; if(pbVersion >= 38) { QString filetype; for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) { if(file.endsWith((*cppit))) { filetype = "sourcecode.cpp.cpp"; break; } } if(!filetype.isNull()) t << "\t\t\t" << "lastKnownFileType = " << filetype << ";" << "\n"; } t << "\t\t" << "};" << "\n"; if(buildable) { //build reference QString build_key = keyFor(file + ".BUILDABLE"); t << "\t\t" << build_key << " = {" << "\n" << "\t\t\t" << "fileRef = " << src_key << ";" << "\n" << "\t\t\t" << "isa = PBXBuildFile;" << "\n" << "\t\t\t" << "settings = {" << "\n" << "\t\t\t\t" << "ATTRIBUTES = (" << "\n" << "\t\t\t\t" << ");" << "\n" << "\t\t\t" << "};" << "\n" << "\t\t" << "};" << "\n"; bool isObj = false; if(file.endsWith(".c")) isObj = true; for(int i = 0; !isObj && i < Option::cpp_ext.size(); ++i) { if(file.endsWith(Option::cpp_ext.at(i))) { isObj = true; break; } } if(isObj) project->variables()["QMAKE_PBX_OBJ"].append(build_key); } } if(!src_list.isEmpty()) { QString group_key = keyFor(sources.at(source).groupName()); if(root_group_list.indexOf(group_key) == -1) root_group_list += group_key; QStringList &group = groups[sources.at(source).groupName()]; for(int src = 0; src < src_list.size(); ++src) { if(group.indexOf(src_list.at(src)) == -1) group += src_list.at(src); } } } for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); grp_it != groups.end(); ++grp_it) { t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n" << "\t\t\t" << "isa = PBXGroup;" << "\n" << "\t\t\t" << "children = (" << "\n" << valGlue(grp_it.value(), "\t\t\t\t", ",\n\t\t\t\t", "\n") << "\t\t\t" << ");" << "\n" << "\t\t\t" << "name = \"" << grp_it.key().section(Option::dir_sep, -1) << "\";" << "\n" << "\t\t\t" << "refType = 4;" << "\n" << "\t\t" << "};" << "\n"; } //PREPROCESS BUILDPHASE (just a makefile) { QString mkfile = pbx_dir + Option::dir_sep + "qt_preprocess.mak"; QFile mkf(mkfile); if(mkf.open(QIODevice::WriteOnly | QIODevice::Text)) { did_preprocess = true; debug_msg(1, "pbuilder: Creating file: %s", mkfile.toLatin1().constData()); QTextStream mkt(&mkf); writeHeader(mkt); mkt << "MOC = " << Option::fixPathToTargetOS(var("QMAKE_MOC")) << endl; mkt << "UIC = " << Option::fixPathToTargetOS(var("QMAKE_UIC")) << endl; mkt << "LEX = " << var("QMAKE_LEX") << endl; mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; mkt << "YACC = " << var("QMAKE_YACC") << endl; mkt << "YACCFLAGS = " << var("QMAKE_YACCFLAGS") << endl; mkt << "DEFINES = " << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ") << varGlue("DEFINES","-D"," -D","") << endl; mkt << "INCPATH = " << "-I" << specdir(); if(!project->isActiveConfig("no_include_pwd")) { QString pwd = fileFixify(qmake_getpwd()); if(pwd.isEmpty()) pwd = "."; mkt << " -I" << pwd; } mkt << varGlue("INCLUDEPATH"," -I", " -I", "") << 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->variables()["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->variables()["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"; writeYaccSrc(mkt, "YACCSOURCES"); writeLexSrc(mkt, "LEXSOURCES"); writeExtraTargets(mkt); if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) { mkt << "compilers:"; const QStringList &compilers = project->variables()["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; mkt << " " << replaceExtraCompilerVariables(tmp_out, files.at(file), QString()); } } } mkt << endl; writeExtraCompilerTargets(mkt); } mkt.flush(); mkf.close(); } mkfile = fileFixify(mkfile, qmake_getpwd()); QString phase_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");// project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].append(phase_key); t << "\t\t" << phase_key << " = {" << "\n" << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" << "\t\t\t" << "files = (" << "\n" << "\t\t\t" << ");" << "\n" << "\t\t\t" << "generatedFileNames = (" << "\n" << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n") << "\t\t\t" << ");" << "\n" << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n" << "\t\t\t" << "name = \"Qt Preprocessors\";" << "\n" << "\t\t\t" << "neededFileNames = (" << "\n" << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n") << "\t\t\t" << ");" << "\n" << "\t\t\t" << "shellPath = /bin/sh;" << "\n" << "\t\t\t" << "shellScript = \"make -C " << qmake_getpwd() << " -f " << mkfile << "\";" << "\n" << "\t\t" << "};" << "\n"; } //SOURCE BUILDPHASE if(!project->isEmpty("QMAKE_PBX_OBJ")) { QString grp = "Build Sources", key = keyFor(grp); project->variables()["QMAKE_PBX_BUILDPHASES"].append(key); t << "\t\t" << key << " = {" << "\n" << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" << "\t\t\t" << "files = (" << "\n" << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n") << "\t\t\t" << ");" << "\n" << "\t\t\t" << "isa = PBXSourcesBuildPhase;" << "\n" << "\t\t\t" << "name = \"" << grp << "\";" << "\n" << "\t\t" << "};" << "\n"; } if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"]; QString libs[] = { "QMAKE_LFLAGS", "QMAKE_LIBDIR_FLAGS", "QMAKE_FRAMEWORKDIR_FLAGS", "QMAKE_LIBS", QString() }; for(int i = 0; !libs[i].isNull(); i++) { tmp = project->variables()[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->variables()["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 usefull. This looks in a prl for what the library will ultimately be called so we can stick it
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -