📄 vcprojconfiguration.cpp
字号:
//
CString szUsePrecompiledHeader;
s = VCCLCompilerTool.GetValue("UsePrecompiledHeader");
if (s.CompareNoCase("1"))
{
s = VCCLCompilerTool.GetValue("PrecompiledHeaderThrough");
if (s.IsEmpty()) s = "stdafx.h"; // default VC7 precompiled harder
szUsePrecompiledHeader = "/Yc\"" + s + "\" "; // create precompiled headers
// specific code for file configuration
if (bFileConfiguration &&
VCCLCompilerTool.GetValue("PrecompiledHeaderThrough").IsEmpty() &&
m_cpParentConfigurations)
{
s = m_cpParentConfigurations->VCCLCompilerTool.GetValue("PrecompiledHeaderThrough");
if (s.IsEmpty()) s = "stdafx.h"; // default VC7 precompiled harder
szUsePrecompiledHeader = "/Yc\"" + s + "\" "; // create precompiled headers
}
}
else if (s.CompareNoCase("2"))
szUsePrecompiledHeader = "/YX "; // auto
else if (s.CompareNoCase("3"))
{
s = VCCLCompilerTool.GetValue("PrecompiledHeaderThrough");
if (s.IsEmpty()) s = "stdafx.h"; // default VC7 precompiled harder
szUsePrecompiledHeader = "/Yu\"" + s + "\" "; // use
// specific code for file configuration
if (bFileConfiguration &&
VCCLCompilerTool.GetValue("PrecompiledHeaderThrough").IsEmpty() &&
m_cpParentConfigurations)
{
s = m_cpParentConfigurations->VCCLCompilerTool.GetValue("PrecompiledHeaderThrough");
if (s.IsEmpty()) s = "stdafx.h"; // default VC7 precompiled harder
szUsePrecompiledHeader = "/Yu\"" + s + "\" "; // use precompiled headers
}
}
else if (s.CompareNoCase("0"))
{
szUsePrecompiledHeader = "PRECOMP_VC7_TOBEREMOVED ";
}
else if (bFileConfiguration)
{
// for individual files, VC7 may actually use precompiled headers
// without even signaling it in the .vcproj settings
// The only thing we know is the parent configuration setting has UsePrecompiledHeader=3
if (m_cpParentConfigurations &&
m_cpParentConfigurations->VCCLCompilerTool.GetValue("UsePrecompiledHeader").CompareNoCase("3") )
szUsePrecompiledHeader = "/Yu\"stdafx.h\" "; // use default VC7 precompiled headers
}
CString szPrecompiledHeaderFile;
s = VCCLCompilerTool.GetValue("PrecompiledHeaderFile");
if (!s.IsEmpty())
{
szPrecompiledHeaderFile = "/Fp\"" + s + "\" ";
}
// -- output tab
//
CString szAssemblerOutput;
s = VCCLCompilerTool.GetValue("AssemblerOutput");
CString szAssemblerListingLocation = "/Fa\"";
szAssemblerListingLocation += VCCLCompilerTool.GetValue("AssemblerListingLocation");
szAssemblerListingLocation += "\" ";
if (s.CompareNoCase("1"))
{
szAssemblerOutput = "/FA " + szAssemblerListingLocation; // assembly only (.asm)
}
else if (s.CompareNoCase("2"))
{
szAssemblerOutput = "/FAcs " + szAssemblerListingLocation; // assembly + machine + source code (.asm + .cod)
}
else if (s.CompareNoCase("3"))
{
szAssemblerOutput = "/FAc " + szAssemblerListingLocation; // machine code (.cod)
}
else if (s.CompareNoCase("4"))
{
szAssemblerOutput = "/FAs " + szAssemblerListingLocation; // source code (.cod)
}
CString szObjectFile;
s = VCCLCompilerTool.GetValue("ObjectFile");
if (!s.IsEmpty())
{
szObjectFile = "/Fo\"" + s + "\" ";
}
CString szProgramDataBaseFileName;
s = VCCLCompilerTool.GetValue("ProgramDataBaseFileName");
if (!s.IsEmpty())
{
szProgramDataBaseFileName = "/Fd\"" + s + "\" ";
}
// -- browse information tab (generate .sbr files)
//
CString szBrowseInformation;
CString szBrowseInformationFile;
s = VCCLCompilerTool.GetValue("BrowseInformationFile");
if (!s.IsEmpty())
{
szBrowseInformationFile = "\"" + s + "\"";
}
s = VCCLCompilerTool.GetValue("BrowseInformation");
if (s.CompareNoCase("1"))
{// browse all infos
szBrowseInformation = "/FR" + szBrowseInformationFile + " ";
}
else if (s.CompareNoCase("2"))
{// browse all except local infos
szBrowseInformation = "/Fr" + szBrowseInformationFile + " ";
}
// -- advanced tab
//
CString szCallingConvention;
s = VCCLCompilerTool.GetValue("CallingConvention");
if (s.CompareNoCase("0"))
szCallingConvention = "/Gd "; // __cdecl
else if (s.CompareNoCase("1"))
szCallingConvention = "/Gr "; // __fastcall
else if (s.CompareNoCase("2"))
szCallingConvention = "/Gz "; // __stdcall
CString szCompileAs;
s = VCCLCompilerTool.GetValue("CompileAs");
if (s.CompareNoCase("1"))
szCompileAs = "/TC "; // compile as C file
else if (s.CompareNoCase("2"))
szCompileAs = "/TP "; // compile as C++ file
s = VCCLCompilerTool.GetValue("ForcedIncludeFiles");
CString szForceIncludeFiles;
ArrayCString arrForceIncludeFiles;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrForceIncludeFiles); // parse comma-separated filenames
else
TokenizeString(s,';',arrForceIncludeFiles); // or parse semi-colon-separated filenames
for (i=0; i<arrForceIncludeFiles.GetSize(); i++)
{
szForceIncludeFiles += "/FI\"" + arrForceIncludeFiles.GetAt(i) + "\" ";
}
CString szUndefineAllPreprocessorDefinitions;
if ( VCCLCompilerTool.GetValue("UndefineAllPreprocessorDefinitions").CompareNoCase("TRUE") )
szUndefineAllPreprocessorDefinitions = "/u ";
s = VCCLCompilerTool.GetValue("UndefinePreprocessorDefinitions");
CString szUndefPrepDefs;
ArrayCString arrUndefPrepDefs;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrUndefPrepDefs); // parse comma-separated symbols
else
TokenizeString(s,';',arrUndefPrepDefs); // or parse semi-colon-separated symbols
for (i=0; i<arrUndefPrepDefs.GetSize(); i++)
{
szUndefPrepDefs += "/U \"" + arrUndefPrepDefs.GetAt(i) + "\" ";
}
// -- command line
//
CString szReleaseBuildErrors;
if ( getConfigName().Find(0,"Debug")>-1 ) // debug config ?
szReleaseBuildErrors = "/GZ "; // fill stack with 0xCC chars if we are in a debug config
CString szAdditionalOptions = VCCLCompilerTool.GetValue("AdditionalOptions");
// add /GX (enable exception handling)
// (VC7 reference says this option if enabled is in the cmdline, not presented with a checkbox)
if (szAdditionalOptions.Find(0,"/GX")==-1)
szAdditionalOptions += "/GX ";
// mandatory
CString szCompileWithoutLinking;
if (!bFileConfiguration) szCompileWithoutLinking = "/c ";
// concatenate everything to form the line
szReturn = szSuppressStartupBanner;
szReturn += szRuntimeLibrary;
szReturn += szAdditionalIncludeDirectories;
szReturn += szDebugInformationFormat;
szReturn += szWarningLevel;
szReturn += szWarnAsError;
szReturn += szOptimization;
szReturn += szGlobalOptimizations;
szReturn += szInlineFunctionExpansion;
szReturn += szEnableIntrinsicFunctions;
szReturn += szImproveFloatingPointConsistency;
szReturn += szFavorSizeOrSpeed;
szReturn += szOmitFramePointers;
szReturn += szEnableFiberSafeOptimizations;
szReturn += szOptimizeForProcessor;
szReturn += szOptimizeForWindowsApplication;
szReturn += szPreprocessorDefs;
szReturn += szIgnoreStandardIncludePath;
szReturn += szGeneratePreprocessedFile;
szReturn += szKeepComments;
szReturn += szStringPooling;
szReturn += szMinimalRebuild;
szReturn += szExceptionHandling;
szReturn += szStructMemberAlignment;
szReturn += szEnableFunctionLevelLinking;
szReturn += szDisableLanguageExtensions;
szReturn += szDefaultCharIsUnsigned;
szReturn += szRuntimeTypeInfo;
szReturn += szUsePrecompiledHeader;
szReturn += szPrecompiledHeaderFile;
szReturn += szAssemblerOutput;
szReturn += szObjectFile;
szReturn += szProgramDataBaseFileName;
szReturn += szBrowseInformation;
szReturn += szCallingConvention;
szReturn += szCompileAs;
szReturn += szForceIncludeFiles;
szReturn += szUndefineAllPreprocessorDefinitions;
szReturn += szUndefPrepDefs;
szReturn += szReleaseBuildErrors;
szReturn += szCompileWithoutLinking;
szReturn += szAdditionalOptions;
return szReturn;
}
CString vcprojconfiguration::serializeLinkerSymbols(BOOL bFileConfiguration)
{
long i;
CString szReturn, s;
// sections are divided wrt to VC++7 (rescrambled for any reason by MS from VC++6)
// -- general tab
//
CString szDllOutput;
if ( General.GetValue("ConfigurationType").CompareNoCase("2") )
szDllOutput = "/dll ";
CString szOutputFile = VCLinkerTool.GetValue("OutputFile");
if (!szOutputFile.IsEmpty())
{
szOutputFile = "/out:\"" + ExpandMacros(szOutputFile) + "\" ";
}
CString szShowProgress;
s = VCLinkerTool.GetValue("ShowProgress");
if (s.CompareNoCase("1"))
szShowProgress = "/verbose "; // full verbose
else if (s.CompareNoCase("2"))
szShowProgress = "/verbose:lib "; // search-lib verbose only
CString szVersion = VCLinkerTool.GetValue("Version");
if (!szVersion.IsEmpty())
{
szVersion = "/version:" + szVersion + " ";
}
CString szLinkIncremental;
s = VCLinkerTool.GetValue("LinkIncremental");
if (s.CompareNoCase("1"))
szLinkIncremental = "/incremental:no "; // not incremental
else if (s.CompareNoCase("2"))
szLinkIncremental = "/incremental:yes "; // incremental
CString szSuppressStartupBanner = "/nologo "; // default VC7 behaviour is "suppress banner"
if ( VCLinkerTool.GetValue("SuppressStartupBanner").CompareNoCase("FALSE") )
szSuppressStartupBanner.Empty();
// "IgnoreImportLibrary" : ignored because does not exist in VC++ 6
// Purpose : Tells the linker not to try to link any .lib output generated from this
// build into any dependent project. This allows the project system to handle .dll files
// that do not produce a .lib file when built. If a project is dependent on another
// project that produces a DLL, the project system automatically will link the .lib file
// produced by that child project. This may not be needed by projects that are producing
// COM DLLs or resource-only DLLs; these DLLs do not have any meaningful exports. If a
// DLL has no exports, the linker will not generate a .lib file. If no export .lib file
// is present on the disk, and the project system tells the linker to link with this
// (missing) DLL, the link will fail.
// Use Ignore Import Library to resolve this problem. When set to Yes, the project
// system will ignore the presence or absence of that .lib file and cause any project
// that is dependent on this project to not link with the nonexistent .lib file.
s = VCLinkerTool.GetValue("AdditionalLibraryDirectories");
CString szAdditionalLibraryDirectories;
ArrayCString arrAdditionalLibraryDirectories;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrAdditionalLibraryDirectories); // parse comma-separated path
else
TokenizeString(s,';',arrAdditionalLibraryDirectories); // or parse semi-colon-separated path
for (i=0; i<arrAdditionalLibraryDirectories.GetSize(); i++)
{
CString szLibraryDir = arrAdditionalLibraryDirectories.GetAt(i);
if ( !szLibraryDir.CompareNoCase("$(NOINHERIT)") )
szAdditionalLibraryDirectories += "/libpath:\"" + szLibraryDir + "\" ";
}
// -- input tab
//
CString szAdditionalDependencies = VCLinkerTool.GetValue("AdditionalDependencies");
szAdditionalDependencies.ReplaceChar(';',' '); // replace semi-colons with spaces
szAdditionalDependencies.ReplaceChar(',',' '); // replace commas with spaces
if (!szAdditionalDependencies.IsEmpty()) szAdditionalDependencies += " ";
// additional dependencies behave a bit different between VC7 and VC6
// in VC7, default windows libraries (such as kernel32) are not even listed
// in VC7, with a console app, the same.
// whether win32 or console app, if MFC are used, then default libraries are not listed (not useful)
szAdditionalDependencies = "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib " \
"ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib " + szAdditionalDependencies;
CString szIgnoreAllDefaultLibraries;
if ( VCLinkerTool.GetValue("IgnoreAllDefaultLibraries").CompareNoCase("TRUE") )
szIgnoreAllDefaultLibraries = "/nodefaultlib "; // ignore all default libraries
s = VCLinkerTool.GetValue("IgnoreDefaultLibraryNames");
CString szIgnoreDefaultLibraryNames;
ArrayCString arrIgnoreDefaultLibraryNames;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrIgnoreDefaultLibraryNames); // parse comma-separated names
else
TokenizeString(s,';',arrIgnoreDefaultLibraryNames); // or parse semi-colon-separated names
for (i=0; i<arrIgnoreDefaultLibraryNames.GetSize(); i++)
{
CString szDefaultLib = arrIgnoreDefaultLibraryNames.GetAt(i);
if ( !szDefaultLib.CompareNoCase("$(NOINHERIT)") )
szIgnoreDefaultLibraryNames += "/nodefaultlib:\"" + szDefaultLib + "\" ";
}
CString szModuleDefinitionFile = VCLinkerTool.GetValue("ModuleDefinitionFile");
if (!szModuleDefinitionFile.IsEmpty())
{
szModuleDefinitionFile = "/def:\"" + szModuleDefinitionFile + "\" ";
}
s = VCLinkerTool.GetValue("ForceSymbolReferences");
CString szForceSymbolReferences;
ArrayCString arrForceSymbolReferences;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrForceSymbolReferences); // parse comma-separated symbols
else if (s.Find(0,";")>-1)
TokenizeString(s,';',arrForceSymbolReferences); // or parse semi-colon-separated symbols
else
TokenizeString(s,' ',arrForceSymbolReferences); // or parse space-separated symbols
for (i=0; i<arrForceSymbolReferences.GetSize(); i++)
{
CString szForceSymbol = arrForceSymbolReferences.GetAt(i);
if ( !szForceSymbol.CompareNoCase("$(NOINHERIT)") )
szForceSymbolReferences += "/include:\"" + szForceSymbol + "\" ";
}
s = VCLinkerTool.GetValue("DelayLoadDLLs");
CString szDelayLoadDLLs;
ArrayCString arrDelayLoadDLLs;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrDelayLoadDLLs); // parse comma-separated dllpath
else
TokenizeString(s,';',arrDelayLoadDLLs); // or parse semi-colon-separated dllpath
for (i=0; i<arrDelayLoadDLLs.GetSize(); i++)
{
CString szDelayLoad = arrDelayLoadDLLs.GetAt(i);
if ( !szDelayLoad.CompareNoCase("$(NOINHERIT)") )
szDelayLoadDLLs += "/delayload:\"" + szDelayLoad + "\" ";
}
// -- debug tab
//
CString szGenerateDebugInformation;
if ( VCLinkerTool.GetValue("GenerateDebugInformation").CompareNoCase("TRUE") )
szGenerateDebugInformation = "/debug "; // generate debug info
CString szProgramDatabaseFile = VCLinkerTool.GetValue("ProgramDatabaseFile");
if (!szProgramDatabaseFile.IsEmpty())
{
szProgramDatabaseFile = "/pdb:\"" + ExpandMacros(szProgramDatabaseFile) + "\" ";
}
CString szPdbSeparated = "/pdbtype:sept "; // separate pdbs
if ( VCLinkerTool.GetValue("StripPrivateSymbols").CompareNoCase("FALSE") )
szPdbSeparated.Empty();
CString szGenerateMapFile;
if ( VCLinkerTool.GetValue("GenerateMapFile").CompareNoCase("TRUE") )
{
szGenerateMapFile = VCLinkerTool.GetValue("MapFileName");
if (!szGenerateMapFile.IsEmpty())
{
szGenerateMapFile = "/map:\"" + ExpandMacros(szGenerateMapFile) + "\" ";
}
else szGenerateMapFile = "/map ";
if ( VCLinkerTool.GetValue("MapExports").CompareNoCase("TRUE") )
szGenerateMapFile += "/mapinfo:exports ";
else if ( VCLinkerTool.GetValue("MapLines").CompareNoCase("TRUE") )
szGenerateMapFile += "/mapinfo:lines ";
}
// -- system tab
//
CString szSubSystem = "/subsystem:windows "; // generic windows app (entry point)
if ( VCLinkerTool.GetValue("SubSystem").CompareNoCase("1") )
szSubSystem = "/subsystem:console "; // console app (entry point)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -