📄 msvc_vcproj.cpp
字号:
}void VcprojGenerator::initPostBuildEventTools(){ VCConfiguration &RConf = vcProject.Configuration[0]; if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) { RConf.postBuild.Description = var("QMAKE_POST_LINK"); RConf.postBuild.CommandLine = var("QMAKE_POST_LINK"); RConf.postBuild.Description.replace(" && ", " && "); RConf.postBuild.CommandLine.replace(" && ", " && "); } if ( !project->variables()["MSVCPROJ_COPY_DLL"].isEmpty() ) { if ( !RConf.postBuild.CommandLine.isEmpty() ) RConf.postBuild.CommandLine += " && "; RConf.postBuild.Description += var("MSVCPROJ_COPY_DLL_DESC"); RConf.postBuild.CommandLine += var("MSVCPROJ_COPY_DLL"); } if( project->isActiveConfig( "activeqt" ) ) { QString name = project->first( "QMAKE_ORIG_TARGET" ); QString nameext = project->first( "TARGET" ); QString objdir = project->first( "OBJECTS_DIR" ); QString idc = project->first( "QMAKE_IDC" ); RConf.postBuild.Description = "Finalizing ActiveQt server..."; if ( !RConf.postBuild.CommandLine.isEmpty() ) RConf.postBuild.CommandLine += " && "; if( project->isActiveConfig( "dll" ) ) { // In process RConf.postBuild.CommandLine += // call idc to generate .idl file from .dll idc + " "$(TargetPath)" -idl " + objdir + name + ".idl -version 1.0 && " + // call midl to create implementations of the .idl file project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb && " + // call idc to replace tlb... idc + " "$(TargetPath)" /tlb " + objdir + name + ".tlb && " + // register server idc + " "$(TargetPath)" /regserver"; } else { // out of process RConf.postBuild.CommandLine = // call application to dump idl ""$(TargetPath)" -dumpidl " + objdir + name + ".idl -version 1.0 && " + // call midl to create implementations of the .idl file project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb && " + // call idc to replace tlb... idc + " "$(TargetPath)" /tlb " + objdir + name + ".tlb && " + // call app to register ""$(TargetPath)" -regserver"; } }}void VcprojGenerator::initPreLinkEventTools(){}// ------------------------------------------------------------------// Helper functions to do proper sorting of the// qstringlists, for both flat and non-flat modes.inline bool XLessThanY( QString &x, QString &y, bool flat_mode ){ if ( flat_mode ) { QString subX = x.mid( x.findRev('\\')+1 ); QString subY = y.mid( y.findRev('\\')+1 ); return QString::compare(subX, subY) < 0; } int xPos = 0; int yPos = 0; int xSlashPos; int ySlashPos; for (;;) { xSlashPos = x.find('\\', xPos); ySlashPos = y.find('\\', yPos); if (xSlashPos == -1 && ySlashPos != -1) { return FALSE; } else if (xSlashPos != -1 && ySlashPos == -1) { return TRUE; } else if (xSlashPos == -1 /* && yySlashPos == -1 */) { QString subX = x.mid(xPos); QString subY = y.mid(yPos); return QString::compare(subX, subY) < 0; } else { QString subX = x.mid(xPos, xSlashPos - xPos); QString subY = y.mid(yPos, ySlashPos - yPos); int cmp = QString::compare(subX, subY); if (cmp != 0) return cmp < 0; } xPos = xSlashPos + 1; yPos = ySlashPos + 1; } return FALSE;}void nonflatDir_BubbleSort( QStringList& list, bool flat_mode ){ QStringList::Iterator b = list.begin(); QStringList::Iterator e = list.end(); QStringList::Iterator last = e; --last; // goto last if ( last == b ) // shortcut return; while( b != last ) {// sort them bool swapped = FALSE; QStringList::Iterator swap_pos = b; QStringList::Iterator x = e; QStringList::Iterator y = x; --y; QString swap_str; do { --x; --y; if ( XLessThanY(*x,*y, flat_mode) ) { swapped = TRUE; swap_str = (*x); // Swap ------- (*x) = (*y); (*y) = swap_str; // ------------ swap_pos = y; } } while( y != b ); if ( !swapped ) return; b = swap_pos; ++b; }}// ------------------------------------------------------------------void VcprojGenerator::initSourceFiles(){ vcProject.SourceFiles.flat_files = project->isActiveConfig("flat"); vcProject.SourceFiles.Name = "Source Files"; vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"; vcProject.SourceFiles.Files += project->variables()["SOURCES"].gres("&", "&"); nonflatDir_BubbleSort( vcProject.SourceFiles.Files, vcProject.SourceFiles.flat_files ); vcProject.SourceFiles.Project = this; vcProject.SourceFiles.Config = &(vcProject.Configuration); vcProject.SourceFiles.CustomBuild = none;}void VcprojGenerator::initHeaderFiles(){ vcProject.HeaderFiles.flat_files = project->isActiveConfig("flat"); vcProject.HeaderFiles.Name = "Header Files"; vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl"; vcProject.HeaderFiles.Files += project->variables()["HEADERS"]; if (usePCH) { // Generated PCH cpp file if (!vcProject.HeaderFiles.Files.contains(precompH)) vcProject.HeaderFiles.Files += precompH; } nonflatDir_BubbleSort( vcProject.HeaderFiles.Files, vcProject.HeaderFiles.flat_files ); vcProject.HeaderFiles.Project = this; vcProject.HeaderFiles.Config = &(vcProject.Configuration); vcProject.HeaderFiles.CustomBuild = moc;}void VcprojGenerator::initMOCFiles(){ vcProject.MOCFiles.flat_files = project->isActiveConfig("flat"); vcProject.MOCFiles.Name = "Generated MOC Files"; vcProject.MOCFiles.Filter = "cpp;c;cxx;moc"; vcProject.MOCFiles.Files += project->variables()["SRCMOC"].gres("&", "&"); nonflatDir_BubbleSort( vcProject.MOCFiles.Files, vcProject.MOCFiles.flat_files ); vcProject.MOCFiles.Project = this; vcProject.MOCFiles.Config = &(vcProject.Configuration); vcProject.MOCFiles.CustomBuild = moc;}void VcprojGenerator::initUICFiles(){ vcProject.UICFiles.flat_files = project->isActiveConfig("flat"); vcProject.UICFiles.Name = "Generated Form Files"; vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;"; vcProject.UICFiles.Project = this; vcProject.UICFiles.Files += project->variables()["UICDECLS"].gres("&", "&"); vcProject.UICFiles.Files += project->variables()["UICIMPLS"].gres("&", "&"); nonflatDir_BubbleSort( vcProject.UICFiles.Files, vcProject.UICFiles.flat_files ); vcProject.UICFiles.Config = &(vcProject.Configuration); vcProject.UICFiles.CustomBuild = none;}void VcprojGenerator::initFormsFiles(){ vcProject.FormFiles.flat_files = project->isActiveConfig("flat"); vcProject.FormFiles.Name = "Forms"; vcProject.FormFiles.ParseFiles = _False; vcProject.FormFiles.Filter = "ui"; vcProject.FormFiles.Files += project->variables()["FORMS"].gres("&", "&"); nonflatDir_BubbleSort( vcProject.FormFiles.Files, vcProject.FormFiles.flat_files ); vcProject.FormFiles.Project = this; vcProject.FormFiles.Config = &(vcProject.Configuration); vcProject.FormFiles.CustomBuild = uic;}void VcprojGenerator::initTranslationFiles(){ vcProject.TranslationFiles.flat_files = project->isActiveConfig("flat"); vcProject.TranslationFiles.Name = "Translations Files"; vcProject.TranslationFiles.ParseFiles = _False; vcProject.TranslationFiles.Filter = "ts"; vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"].gres("&", "&"); nonflatDir_BubbleSort( vcProject.TranslationFiles.Files, vcProject.TranslationFiles.flat_files ); vcProject.TranslationFiles.Project = this; vcProject.TranslationFiles.Config = &(vcProject.Configuration); vcProject.TranslationFiles.CustomBuild = none;}void VcprojGenerator::initLexYaccFiles(){ vcProject.LexYaccFiles.flat_files = project->isActiveConfig("flat"); vcProject.LexYaccFiles.Name = "Lex / Yacc Files"; vcProject.LexYaccFiles.ParseFiles = _False; vcProject.LexYaccFiles.Filter = "l;y"; vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"].gres("&", "&"); vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"].gres("&", "&"); nonflatDir_BubbleSort( vcProject.LexYaccFiles.Files, vcProject.LexYaccFiles.flat_files ); vcProject.LexYaccFiles.Project = this; vcProject.LexYaccFiles.Config = &(vcProject.Configuration); vcProject.LexYaccFiles.CustomBuild = lexyacc;}void VcprojGenerator::initResourceFiles(){ vcProject.ResourceFiles.flat_files = project->isActiveConfig("flat"); vcProject.ResourceFiles.Name = "Resources"; vcProject.ResourceFiles.ParseFiles = _False; vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts"; if (!project->variables()["RC_FILE"].isEmpty()) vcProject.ResourceFiles.Files += project->variables()["RC_FILE"].gres("&", "&"); if (!project->variables()["RES_FILE"].isEmpty()) vcProject.ResourceFiles.Files += project->variables()["RES_FILE"].gres("&", "&"); vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"].gres("&", "&"); vcProject.ResourceFiles.Files += project->variables()["IMAGES"].gres("&", "&"); vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"].gres("&", "&"); nonflatDir_BubbleSort( vcProject.ResourceFiles.Files, vcProject.ResourceFiles.flat_files ); vcProject.ResourceFiles.Project = this; vcProject.ResourceFiles.Config = &(vcProject.Configuration); vcProject.ResourceFiles.CustomBuild = resource;}/* \internal Sets up all needed variables from the environment and all the different caches and .conf files*/void VcprojGenerator::initOld(){ if( init_flag ) return; init_flag = TRUE; QStringList::Iterator it; if ( project->isActiveConfig("stl") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"]; } else { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"]; } if ( project->isActiveConfig("exceptions") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"]; } else { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; } if ( project->isActiveConfig("rtti") ) { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; } else { project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; } // this should probably not be here, but I'm using it to wrap the .t files if(project->first("TEMPLATE") == "vcapp" ) project->variables()["QMAKE_APP_FLAG"].append("1"); else if(project->first("TEMPLATE") == "vclib") project->variables()["QMAKE_LIB_FLAG"].append("1"); if ( project->variables()["QMAKESPEC"].isEmpty() ) project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); bool is_qt = ( project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX ); QStringList &configs = project->variables()["CONFIG"]; if ( project->isActiveConfig( "shared" ) ) project->variables()["DEFINES"].append( "QT_DLL" ); if ( project->isActiveConfig( "qt_dll" ) && configs.findIndex("qt") == -1 ) configs.append("qt"); if ( project->isActiveConfig( "qt" ) ) { if ( project->isActiveConfig( "plugin" ) ) { project->variables()["CONFIG"].append( "dll" ); project->variables()["DEFINES"].append( "QT_PLUGIN" ); } if ( ( project->variables()["DEFINES"].findIndex( "QT_NODLL" ) == -1 ) && (( project->variables()["DEFINES"].findIndex( "QT_MAKEDLL" ) != -1 || project->variables()["DEFINES"].findIndex( "QT_DLL" ) != -1 ) || ( getenv( "QT_DLL" ) && !getenv( "QT_NODLL" ))) ) { project->variables()["QMAKE_QT_DLL"].append( "1" ); if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) project->variables()["CONFIG"].append( "dll" ); } } // If we are a dll, then we cannot be a staticlib at the same time... if ( project->isActiveConfig( "dll" ) || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { project->variables()["CONFIG"].remove( "staticlib" ); project->variables()["QMAKE_APP_OR_DLL"].append( "1" ); } else { project->variables()["CONFIG"].append( "staticlib" ); } // If we need 'qt' and/or 'opengl', then we need windows and not console if ( project->isActiveConfig( "qt" ) || project->isActiveConfig( "opengl" ) ) { project->variables()["CONFIG"].append( "windows" ); } // Decode version, and add it to $$MSVCPROJ_VERSION -------------- if ( !project->variables()["VERSION"].isEmpty() ) { QString version = project->variables()["VERSION"][0]; int firstDot = version.find( "." ); QString major = version.left( firstDot ); QString minor = version.right( version.length() - firstDot - 1 ); minor.replace( QRegExp( "\\." ), "" ); project->variables()["MSVCPROJ_VERSION"].append( "/VERSION:" + major + "." + minor ); } // QT ------------------------------------------------------------ if ( project->isActiveConfig("qt") ) { project->variables()["CONFIG"].append("moc"); project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { project->variables()["DEFINES"].append("QT_MAKEDLL"); project->variables()["QMAKE_LFLAGS"].append("/BASE:0x39D00000"); } } else { if(project->isActiveConfig("thread")) project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; else project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); if( hver==-1 ) { hver = findHighestVersion( project->first("QMAKE_LIBDIR_QT"), "qt-mt" ); } if(hver != -1) { QString ver; ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); QStringList &libs = project->variables()["QMAKE_LIBS"]; for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -