📄 unixmake2.cpp
字号:
QStringList build; for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++) build << (*objit); QString ar; if((*libit) == "$(TARGET)") { t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) " << var("POST_TARGETDEPS") << valList(build) << "\n\t"; ar = project->variables()["QMAKE_AR_CMD"].first(); ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)", build.join(" ")); } else { t << (*libit) << ": " << valList(build) << "\n\t"; ar = "$(AR) " + (*libit) + " " + build.join(" "); } if(!project->isEmpty("DESTDIR")) { QString destdir = project->first("DESTDIR"); t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; } t << "-$(DEL_FILE) " << (*libit) << "\n\t" << ar << "\n"; if(!project->isEmpty("QMAKE_POST_LINK")) t << "\t" << var("QMAKE_POST_LINK") << "\n"; if(!project->isEmpty("QMAKE_RANLIB")) t << "\t" << "$(RANLIB) " << (*libit) << "\n"; if(!project->isEmpty("DESTDIR")) t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n" << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n"; } } t << endl << endl; } t << "mocables: $(SRCMOC)" << endl << "uicables: $(UICDECLS) $(UICIMPLS)" << endl << endl; if(!project->isActiveConfig("no_mocdepend")) { //this is an implicity depend on moc, so it will be built if necesary, however //moc itself shouldn't have this dependency - this is a little kludgy but it is //better than the alternative for now. QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"), moc_dir = "$(QTDIR)/src/moc"; if(!project->isEmpty("QMAKE_MOC_SRC")) moc_dir = project->first("QMAKE_MOC_SRC"); fixEnvVariables(target); fixEnvVariables(moc); if(target != moc) t << "$(MOC): \n\t" << "( cd " << moc_dir << " && $(MAKE) )" << endl << endl; } writeMakeQmake(t); if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake")) { QString meta_files; if(project->isActiveConfig("create_libtool") && project->first("TEMPLATE") == "lib" && !project->isActiveConfig("compile_libtool")) { //libtool if(!meta_files.isEmpty()) meta_files += " "; meta_files += libtoolFileName(); } if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib") { //pkg-config if(!meta_files.isEmpty()) meta_files += " "; meta_files += pkgConfigFileName(); } if(!meta_files.isEmpty()) { QStringList files = fileFixify(Option::mkfile::project_files); t << meta_files << ": " << "\n\t" << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl; } } if(!project->first("QMAKE_PKGINFO").isEmpty()) { QString pkginfo = project->first("QMAKE_PKGINFO"); QString destdir = project->first("DESTDIR"); t << pkginfo << ": " << "\n\t"; if(!destdir.isEmpty()) t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; t << "@$(DEL_FILE) " << pkginfo << "\n\t" << "@echo \"APPL????\" >" << pkginfo << endl; } if(!project->first("QMAKE_INFO_PLIST").isEmpty()) { QString info_plist = project->first("QMAKE_INFO_PLIST"), info_plist_out = project->first("QMAKE_INFO_PLIST_OUT"); QString destdir = project->first("DESTDIR"); t << info_plist_out << ": " << "\n\t"; if(!destdir.isEmpty()) t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; t << "@$(DEL_FILE) " << info_plist_out << "\n\t" << "@sed -e \"s,@ICON@,application.icns,g\" -e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" \"" << info_plist << "\" >\"" << info_plist_out << "\"" << endl; if(!project->first("RC_FILE").isEmpty()) { QString dir = destdir + "../Resources/"; t << dir << "application.icns: " << fileFixify(var("RC_FILE")) << "\n\t" << "@test -d " << dir << " || mkdir -p " << dir << "\n\t" << "@$(DEL_FILE) " << dir << "application.icns" << "\n\t" << "@$(COPY_FILE) " << fileFixify(var("RC_FILE")) << " " << dir << "application.icns" << endl; } } QString ddir = project->isEmpty("QMAKE_DISTDIR") ? project->first("QMAKE_ORIG_TARGET") : project->first("QMAKE_DISTDIR"); QString ddir_c = fileFixify((project->isEmpty("OBJECTS_DIR") ? QString(".tmp/") : project->first("OBJECTS_DIR")) + ddir); t << "dist: " << "\n\t" << "@mkdir -p " << ddir_c << " && " << "$(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) " << ddir_c << Option::dir_sep << " && "; if(!project->isEmpty("TRANSLATIONS")) t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && "; if(!project->isEmpty("IMAGES")) t << "$(COPY_FILE) --parents " << var("IMAGES") << " " << ddir_c << Option::dir_sep << " && "; if(!project->isEmpty("FORMS")) { QStringList &forms = project->variables()["FORMS"], ui_headers; for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { QString ui_h = fileFixify((*formit) + Option::h_ext.first()); if(QFile::exists(ui_h) ) ui_headers << ui_h; } if(!ui_headers.isEmpty()) t << "$(COPY_FILE) --parents " << val(ui_headers) << " " << ddir_c << Option::dir_sep << " && "; } t << "( cd `dirname " << ddir_c << "` && " << "$(TAR) " << var("QMAKE_ORIG_TARGET") << ".tar " << ddir << " && " << "$(GZIP) " << var("QMAKE_ORIG_TARGET") << ".tar ) && " << "$(MOVE) `dirname " << ddir_c << "`" << Option::dir_sep << var("QMAKE_ORIG_TARGET") << ".tar.gz . && " << "$(DEL_FILE) -r " << ddir_c << endl << endl; QString clean_targets; t << "mocclean:" << "\n"; if(mocAware()) { if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) { if(!objMoc.isEmpty()) t << "\t-$(DEL_FILE) $(OBJMOC)" << '\n'; if(!srcMoc.isEmpty()) t << "\t-$(DEL_FILE) $(SRCMOC)" << '\n'; if(moc_incremental) t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; clean_targets += " mocclean"; } t << endl; } t << "uiclean:" << "\n"; if (!var("UICIMPLS").isEmpty() || !var("UICDECLS").isEmpty()) { t << "\t-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)" << "\n"; clean_targets += " uiclean"; } t << endl; t << "yaccclean:" << "\n"; if(!var("YACCSOURCES").isEmpty()) { QStringList clean, &l = project->variables()["YACCSOURCES"]; for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { QFileInfo fi((*it)); QString dir; if(fi.dirPath() != ".") dir = fi.dirPath() + Option::dir_sep; dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) dir += Option::dir_sep; clean << ( dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first() ); clean << ( dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first() ); } if(!clean.isEmpty()) { t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n"; clean_targets += " yaccclean"; } } t << "lexclean:" << "\n"; if(!var("LEXSOURCES").isEmpty()) { QStringList clean, &l = project->variables()["LEXSOURCES"]; for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { QFileInfo fi((*it)); QString dir; if(fi.dirPath() != ".") dir = fi.dirPath() + Option::dir_sep; dir = fileFixify(dir, QDir::currentDirPath(), Option::output_dir); if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) dir += Option::dir_sep; clean << ( dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first() ); } if(!clean.isEmpty()) { t << "\t-$(DEL_FILE) " << clean.join(" ") << "\n"; clean_targets += " lexclean"; } } if(do_incremental) { t << "incrclean:" << "\n"; if(src_incremental) t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n"; if(moc_incremental) t << "\t-$(DEL_FILE) $(INCREMENTAL_OBJMOC)" << '\n'; t << endl; } t << "clean:" << clean_targets << "\n\t"; if(!project->isEmpty("OBJECTS")) { if(project->isActiveConfig("compile_libtool")) t << "-$(LIBTOOL) --mode=clean $(DEL_FILE) $(OBJECTS)" << "\n\t"; else t << "-$(DEL_FILE) $(OBJECTS)" << "\n\t"; } if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) { QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX"); QString precomph_out_dir = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep; t << "-$(DEL_FILE) " << precomph_out_dir << (header_prefix + "c ") << precomph_out_dir << header_prefix << "c++" << "\n\t"; } if(!project->isEmpty("IMAGES")) t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; if(src_incremental) t << "-$(DEL_FILE) $(INCREMENTAL_OBJECTS)" << "\n\t"; t << varGlue("QMAKE_CLEAN","-$(DEL_FILE) "," ","\n\t") << "-$(DEL_FILE) *~ core *.core" << "\n" << varGlue("CLEAN_FILES","\t-$(DEL_FILE) "," ","") << endl << endl; t << "####### Sub-libraries" << endl << endl; if ( !project->variables()["SUBLIBS"].isEmpty() ) { QString libdir = "tmp/"; if(!project->isEmpty("SUBLIBS_DIR")) libdir = project->first("SUBLIBS_DIR"); QStringList &l = project->variables()["SUBLIBS"]; for(it = l.begin(); it != l.end(); ++it) t << libdir << "lib" << (*it) << ".a" << ":\n\t" << var(QString("MAKELIB") + (*it)) << endl << endl; } QString destdir = project->first("DESTDIR"); if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) destdir += Option::dir_sep; t << "distclean: " << "clean\n"; if(project->first("TEMPLATE") == "app" && project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n"; else if(project->isActiveConfig("compile_libtool")) t << "\t-$(LIBTOOL) --mode=clean $(DEL_FILE) " << "$(TARGET)" << "\n"; else t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n"; if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() && !project->isActiveConfig("plugin") && !project->isActiveConfig("compile_libtool")) t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " << destdir << "$(TARGET2) $(TARGETA)" << "\n"; t << endl << endl; if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER") ) { QString precomph = fileFixify(project->first("PRECOMPILED_HEADER")); t << "###### Prefix headers" << endl; QString comps[] = { "C", "CXX", QString::null }; for(int i = 0; !comps[i].isNull(); i++) { QString flags = var("QMAKE_" + comps[i] + "FLAGS_PRECOMPILE"); flags += " $(" + comps[i] + "FLAGS)"; QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX"); QString outdir = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep, outfile = outdir; QString compiler; if(comps[i] == "C") { outfile += header_prefix + "c"; compiler = "$(CC) "; } else { outfile += header_prefix + "c++"; compiler = "$(CXX) "; } t << outfile << ": " << precomph << " " << findDependencies(precomph).join(" \\\n\t\t") << "\n\t" << "test -d " << outdir << " || mkdir -p " << outdir << "\n\t" << compiler << flags << " $(INCPATH) " << precomph << " -o " << outfile << endl << endl; } } if(!project->isEmpty("ALLMOC_HEADER")) { QString outdir = project->first("MOC_DIR"); QString precomph = fileFixify(project->first("ALLMOC_HEADER")); t << "###### Combined headers" << endl << endl << outdir << "allmoc.cpp: " << precomph << " " << varList("HEADERS_ORIG") << "\n\t" << "echo '#include \"" << precomph << "\"' >" << outdir << "allmoc.cpp" << "\n\t" << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " << outdir << "allmoc.cpp" << "\n\t" << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" << precomph << "\"}' " << outdir << "allmoc.cpp" << "\n\t" << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; } // user defined targets QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; for(it = qut.begin(); it != qut.end(); ++it) { QString targ = var((*it) + ".target"), cmd = var((*it) + ".commands"), deps; if(targ.isEmpty()) targ = (*it); QStringList &deplist = project->variables()[(*it) + ".depends"]; for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { QString dep = var((*dep_it) + ".target"); if(dep.isEmpty()) dep = (*dep_it); deps += " " + dep; } if(project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1) deps += QString(" ") + "FORCE"; t << targ << ":" << deps << "\n\t" << cmd << endl << endl; } // user defined compilers QStringList &quc = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"]; for(it = quc.begin(); it != quc.end(); ++it) { QString tmp_out = project->variables()[(*it) + ".output"].first(); QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" "); QString tmp_dep = project->variables()[(*it) + ".depends"].join(" "); QStringList &vars = project->variables()[(*it) + ".variables"]; if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) continue; QStringList &tmp = project->variables()[(*it) + ".input"]; for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { QStringList &inputs = project->variables()[(*it2)]; for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { QFileInfo fi(Option::fixPathToLocalOS((*input))); QString in = Option::fixPathToTargetOS((*input), FALSE), out = tmp_out, cmd = tmp_cmd, deps; out.replace("${QMAKE_FILE_BASE}", fi.baseName());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -