📄 vcprojconfiguration.cpp
字号:
if (VCMidlTool.GetValue("ErrorCheckStubData").CompareNoCase("TRUE"))
szErrorCheckStubData = "/error stub_data ";
}
CString szValidateParameters;
if (VCMidlTool.GetValue("ValidateParameters").CompareNoCase("TRUE"))
szValidateParameters = "/robust ";
CString szStructMemberAlignment;
s = VCMidlTool.GetValue("StructMemberAlignment");
if (s.CompareNoCase("1"))
szStructMemberAlignment = "/Zp1 "; // 1-byte alignment
else if (s.CompareNoCase("2"))
szStructMemberAlignment = "/Zp2 "; // 2-byte alignment
else if (s.CompareNoCase("3"))
szStructMemberAlignment = "/Zp4 "; // 4-byte alignment
else if (s.CompareNoCase("4"))
szStructMemberAlignment = "/Zp8 "; // 8-byte alignment
else if (s.CompareNoCase("5"))
szStructMemberAlignment = "/Zp8 "; // no 16-byte alignment in MIDL VC++6.0
CString szRedirectOutputAndErrors;
s = VCMidlTool.GetValue("RedirectOutputAndErrors");
if (!s.IsEmpty())
{
szRedirectOutputAndErrors = "/o\"" + s + "\" ";
}
s = VCMidlTool.GetValue("CPreprocessOptions");
CString szCPreprocessOptions;
ArrayCString arrCPreprocessOptions;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrCPreprocessOptions); // parse comma-separated symbols
else
TokenizeString(s,';',arrCPreprocessOptions); // or parse semi-colon-separated symbols
for (i=0; i<arrCPreprocessOptions.GetSize(); i++)
{
CString szCPreprocss = arrCPreprocessOptions.GetAt(i);
if ( !szCPreprocss.CompareNoCase("$(NOINHERIT)") )
szCPreprocessOptions += "/cpp_opt\"" + szCPreprocss + "\" ";
}
s = VCMidlTool.GetValue("UndefinePreprocessorDefinitions");
CString szUndefinePreprocessorDefinitions;
ArrayCString arrUndefinePreprocessorDefinitions;
if (s.Find(0,",")>-1)
TokenizeString(s,',',arrUndefinePreprocessorDefinitions); // parse comma-separated symbols
else
TokenizeString(s,';',arrUndefinePreprocessorDefinitions); // or parse semi-colon-separated symbols
for (i=0; i<arrUndefinePreprocessorDefinitions.GetSize(); i++)
{
CString szUndefSymbol = arrUndefinePreprocessorDefinitions.GetAt(i);
if ( !szUndefSymbol.CompareNoCase("$(NOINHERIT)") )
szUndefinePreprocessorDefinitions += "/U \"" + szUndefSymbol + "\" ";
}
// target win32 environment (almost always)
//
CString szTargetEnv = "/win32 ";
if (General.GetValue("Name").FindNoCase(0,"Win64")>-1)
szTargetEnv = "/win64 ";
// -- cmdline tab
//
CString szAdditionalOptions = VCMidlTool.GetValue("AdditionalOptions");
szReturn = szSuppressStartupBanner;
szReturn += szPreprocessorDefs;
szReturn += szAdditionalIncludeDirectories;
szReturn += szIgnoreStandardIncludePath;
szReturn += szMkTypLibCompatible;
szReturn += szWarningLevel;
szReturn += szWarnAsError;
szReturn += szDefaultCharset;
szReturn += szGenerateStublessProxies;
szReturn += szOutputDirectory;
szReturn += szHeaderFileName;
szReturn += szInterfaceIdentifierFileName;
szReturn += szDLLDataFileName;
szReturn += szProxyFileName;
szReturn += szTypeLibraryName;
szReturn += szEnableErrorChecks;
szReturn += szErrorCheckAllocations;
szReturn += szErrorCheckBounds;
szReturn += szErrorCheckEnumRange;
szReturn += szErrorCheckRefPointers;
szReturn += szErrorCheckStubData;
szReturn += szValidateParameters;
szReturn += szStructMemberAlignment;
szReturn += szRedirectOutputAndErrors;
szReturn += szCPreprocessOptions;
szReturn += szUndefinePreprocessorDefinitions;
szReturn += szTargetEnv;
szReturn += szAdditionalOptions;
return szReturn;
}
CString vcprojconfiguration::serializeBscMakeSymbols(BOOL bFileConfiguration)
{
CString szReturn, s;
// sections are divided wrt to VC++7 (rescrambled for any reason by MS from VC++6)
// -- general tab
//
CString szSuppressStartupBanner = "/nologo "; // default VC7 behaviour is "suppress banner"
if ( VCBscMakeTool.GetValue("SuppressStartupBanner").CompareNoCase("FALSE") )
szSuppressStartupBanner.Empty();
CString szOutputFile;
s = VCBscMakeTool.GetValue("OutputFile");
if (!s.IsEmpty())
{
szOutputFile = "/o \"" + ExpandMacros(s) + "\" ";
}
// -- cmdline tab
//
CString szAdditionalOptions = VCBscMakeTool.GetValue("AdditionalOptions");
szReturn = szSuppressStartupBanner;
szReturn += szOutputFile;
szReturn += szAdditionalOptions;
return szReturn;
}
void vcprojconfiguration::serializePreBuildCommands(/*out*/ArrayCString &output, BOOL bFileConfiguration)
{
// sections are divided wrt to VC++7 (rescrambled for any reason by MS from VC++6)
// -- general tab
//
CString szDescription = VCPreBuildEventTool.GetValue("Description");
output.Add( szDescription );
CString szCommandLine = VCPreBuildEventTool.GetValue("CommandLine");
szCommandLine = ReplaceMacros(szCommandLine,FALSE);
szCommandLine.ReplaceChar('\n','\t'); // switch to tab char instead
szCommandLine.ReplaceCharWithString('\r',""); // remove these
output.Add( szCommandLine );
if (szCommandLine.IsEmpty())
output.RemoveAll();
}
void vcprojconfiguration::serializePreLinkCommands(/*out*/ArrayCString &output, BOOL bFileConfiguration)
{
// sections are divided wrt to VC++7 (rescrambled for any reason by MS from VC++6)
// -- general tab
//
CString szDescription = VCPreLinkEventTool.GetValue("Description");
output.Add( szDescription );
CString szCommandLine = VCPreLinkEventTool.GetValue("CommandLine");
szCommandLine = ReplaceMacros(szCommandLine,FALSE);
szCommandLine.ReplaceChar('\n','\t'); // switch to tab char instead
szCommandLine.ReplaceCharWithString('\r',""); // remove these
output.Add( szCommandLine );
if (szCommandLine.IsEmpty())
output.RemoveAll();
}
void vcprojconfiguration::serializePostBuildCommands(/*out*/ArrayCString &output, BOOL bFileConfiguration)
{
// sections are divided wrt to VC++7 (rescrambled for any reason by MS from VC++6)
// -- general tab
//
CString szDescription = VCPostBuildEventTool.GetValue("Description");
output.Add( szDescription );
CString szCommandLine = VCPostBuildEventTool.GetValue("CommandLine");
szCommandLine = ReplaceMacros(szCommandLine,FALSE);
szCommandLine.ReplaceChar('\n','\t'); // switch to tab char instead
szCommandLine.ReplaceCharWithString('\r',""); // remove these
output.Add( szCommandLine );
// check whether the user has checked "auto register" in the VCLinkerTool
// and produce a COM registration command
if ( VCLinkerTool.GetValue("RegisterOutput").CompareNoCase("TRUE") )
{
; // create a post build cmd line "Regsvr32.exe /s $(TargetPath)"
// make sure there is no registration already
if (output.GetAt(1).FindNoCase(0,"regsvr32")==-1)
{
szCommandLine = output.GetAt(1);
if (!szCommandLine.IsEmpty()) szCommandLine += "\t";
szCommandLine += "Regsvr32.exe /s $(TargetPath)";
output.SetAt(1, szCommandLine );
}
}
if (szCommandLine.IsEmpty())
output.RemoveAll();
}
void vcprojconfiguration::serializeCustomBuildCommands(/*out*/CString &szDescription,
/*out*/ArrayCString &cmds,
/*out*/ArrayCString &outputFiles,
/*out*/ArrayCString &additionalDeps,
BOOL bFileConfiguration)
{
// sections are divided wrt to VC++7 (rescrambled for any reason by MS from VC++6)
// -- general tab
//
szDescription = VCCustomBuildTool.GetValue("Description");
CString szCommandLines = VCCustomBuildTool.GetValue("CommandLine"); // EOL-separated lines
szCommandLines = ReplaceMacros(szCommandLines,FALSE);
if (!szCommandLines.IsEmpty())
TokenizeString(szCommandLines, '\n', cmds);
CString szOutputFiles = VCCustomBuildTool.GetValue("Outputs"); // semicolon-separated filenames
szOutputFiles = ReplaceMacros(szOutputFiles);
if (!szOutputFiles.IsEmpty())
TokenizeString(szOutputFiles, ';', outputFiles);
CString szAdditionalDependencies = VCCustomBuildTool.GetValue("AdditionalDependencies"); // semicolon-separated filenames
szAdditionalDependencies = ReplaceMacros(szAdditionalDependencies);
if (!szAdditionalDependencies.IsEmpty())
TokenizeString(szAdditionalDependencies, ';', additionalDeps);
}
void vcprojconfiguration::BSTR_to_CString(/*in*/BSTR bstr, /*out*/CString &s)
{
s.Empty();
_bstr_t bstrTag(bstr);
UINT uLen = bstrTag.length();
if (uLen==0) return;
TCHAR *szTemp= new TCHAR[uLen+1];
memset (szTemp, 0, uLen+1);
LPOLESTR wszTag = bstrTag; // get ptr to Unicode
int iBytes = ::WideCharToMultiByte(CP_ACP, 0,
wszTag, uLen,
szTemp, uLen, NULL, NULL);
s = szTemp;
delete [] szTemp;
::SysFreeString(bstr);
}
void vcprojconfiguration::getAttribValue(/*in*/IXMLDOMElement *p, /*in*/char *szAttribName, /*out*/CString &szValue)
{
szValue.Empty();
if (!p) return;
VARIANT vtValue;
p->getAttribute( _bstr_t(szAttribName), &vtValue);
VARIANT_to_CString( vtValue, szValue);
}
void vcprojconfiguration::VARIANT_to_CString(/*in*/VARIANT &vt, /*out*/CString &s)
{
s.Empty();
if (vt.vt!=VT_BSTR) return;
_bstr_t bstrTag(vt);
UINT uLen = bstrTag.length();
if (uLen==0) return;
TCHAR *szTemp= new TCHAR[uLen+1];
memset (szTemp, 0, uLen+1);
LPOLESTR wszTag = bstrTag; // get ptr to Unicode
int iBytes = ::WideCharToMultiByte(CP_ACP, 0,
wszTag, uLen,
szTemp, uLen, NULL, NULL);
s = szTemp;
delete [] szTemp;
::SysFreeString(vt.bstrVal);
}
void vcprojconfiguration::TokenizeString(/*in*/CString &szInput, char cToken, /*out*/ArrayCString &arrStrings)
{
long i;
CString s = szInput;
arrStrings.RemoveAll();
while ( (i=s.Find(0,cToken))>-1 )
{
arrStrings.Add( s.Left(i) );
s = s.ExcludeLeft(i+1);
}
if (!s.IsEmpty())
arrStrings.Add ( s );
}
void vcprojconfiguration::TokenizeString(/*in*/CString &szInput, /*in*/CString &szTokenString, /*out*/ArrayCString &arrStrings)
{
long i;
CString s = szInput;
arrStrings.RemoveAll();
while ( (i=s.Find(0,szTokenString))>-1 )
{
arrStrings.Add( s.Left(i) );
s = s.ExcludeLeft(i+szTokenString.GetLength());
}
if (!s.IsEmpty())
arrStrings.Add ( s );
}
void vcprojconfiguration::UntokenizeString(/*in*/ArrayCString &arrStrings, char cToken, /*out*/CString &szOutput)
{
szOutput.Empty();
for (long i=0;i<arrStrings.GetSize(); i++)
{
if (!szOutput.IsEmpty()) szOutput += cToken;
szOutput += arrStrings.GetAt(i);
}
}
// expand the $(OutDir) and $(IntDir) macros
CString vcprojconfiguration::ExpandMacros(/*in*/CString &szInputString)
{
CString s = szInputString;
CString szOutputDir = General.GetValue("OutputDirectory");
CString szIntermediateDir = General.GetValue("IntermediateDirectory");
if (!szOutputDir.IsEmpty())
{
long n;
while ( (n=s.Find(0, "$(OutDir)"))>-1)
{
s = s.Left(n) +
szOutputDir +
s.ExcludeLeft(n+CString("$(OutDir)").GetLength());
}
} // end if
if (!szIntermediateDir.IsEmpty())
{
long n;
while ( (n=s.Find(0, "$(IntDir)"))>-1)
{
s = s.Left(n) +
szIntermediateDir +
s.ExcludeLeft(n+CString("$(IntDir)").GetLength());
}
} // end if
s.ReplaceChar('/','\\');
return s;
}
// replace VC7 macro names with VC6 macro names (thanks MS for changing them!)
CString vcprojconfiguration::ReplaceMacros(/*in*/CString &szInputString, BOOL bReplaceBackslash)
{
CString s = szInputString;
if (s.IsEmpty()) return s;
// replace $(ProjectDir) with $(ProjDir)
long n;
while ( (n=s.Find(0, "$(ProjectDir)"))>-1)
{
s = s.Left(n) +
CString("$(ProjDir)") +
s.ExcludeLeft(n+CString("$(ProjDir)").GetLength());
}
// remove $(NoInherit) and $(Inherit) : not supported on VC6
while ( (n=s.Find(0, "$(NoInherit)"))>-1)
{
s = s.Left(n) +
s.ExcludeLeft(n+CString("$(NoInherit)").GetLength());
}
while ( (n=s.Find(0, "$(Inherit)"))>-1)
{
s = s.Left(n) +
s.ExcludeLeft(n+CString("$(Inherit)").GetLength());
}
if ( bReplaceBackslash )
s.ReplaceChar('/','\\');
return s;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -