public void UpdateRccStep(VCFile qrcFile, RccOptions rccOpts) { VCProject vcpro = (VCProject)qrcFile.project; EnvDTE.DTE dteObject = ((EnvDTE.Project)vcpro.Object).DTE; QtProject qtPro = QtProject.Create(vcpro); QrcParser parser = new QrcParser(qrcFile.FullPath); string filesInQrcFile = ProjectMacros.Path; if (parser.parse()) { FileInfo fi = new FileInfo(qrcFile.FullPath); string qrcDir = fi.Directory.FullName + "\\"; foreach (QrcPrefix prfx in parser.Prefixes) { foreach (QrcItem itm in prfx.Items) { string relativeQrcItemPath = HelperFunctions.GetRelativePath(this.vcPro.ProjectDirectory, qrcDir + itm.Path); filesInQrcFile += ";" + relativeQrcItemPath; try { VCFile addedFile = qtPro.AddFileInFilter(Filters.ResourceFiles(), relativeQrcItemPath, true); QtProject.ExcludeFromAllBuilds(addedFile); } catch { /* it's not possible to add all kinds of files */ } } } } string nameOnly = HelperFunctions.RemoveFileNameExtension(new FileInfo(qrcFile.FullPath)); string qrcCppFile = QtVSIPSettings.GetRccDirectory(envPro) + "\\" + "qrc_" + nameOnly + ".cpp"; try { foreach (VCFileConfiguration vfc in (IVCCollection)qrcFile.FileConfigurations) { RccOptions rccOptsCfg = rccOpts; string cmdLine = ""; VCCustomBuildTool cbt = HelperFunctions.GetCustomBuildTool(vfc); cbt.AdditionalDependencies = filesInQrcFile; cbt.Description = "Rcc'ing " + ProjectMacros.FileName + "..."; cbt.Outputs = qrcCppFile.Replace(nameOnly, ProjectMacros.Name); cmdLine += "\"" + Resources.rcc4Command + "\"" + " -name \"" + ProjectMacros.Name + "\""; if (rccOptsCfg == null) rccOptsCfg = HelperFunctions.ParseRccOptions(cbt.CommandLine, qrcFile); if (rccOptsCfg.CompressFiles) { cmdLine += " -threshold " + rccOptsCfg.CompressThreshold.ToString(); cmdLine += " -compress " + rccOptsCfg.CompressLevel.ToString(); } else { cmdLine += " -no-compress"; } cmdLine += " \"" + ProjectMacros.Path + "\" -o " + cbt.Outputs; cbt.CommandLine = cmdLine; } AddFileInFilter(Filters.GeneratedFiles(), qrcCppFile, true); } catch(System.Exception /*e*/) { Messages.PaneMessage(dteObject, "*** WARNING (RCC): Couldn't add rcc step"); } }
public void UpdateRccStep(string fileName, RccOptions rccOpts) { VCFile file = (VCFile)((IVCCollection)vcPro.Files).Item(fileName); UpdateRccStep(file, rccOpts); }
public void RefreshRccSteps() { Messages.PaneMessage(dte, "\r\n=== Update rcc steps ==="); List<VCFile> files = GetResourceFiles(); VCFilter vcFilter = FindFilterFromGuid(Filters.GeneratedFiles().UniqueIdentifier); if (vcFilter != null) { IVCCollection filterFiles = (IVCCollection)vcFilter.Files; List<VCFile> filesToDelete = new List<VCFile>(); foreach (VCFile rmFile in filterFiles) { if (rmFile.Name.ToLower().StartsWith("qrc_")) filesToDelete.Add(rmFile); } foreach (VCFile rmFile in filesToDelete) { RemoveFileFromFilter(rmFile, vcFilter); HelperFunctions.DeleteEmptyParentDirs(rmFile); } } foreach (VCFile file in files) { Messages.PaneMessage(dte, "Update rcc step for " + file.Name + "."); RccOptions options = new RccOptions(envPro, file); UpdateRccStep(file, options); } Messages.PaneMessage(dte, "\r\n=== " + files.Count.ToString() + " rcc steps updated. ===\r\n"); }
public void RemoveRccStep(VCFile file) { if (file == null) return; try { string relativeQrcFilePath = file.RelativePath; FileInfo qrcFileInfo = new FileInfo(ProjectDir + "\\" + relativeQrcFilePath); if (qrcFileInfo.Exists) { RccOptions opts = new RccOptions(Project, file); string qrcCppFile = QtVSIPSettings.GetRccDirectory(envPro) + "\\" + opts.OutputFileName; VCFile generatedFile = GetFileFromProject(qrcCppFile); if (generatedFile != null) RemoveFileFromFilter(generatedFile, Filters.GeneratedFiles()); } } catch (System.Exception e) { Messages.DisplayWarningMessage(e); } }
public static RccOptions ParseRccOptions(string cmdLine, VCFile qrcFile) { EnvDTE.Project pro = HelperFunctions.VCProjectToProject((VCProject)qrcFile.project); RccOptions rccOpts = new RccOptions(pro, qrcFile); if (cmdLine.Length > 0) { string[] cmdSplit = cmdLine.Split(new Char[] {' ','\t'}); for (int i=0; i<cmdSplit.Length; ++i) { string lowercmdSplit = cmdSplit[i].ToLower(); if (lowercmdSplit.Equals("-threshold")) { rccOpts.CompressFiles = true; rccOpts.CompressThreshold = int.Parse(cmdSplit[i+1]); } else if (lowercmdSplit.Equals("-compress")) { rccOpts.CompressFiles = true; rccOpts.CompressLevel = int.Parse(cmdSplit[i+1]); } } } return rccOpts; }