📄 msvc_vcproj.cpp
字号:
opt != "ole32.lib" && opt != "oleaut32.lib" && opt != "uuid.lib" && opt != "imm32.lib" && opt != "winmm.lib" && opt != "wsock32.lib" && opt != "ws2_32.lib" && opt != "winspool.lib" && opt != "delayimp.lib") { newDep->dependencies << opt.section(Option::dir_sep, -1); } } }#ifdef DEBUG_SOLUTION_GEN qDebug("Deps for %20s: [%s]", newDep->target.toLatin1().constData(), newDep->dependencies.join(" :: ").toLatin1().constData());#endif solution_cleanup.append(newDep); solution_depends.insert(newDep->target, newDep); t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile << "\", \"" << newDep->uuid << "\""; t << _slnProjectEnd; } }nextfile: qmake_setpwd(oldpwd); } } } t << _slnGlobalBeg; t << _slnSolutionConf; t << _slnProjDepBeg; // Restore previous after_user_var options Option::after_user_vars = old_after_vars; // Figure out dependencies for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) { int cnt = 0; for(QStringList::iterator dit = (*it)->dependencies.begin(); dit != (*it)->dependencies.end(); ++dit) { if(VcsolutionDepend *vc = solution_depends[*dit]) t << "\n\t\t" << (*it)->uuid << "." << cnt++ << " = " << vc->uuid; } } t << _slnProjDepEnd; t << _slnProjConfBeg; for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) { t << "\n\t\t" << (*it)->uuid << _slnProjDbgConfTag1; t << "\n\t\t" << (*it)->uuid << _slnProjDbgConfTag2; t << "\n\t\t" << (*it)->uuid << _slnProjRelConfTag1; t << "\n\t\t" << (*it)->uuid << _slnProjRelConfTag2; } t << _slnProjConfEnd; t << _slnExtSections; t << _slnGlobalEnd; while (!solution_cleanup.isEmpty()) delete solution_cleanup.takeFirst();}// ------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------bool VcprojGenerator::hasBuiltinCompiler(const QString &file){ // Source files for (int i = 0; i < Option::cpp_ext.count(); ++i) if (file.endsWith(Option::cpp_ext.at(i))) return true; for (int i = 0; i < Option::c_ext.count(); ++i) if (file.endsWith(Option::c_ext.at(i))) return true; if (file.endsWith(".rc") || file.endsWith(".idl")) return true; return false;}void VcprojGenerator::init(){ if(init_flag) return; if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs init_flag = true; return; } debug_msg(1, "Generator: MSVC.NET: Initializing variables"); // this should probably not be here, but I'm using it to wrap the .t files if(project->first("TEMPLATE") == "vcapp") project->values("QMAKE_APP_FLAG").append("1"); else if(project->first("TEMPLATE") == "vclib") project->values("QMAKE_LIB_FLAG").append("1"); if(project->values("QMAKESPEC").isEmpty()) project->values("QMAKESPEC").append(qgetenv("QMAKESPEC")); processVars(); initOld(); // Currently calling old DSP code to set variables. CLEAN UP! // Figure out what we're trying to build if(project->first("TEMPLATE") == "vcapp") { projectTarget = Application; } else if(project->first("TEMPLATE") == "vclib") { if(project->isActiveConfig("staticlib")) projectTarget = StaticLib; else projectTarget = SharedLib; } // Setup PCH variables precompH = project->first("PRECOMPILED_HEADER"); precompCPP = project->first("PRECOMPILED_SOURCE"); usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); if (usePCH) { precompHFilename = fileInfo(precompH).fileName(); // Created files QString origTarget = unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); precompObj = origTarget + Option::obj_ext; precompPch = origTarget + ".pch"; // Add PRECOMPILED_HEADER to HEADERS if (!project->values("HEADERS").contains(precompH)) project->values("HEADERS") += precompH; // Return to variable pool project->values("PRECOMPILED_OBJECT") = QStringList(precompObj); project->values("PRECOMPILED_PCH") = QStringList(precompPch); autogenPrecompCPP = precompCPP.isEmpty() && project->isActiveConfig("autogen_precompile_source"); if (autogenPrecompCPP) { precompCPP = precompH + (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp")); project->values("GENERATED_SOURCES") += precompCPP; } else if (!precompCPP.isEmpty()) { project->values("SOURCES") += precompCPP; } } // Add all input files for a custom compiler into a map for uniqueness, // unless the compiler is configure as a combined stage, then use the first one const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS"); for(QStringList::ConstIterator it = quc.constBegin(); it != quc.constEnd(); ++it) { const QStringList &invar = project->variables().value((*it) + ".input"); const QString compiler_out = project->first((*it) + ".output"); for(QStringList::ConstIterator iit = invar.constBegin(); iit != invar.constEnd(); ++iit) { QStringList fileList = project->variables().value(*iit); if (!fileList.isEmpty()) { if (project->values((*it) + ".CONFIG").indexOf("combine") != -1) fileList = QStringList(fileList.first()); for(QStringList::ConstIterator fit = fileList.constBegin(); fit != fileList.constEnd(); ++fit) { QString file = (*fit); if (verifyExtraCompiler((*it), file)) { if (!hasBuiltinCompiler(file)) { extraCompilerSources[file] += *it; } else { QString out = Option::fixPathToTargetOS(replaceExtraCompilerVariables( compiler_out, file, QString()), false); extraCompilerSources[out] += *it; extraCompilerOutputs[out] = QStringList(file); // Can only have one } } } } } }#if 0 // Debugging Q_FOREACH(QString aKey, extraCompilerSources.keys()) { qDebug("Extracompilers for %s are (%s)", aKey.toLatin1().constData(), extraCompilerSources.value(aKey).join(", ").toLatin1().constData()); } Q_FOREACH(QString aKey, extraCompilerOutputs.keys()) { qDebug("Object mapping for %s is (%s)", aKey.toLatin1().constData(), extraCompilerOutputs.value(aKey).join(", ").toLatin1().constData()); } qDebug("");#endif}bool VcprojGenerator::mergeBuildProject(MakefileGenerator *other){ VcprojGenerator *otherVC = static_cast<VcprojGenerator*>(other); if (!otherVC) { warn_msg(WarnLogic, "VcprojGenerator: Cannot merge other types of projects! (ignored)"); return false; } mergedProjects += otherVC; return true;}void VcprojGenerator::initProject(){ // Initialize XML sub elements // - Do this first since project elements may need // - to know of certain configuration options initConfiguration(); initRootFiles(); initSourceFiles(); initHeaderFiles(); initGeneratedFiles(); initLexYaccFiles(); initTranslationFiles(); initFormFiles(); initResourceFiles(); initExtraCompilerOutputs(); // Own elements ----------------------------- vcProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); switch(which_dotnet_version()) { case NET2005: //### using ',' because of a bug in 2005 B2 //### VS uses '.' or ',' depending on the regional settings! Using ',' always works. vcProject.Version = "8,00"; break; case NET2003: vcProject.Version = "7.10"; break; case NET2002: vcProject.Version = "7.00"; break; default: vcProject.Version = "7.00"; warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .vcproj", which_dotnet_version()); break; } vcProject.Keyword = project->first("VCPROJ_KEYWORD"); vcProject.PlatformName = (vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32"); // These are not used by Qt, but may be used by customers vcProject.SccProjectName = project->first("SCCPROJECTNAME"); vcProject.SccLocalPath = project->first("SCCLOCALPATH"); vcProject.flat_files = project->isActiveConfig("flat");}void VcprojGenerator::initConfiguration(){ // Initialize XML sub elements // - Do this first since main configuration elements may need // - to know of certain compiler/linker options VCConfiguration &conf = vcProject.Configuration; conf.CompilerVersion = which_dotnet_version(); initCompilerTool(); // Only on configuration per build bool isDebug = project->isActiveConfig("debug"); if(projectTarget == StaticLib) initLibrarianTool(); else { conf.linker.GenerateDebugInformation = isDebug ? _True : _False; initLinkerTool(); } initResourceTool(); initIDLTool(); // Own elements ----------------------------- QString temp = project->first("BuildBrowserInformation"); switch (projectTarget) { case SharedLib: conf.ConfigurationType = typeDynamicLibrary; break; case StaticLib: conf.ConfigurationType = typeStaticLibrary; break; case Application: default: conf.ConfigurationType = typeApplication; break; } conf.Name = project->values("BUILD_NAME").join(" "); if (conf.Name.isEmpty()) conf.Name = isDebug ? "Debug" : "Release"; conf.Name += (conf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32"); conf.ATLMinimizesCRunTimeLibraryUsage = (project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True); conf.BuildBrowserInformation = triState(temp.isEmpty() ? (short)unset : temp.toShort()); temp = project->first("CharacterSet"); conf.CharacterSet = charSet(temp.isEmpty() ? (short)charSetNotSet : temp.toShort()); conf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); conf.ImportLibrary = conf.linker.ImportLibrary; conf.IntermediateDirectory = project->first("OBJECTS_DIR"); conf.OutputDirectory = "."; conf.PrimaryOutput = project->first("PrimaryOutput"); conf.WholeProgramOptimization = conf.compiler.WholeProgramOptimization; temp = project->first("UseOfATL"); if(!temp.isEmpty()) conf.UseOfATL = useOfATL(temp.toShort()); temp = project->first("UseOfMfc"); if(!temp.isEmpty()) conf.UseOfMfc = useOfMfc(temp.toShort()); // Configuration does not need parameters from // these sub XML items; initCustomBuildTool(); initPreBuildEventTools(); initPostBuildEventTools(); initPreLinkEventTools(); // Set definite values in both configurations if (isDebug) { conf.compiler.PreprocessorDefinitions.removeAll("NDEBUG"); } else { conf.compiler.PreprocessorDefinitions += "NDEBUG"; }}void VcprojGenerator::initCompilerTool(){ QString placement = project->first("OBJECTS_DIR"); if(placement.isEmpty()) placement = ".\\"; VCConfiguration &conf = vcProject.Configuration;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -