📄 winmakefile.cpp
字号:
QString inc = incs.at(i); inc.replace(QRegExp("\\\\$"), ""); inc.replace(QRegExp("\""), ""); if(!inc.isEmpty()) t << "-I" << "\"" << inc << "\" "; } t << "-I\"" << specdir() << "\"" << endl;}void Win32MakefileGenerator::writeStandardParts(QTextStream &t){ t << "####### Compiler, tools and options" << endl << endl; t << "CC = " << var("QMAKE_CC") << endl; t << "CXX = " << var("QMAKE_CXX") << endl; t << "DEFINES = " << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ") << varGlue("DEFINES","-D"," -D","") << endl; t << "CFLAGS = " << var("QMAKE_CFLAGS") << " $(DEFINES)" << endl; t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " $(DEFINES)" << endl; writeIncPart(t); writeLibsPart(t); t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : Option::fixPathToTargetOS(var("QMAKE_QMAKE"), false)) << endl; t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? QString("idc") : Option::fixPathToTargetOS(var("QMAKE_IDC"), false)) << endl; t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? QString("midl") : Option::fixPathToTargetOS(var("QMAKE_IDL"), false)) << endl; t << "ZIP = " << var("QMAKE_ZIP") << endl; t << "DEF_FILE = " << varList("DEF_FILE") << endl; t << "RES_FILE = " << varList("RES_FILE") << endl; // Not on mingw, can't see why not though... t << "COPY = " << var("QMAKE_COPY") << endl; t << "COPY_FILE = " << var("QMAKE_COPY_FILE") << endl; t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; t << "MOVE = " << var("QMAKE_MOVE") << endl; t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl; t << "MKDIR = " << var("QMAKE_MKDIR") << endl; t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl; t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl; t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; t << endl; t << "####### Output directory" << endl << endl; if(!project->values("OBJECTS_DIR").isEmpty()) t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(QRegExp("\\\\$"),"") << endl; else t << "OBJECTS_DIR = . " << endl; t << endl; t << "####### Files" << endl << endl; t << "SOURCES = " << valList(escapeFilePaths(project->values("SOURCES"))) << " " << valList(escapeFilePaths(project->values("GENERATED_SOURCES"))) << endl; // do this here so we can set DEST_TARGET to be the complete path to the final target if it is needed. QString orgDestDir = var("DESTDIR"); QString destDir = Option::fixPathToTargetOS(orgDestDir, false); if (orgDestDir.endsWith('/') || orgDestDir.endsWith(Option::dir_sep)) destDir += Option::dir_sep; QString target = QString(project->first("TARGET")+project->first("TARGET_EXT")); target.remove("\""); project->values("DEST_TARGET").prepend(destDir + target); writeObjectsPart(t); writeExtraCompilerVariables(t); writeExtraVariables(t); t << "DIST = " << varList("DISTFILES") << endl; t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; // The comment is important to maintain variable compatability with Unix // Makefiles, while not interpreting a trailing-slash as a linebreak t << "DESTDIR = " << escapeFilePath(destDir) << " #avoid trailing-slash linebreak" << endl; t << "TARGET = " << escapeFilePath(target) << endl; t << "DESTDIR_TARGET = " << escapeFilePath(var("DEST_TARGET")) << endl; t << endl; t << "####### Implicit rules" << endl << endl; writeImplicitRulesPart(t); t << "####### Build rules" << endl << endl; writeBuildRulesPart(t); if(project->isActiveConfig("shared") && !project->values("DLLDESTDIR").isEmpty()) { QStringList dlldirs = project->values("DLLDESTDIR"); for (QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) { t << "\n\t" << "-$(COPY_FILE) \"$(DESTDIR_TARGET)\" " << Option::fixPathToTargetOS(*dlldir, false); } } t << endl << endl; writeRcFilePart(t); writeMakeQmake(t); QStringList dist_files = fileFixify(Option::mkfile::project_files); if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES")) dist_files += project->values("QMAKE_INTERNAL_INCLUDED_FILES"); if(!project->isEmpty("TRANSLATIONS")) dist_files << var("TRANSLATIONS"); if(!project->isEmpty("FORMS")) { QStringList &forms = project->values("FORMS"); for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { QString ui_h = fileFixify((*formit) + Option::h_ext.first()); if(exists(ui_h)) dist_files << ui_h; } } t << "dist:" << "\n\t" << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(DIST) " << dist_files.join(" ") << " " << var("TRANSLATIONS") << " "; if(!project->isEmpty("QMAKE_EXTRA_COMPILERS")) { const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS"); for(QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { const QStringList &inputs = project->values((*it)+".input"); for(QStringList::ConstIterator input = inputs.begin(); input != inputs.end(); ++input) { t << (*input) << " "; } } } t << endl << endl; writeCleanParts(t); writeExtraTargets(t); writeExtraCompilerTargets(t); t << endl << endl;}void Win32MakefileGenerator::writeLibsPart(QTextStream &t){ if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { t << "LIB = " << var("QMAKE_LIB") << endl; } else { t << "LINK = " << var("QMAKE_LINK") << endl; t << "LFLAGS = "; if(!project->values("QMAKE_LIBDIR").isEmpty()) writeLibDirPart(t); t << var("QMAKE_LFLAGS") << endl; t << "LIBS = " << var("QMAKE_LIBS") << endl; }}void Win32MakefileGenerator::writeLibDirPart(QTextStream &t){ QStringList libDirs = project->values("QMAKE_LIBDIR"); for (int i = 0; i < libDirs.size(); ++i) libDirs[i].remove("\""); t << valGlue(libDirs,"-L\"","\" -L\"","\"") << " ";}void Win32MakefileGenerator::writeObjectsPart(QTextStream &t){ t << "OBJECTS = " << valList(escapeDependencyPaths(project->values("OBJECTS"))) << endl;}void Win32MakefileGenerator::writeImplicitRulesPart(QTextStream &t){ t << ".SUFFIXES:"; for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) t << " " << (*cppit); for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit) t << " " << (*cit); t << endl << endl; for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; for(QStringList::Iterator cit = Option::c_ext.begin(); cit != Option::c_ext.end(); ++cit) t << (*cit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;}void Win32MakefileGenerator::writeBuildRulesPart(QTextStream &){}void Win32MakefileGenerator::writeRcFilePart(QTextStream &t){ if(!project->values("RC_FILE").isEmpty()) { const QString res_file = project->first("RES_FILE"), rc_file = fileFixify(project->first("RC_FILE")); // The resource tool needs to have the same defines passed in as the compiler, since you may // use these defines in the .rc file itself. Also, we need to add the _DEBUG define manually // since the compiler defines this symbol by itself, and we use it in the automatically // created rc file when VERSION is define the .pro file. t << res_file << ": " << rc_file << "\n\t" << var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "") << " $(DEFINES) -fo " << res_file << " " << rc_file; t << endl << endl; }}QString Win32MakefileGenerator::getLibTarget(){ return QString(project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".lib");}QString Win32MakefileGenerator::defaultInstall(const QString &t){ if((t != "target" && t != "dlltarget") || (t == "dlltarget" && (project->first("TEMPLATE") != "lib" || !project->isActiveConfig("shared"))) || project->first("TEMPLATE") == "subdirs") return QString(); const QString root = "$(INSTALL_ROOT)"; QStringList &uninst = project->values(t + ".uninstall"); QString ret; QString targetdir = Option::fixPathToTargetOS(project->first(t + ".path"), false); targetdir = fileFixify(targetdir, FileFixifyAbsolute); if(targetdir.right(1) != Option::dir_sep) targetdir += Option::dir_sep; if(t == "target" && project->first("TEMPLATE") == "lib") { if(project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") && !project->isEmpty("QMAKE_INTERNAL_PRL_FILE")) { QString dst_prl = Option::fixPathToTargetOS(project->first("QMAKE_INTERNAL_PRL_FILE")); int slsh = dst_prl.lastIndexOf(Option::dir_sep); if(slsh != -1) dst_prl = dst_prl.right(dst_prl.length() - slsh - 1); dst_prl = filePrefixRoot(root, targetdir + dst_prl); ret += "-$(INSTALL_FILE) \"" + project->first("QMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\""; if(!uninst.isEmpty()) uninst.append("\n\t"); uninst.append("-$(DEL_FILE) \"" + dst_prl + "\""); } if(project->isActiveConfig("shared") && !project->isActiveConfig("plugin")) { QString lib_target = getLibTarget(); lib_target.remove('"'); QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + lib_target; QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + lib_target, FileFixifyAbsolute)); if(!ret.isEmpty()) ret += "\n\t"; ret += QString("-$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\""; if(!uninst.isEmpty()) uninst.append("\n\t"); uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); } } if(t == "dlltarget" || project->values(t + ".CONFIG").indexOf("no_dll") == -1) { QString src_targ = "$(DESTDIR_TARGET)"; QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + "$(TARGET)", FileFixifyAbsolute)); if(!ret.isEmpty()) ret += "\n\t"; ret += QString("-$(INSTALL_FILE)") + " \"" + src_targ + "\" \"" + dst_targ + "\""; if(!uninst.isEmpty()) uninst.append("\n\t"); uninst.append("-$(DEL_FILE) \"" + dst_targ + "\""); } return ret;}QString Win32MakefileGenerator::escapeFilePath(const QString &path) const{ QString ret = path; if(!ret.isEmpty()) { ret = unescapeFilePath(ret); if(ret.contains(" ")) ret = "\"" + ret + "\""; debug_msg(2, "EscapeFilePath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData()); } return ret;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -