本文整理汇总了C#中VCFile类的典型用法代码示例。如果您正苦于以下问题:C# VCFile类的具体用法?C# VCFile怎么用?C# VCFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VCFile类属于命名空间,在下文中一共展示了VCFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveIncludes
public Boolean RemoveIncludes(VCFile oFile)
{
Boolean bRetVal = false;
if (oFile.Extension != ".cpp" ||
oFile.Name.ToLowerInvariant().Contains("stdafx.cpp"))
{
return bRetVal;
}
if (Utilities.IsThirdPartyFile(oFile.FullPath, Utilities.GetCurrentConfiguration((VCProject)oFile.project)))
{
return bRetVal;
}
if (!Utilities.CompileFile(oFile, true))
{
mLogger.PrintMessage("ERROR: File '" + oFile.Name + "' must be in a compilable condition before you proceed! Aborting...");
return bRetVal;
}
try
{
SortedDictionary<IncludesKey, VCCodeInclude> oIncludes = new SortedDictionary<IncludesKey, VCCodeInclude>();
List<String> SkipFiles = new List<String>();
Utilities.RetrieveIncludes(oFile, ref oIncludes);
Utilities.RetrieveFilesToSkip(oFile, ref SkipFiles);
foreach (VCCodeInclude oCI in oIncludes.Values)
{
IncludeStructEx oInc = null;
Boolean isLocal = Utilities.IsLocalFile(oCI, ref oInc);
if (oInc != null && SkipFiles.Contains(oInc.sFullPath.ToUpperInvariant()))
{
continue;
}
String sIncludeFile = oCI.FullName;
TextPoint oStartPoint = oCI.StartPoint;
EditPoint oEditPoint = oStartPoint.CreateEditPoint();
String sOrigText = oEditPoint.GetText(oCI.EndPoint);
oEditPoint.Insert("//");
Utilities.SaveFile((ProjectItem)oFile.Object);
if (!Utilities.CompileFile(oFile))
{
oEditPoint.ReplaceText(oStartPoint, "", (int)vsEPReplaceTextOptions.vsEPReplaceTextAutoformat);
Utilities.SaveFile((ProjectItem)oFile.Object);
}
else
{
mLogger.PrintMessage("Dirrective " + sOrigText + " in file " + oFile.Name + " has been found as unnesessary and removed.");
bRetVal = true;
}
}
if (bRetVal)
bRetVal = RemoveIncludes(oFile);
}
catch (SystemException ex)
{
String msg = ex.Message;
}
return bRetVal;
}
示例2: VCFile
public VCFile(VCFile template)
{
mFileState1 = template.fileState1;
mFileState2 = template.fileState2;
mName1 = template.name1;
mName2 = template.name2;
mPath1 = template.path1;
mPath2 = template.path2;
}
示例3: RccOptions
public RccOptions(EnvDTE.Project pro, VCFile qrcFile)
{
project = pro;
id = qrcFile.RelativePath;
qrcFileName = qrcFile.FullPath;
name = id;
if (id.StartsWith(".\\"))
name = name.Substring(2);
if (name.EndsWith(".qrc"))
name = name.Substring(0, name.Length-4);
}
示例4: SortIncludes
public void SortIncludes(VCFile oFile)
{
try
{
if (Utilities.IsThirdPartyFile(oFile.FullPath, Utilities.GetCurrentConfiguration((VCProject)oFile.project)))
{
return;
}
IncludeComparer comparer = new IncludeComparer();
SortedDictionary<IncludesKey, VCCodeInclude> oIncludes = new SortedDictionary<IncludesKey, VCCodeInclude>(comparer);
mLogger.PrintMessage("Processing file ..::" + oFile.FullPath + "::..");
Utilities.RetrieveIncludes(oFile, ref oIncludes);
SortInclude(oIncludes);
}
catch (SystemException ex)
{
mLogger.PrintMessage("Failed when processing file " + oFile.Name + ". Reason: " + ex.Message);
}
}
示例5: Load
public void Load(VCFile file)
{
this.FileName = file.FullPath;
this.Cpps = new Dictionary<string, Cpp>();
string[] lines = File.ReadAllLines(file.FullPath);
for (int i = 0; i < lines.Length; i++)
{
Match match = Utils.IncludeRegex.Match(lines[i]);
if (match.Success && match.Groups["Include"].Captures.Count > 0)
{
string include = match.Groups["Include"].Captures[0].Value;
if (include.EndsWith(".cpp", true, null))
{
Cpp cpp;
VCFile f = Connect.GetVCFile(file.project as VCProject, include);
if (f != null)
{
cpp = new Cpp(f);
}
else
{
cpp = new Cpp(include);
}
if (i > 0 && lines[i - 1].StartsWith("#if"))
{
cpp.Condition = lines[i - 1].Substring(4);
}
cpp.Unity = this;
this.Cpps.Add(cpp.Name, cpp);
}
}
}
}
示例6: CompileSingleFile
/// <summary>
/// compile a single VCFile, do nothing with the OBJ
/// </summary>
public bool CompileSingleFile(VCFile vcFile, VCProject vcProject, VCConfiguration vcCfg, String additionalCmds = "")
{
CVXBuildSystem buildSystem;
try
{
buildSystem = new CVXBuildSystem(_vsOutputWindow, _outputPane);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "ClangVSx Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
try
{
return buildSystem.CompileSingleFile(vcFile, vcProject, vcCfg, additionalCmds);
}
catch (System.Exception ex)
{
WriteToOutputPane("Exception During File Compile : \n" + ex.Message + "\n");
}
return false;
}
示例7: AddMocStep
/// <summary>
/// Adds a moc step to a given file for this project.
/// </summary>
/// <param name="file">file</param>
public void AddMocStep(VCFile file)
{
string oldItemType = file.ItemType;
try
{
string mocFileName = GetMocFileName(file.FullPath);
if (mocFileName == null)
return;
bool hasDifferentMocFilePerConfig = QtVSIPSettings.HasDifferentMocFilePerConfig(envPro);
bool hasDifferentMocFilePerPlatform = QtVSIPSettings.HasDifferentMocFilePerPlatform(envPro);
bool mocableIsCPP = mocFileName.ToLower().EndsWith(".moc");
#if (VS2010 || VS2012 || VS2013)
if (!mocableIsCPP && file.ItemType != "CustomBuild")
{
file.ItemType = "CustomBuild";
}
#endif
#if VS2013
file = Update(this, file);
#endif
#region Add moc for each configuration
foreach (VCFileConfiguration config in (IVCCollection)file.FileConfigurations)
{
string name = ((VCCustomBuildTool)config.Tool).toolName;
VCConfiguration vcConfig = config.ProjectConfiguration as VCConfiguration;
VCPlatform platform = vcConfig.Platform as VCPlatform;
string platformName = platform.Name;
string mocRelPath = GetRelativeMocFilePath(file.FullPath, vcConfig.ConfigurationName, platformName);
string platformFilterName = null;
string configFilterName = null;
if (mocRelPath.Contains(platformName))
{
platformFilterName = platformName;
}
if (mocRelPath.Contains(vcConfig.ConfigurationName))
{
configFilterName = vcConfig.ConfigurationName;
}
VCFile mocFile = GetFileFromProject(mocRelPath);
if (mocFile == null)
{
FileInfo fi = new FileInfo(this.VCProject.ProjectDirectory + "\\" + mocRelPath);
if (!fi.Directory.Exists)
fi.Directory.Create();
mocFile = AddFileInSubfilter(Filters.GeneratedFiles(), platformFilterName, configFilterName, mocRelPath);
#if (VS2010 || VS2012 || VS2013)
if (mocFileName.ToLower().EndsWith(".moc"))
{
ProjectItem mocFileItem = mocFile.Object as ProjectItem;
if (mocFileItem != null)
HelperFunctions.EnsureCustomBuildToolAvailable(mocFileItem);
}
#endif
}
if (mocFile == null)
throw new Qt4VSException(SR.GetString("QtProject_CannotAddMocStep", file.FullPath));
VCCustomBuildTool tool = null;
string fileToMoc = null;
if (!mocableIsCPP)
{
tool = HelperFunctions.GetCustomBuildTool(config);
fileToMoc = ProjectMacros.Path;
}
else
{
VCFileConfiguration mocConf = GetVCFileConfigurationByName(mocFile, vcConfig.Name);
tool = HelperFunctions.GetCustomBuildTool(mocConf);
fileToMoc = HelperFunctions.GetRelativePath(vcPro.ProjectDirectory, file.FullPath);
}
if (tool == null)
throw new Qt4VSException(SR.GetString("QtProject_CannotFindCustomBuildTool", file.FullPath));
if (hasDifferentMocFilePerPlatform && hasDifferentMocFilePerConfig)
{
foreach (VCFileConfiguration mocConf in (IVCCollection)mocFile.FileConfigurations)
{
VCConfiguration projectCfg = mocConf.ProjectConfiguration as VCConfiguration;
if (projectCfg.Name != vcConfig.Name || (IsMoccedFileIncluded(file) && !mocableIsCPP))
{
if (!mocConf.ExcludedFromBuild)
mocConf.ExcludedFromBuild = true;
}
else
{
//.........这里部分代码省略.........
示例8: RefreshMocStep
/// <summary>
/// Updates the moc command line for the given header or source file
/// containing the Q_OBJECT macro.
/// If the function is called from a property change for a single file
/// (singleFile = true) we may have to look for the according header
/// file and refresh the moc step for this file, if it contains Q_OBJECT.
/// </summary>
/// <param name="vcfile"></param>
private void RefreshMocStep(VCFile vcfile, bool singleFile)
{
bool isHeaderFile = HelperFunctions.HasHeaderFileExtension(vcfile.FullPath);
if (!isHeaderFile && !HelperFunctions.HasSourceFileExtension(vcfile.FullPath))
return;
if (mocCmdChecker == null)
mocCmdChecker = new MocCmdChecker();
foreach (VCFileConfiguration config in (IVCCollection)vcfile.FileConfigurations)
{
try
{
VCCustomBuildTool tool = null;
VCFile mocable = null;
if (isHeaderFile)
{
mocable = vcfile;
tool = HelperFunctions.GetCustomBuildTool(config);
}
else
{
string mocFileName = GetMocFileName(vcfile.FullPath);
VCFile mocFile = GetGeneratedMocFile(mocFileName, config);
if (mocFile != null)
{
VCFileConfiguration mocFileConfig = GetVCFileConfigurationByName(mocFile, config.Name);
tool = HelperFunctions.GetCustomBuildTool(mocFileConfig);
mocable = mocFile;
}
// It is possible that the function was called from a source file's property change, it is possible that
// we have to obtain the tool from the according header file
if (tool == null && singleFile)
{
string headerName = vcfile.FullPath.Remove(vcfile.FullPath.LastIndexOf('.')) + ".h";
mocFileName = GetMocFileName(headerName);
mocFile = GetGeneratedMocFile(mocFileName, config);
if (mocFile != null)
{
mocable = GetFileFromProject(headerName);
VCFileConfiguration customBuildConfig = GetVCFileConfigurationByName(mocable, config.Name);
tool = HelperFunctions.GetCustomBuildTool(customBuildConfig);
}
}
}
if (tool == null || tool.CommandLine.ToLower().IndexOf("moc.exe") == -1)
continue;
VCFile srcMocFile = GetSourceFileForMocStep(mocable);
VCFile cppFile = GetCppFileForMocStep(mocable);
if (srcMocFile == null)
continue;
bool mocableIsCPP = (srcMocFile == cppFile);
string pchParameters = null;
VCFileConfiguration cppConfig = GetVCFileConfigurationByName(cppFile, config.Name);
CompilerToolWrapper compiler = CompilerToolWrapper.Create(cppConfig);
if (compiler.GetUsePrecompiledHeader() != pchOption.pchNone)
pchParameters = GetPCHMocOptions(srcMocFile, compiler);
string outputFileName = QtVSIPSettings.GetMocDirectory(envPro) + "\\";
if (mocableIsCPP)
{
outputFileName += ProjectMacros.Name;
outputFileName += ".moc";
}
else
{
outputFileName += "moc_";
outputFileName += ProjectMacros.Name;
outputFileName += ".cpp";
}
string newCmdLine = mocCmdChecker.NewCmdLine(tool.CommandLine,
GetIncludes(cppConfig),
GetDefines(cppConfig),
QtVSIPSettings.GetMocOptions(envPro), srcMocFile.RelativePath,
pchParameters,
outputFileName);
// The tool's command line automatically gets a trailing "\r\n".
// We have to remove it to make the check below work.
string origCommandLine = tool.CommandLine;
if (origCommandLine.EndsWith("\r\n"))
origCommandLine = origCommandLine.Substring(0, origCommandLine.Length - 2);
if (newCmdLine != null && newCmdLine != origCommandLine)
{
// We have to delete the old moc file in order to trigger custom build step.
string configName = config.Name.Remove(config.Name.IndexOf("|"));
string platformName = config.Name.Substring(config.Name.IndexOf("|") + 1);
string projectPath = envPro.FullName.Remove(envPro.FullName.LastIndexOf('\\'));
//.........这里部分代码省略.........
示例9: GetPCHMocOptions
private string GetPCHMocOptions(VCFile file, CompilerToolWrapper compiler)
{
// As .moc files are included, we should not add anything there
if (!HelperFunctions.HasHeaderFileExtension(file.Name))
return "";
string additionalMocOptions = "\"-f" + compiler.GetPrecompiledHeaderThrough().Replace('\\', '/') + "\" ";
//Get mocDir without .\\ at the beginning of it
string mocDir = QtVSIPSettings.GetMocDirectory(envPro);
if (mocDir.StartsWith(".\\"))
mocDir = mocDir.Substring(2);
//Get the absolute path
mocDir = vcPro.ProjectDirectory + mocDir;
string relPathToFile = HelperFunctions.GetRelativePath(mocDir, file.FullPath).Replace('\\', '/');
additionalMocOptions += "\"-f" + relPathToFile + "\"";
return additionalMocOptions;
}
示例10: SetPCHOption
public static void SetPCHOption(VCFile vcFile, pchOption option)
{
foreach (VCFileConfiguration config in vcFile.FileConfigurations as IVCCollection)
{
CompilerToolWrapper compiler = CompilerToolWrapper.Create(config);
compiler.SetUsePrecompiledHeader(option);
}
}
示例11: GetVCFileConfigurationByName
private static VCFileConfiguration GetVCFileConfigurationByName(VCFile file, string configName)
{
foreach (VCFileConfiguration cfg in (IVCCollection)file.FileConfigurations)
{
if (cfg.Name == configName)
return cfg;
}
return null;
}
示例12: RemoveFileFromFilter
/// <summary>
/// Removes a file from the filter.
/// This file will be deleted!
/// </summary>
/// <param name="project">project</param>
/// <param name="file">file</param>
public void RemoveFileFromFilter(VCFile file, VCFilter filter)
{
try
{
filter.RemoveFile(file);
FileInfo fi = new FileInfo(file.FullPath);
if (fi.Exists)
fi.Delete();
}
catch
{
}
IVCCollection subfilters = (IVCCollection)filter.Filters;
for (int i = subfilters.Count; i > 0; i--)
{
try
{
VCFilter subfilter = (VCFilter)subfilters.Item(i);
RemoveFileFromFilter(file, subfilter);
}
catch
{
}
}
}
示例13: OnExcludedFromBuildChanged
public void OnExcludedFromBuildChanged(VCFile vcFile, VCFileConfiguration vcFileCfg)
{
// Update the ExcludedFromBuild flags of the mocced file
// according to the ExcludedFromBuild flag of the mocable source file.
string moccedFileName = GetMocFileName(vcFile.Name);
if (string.IsNullOrEmpty(moccedFileName))
return;
VCFile moccedFile = GetGeneratedMocFile(moccedFileName, vcFileCfg);
if (moccedFile != null)
{
VCFile cppFile = null;
if (HelperFunctions.HasHeaderFileExtension(vcFile.Name))
cppFile = GetCppFileForMocStep(vcFile);
VCFileConfiguration moccedFileConfig = GetVCFileConfigurationByName(moccedFile, vcFileCfg.Name);
if (moccedFileConfig != null)
{
if (cppFile != null && IsMoccedFileIncluded(cppFile))
{
if (!moccedFileConfig.ExcludedFromBuild)
{
moccedFileConfig.ExcludedFromBuild = true;
}
}
else if (moccedFileConfig.ExcludedFromBuild != vcFileCfg.ExcludedFromBuild)
moccedFileConfig.ExcludedFromBuild = vcFileCfg.ExcludedFromBuild;
}
}
}
示例14: UpdateUicSteps
public void UpdateUicSteps(string oldUicDir, bool update_inc_path)
{
Messages.PaneMessage(dte, "\r\n=== Update uic steps ===");
VCFilter vcFilter = FindFilterFromGuid(Filters.GeneratedFiles().UniqueIdentifier);
if (vcFilter != null)
{
IVCCollection filterFiles = (IVCCollection)vcFilter.Files;
for (int i = filterFiles.Count; i > 0; i--)
{
VCFile file = (VCFile)filterFiles.Item(i);
if (file.Name.ToLower().StartsWith("ui_"))
{
RemoveFileFromFilter(file, vcFilter);
HelperFunctions.DeleteEmptyParentDirs(file);
}
}
}
int updatedFiles = 0;
int j = 0;
VCFile[] files = new VCFile[((IVCCollection)vcPro.Files).Count];
foreach (VCFile file in (IVCCollection)vcPro.Files)
{
files[j++] = file;
}
foreach (VCFile file in files)
{
if (file.Name.EndsWith(".ui") && !IsUic3File(file))
{
AddUic4BuildStep(file);
Messages.PaneMessage(dte, "Update uic step for " + file.Name + ".");
++updatedFiles;
}
}
if (update_inc_path)
{
UpdateCompilerIncludePaths(oldUicDir, QtVSIPSettings.GetUicDirectory(envPro));
}
Messages.PaneMessage(dte, "\r\n=== " + updatedFiles.ToString()
+ " uic steps updated. ===\r\n");
}
示例15: CheckForCommand
private static bool CheckForCommand(VCFile file, string cmd)
{
if (file == null)
return false;
foreach (VCFileConfiguration config in (IVCCollection)file.FileConfigurations)
{
VCCustomBuildTool tool = HelperFunctions.GetCustomBuildTool(config);
if (tool == null)
return false;
if (tool.CommandLine != null && tool.CommandLine.Contains(cmd))
return true;
}
return false;
}