internal Project CreateProject(Process process) { var project = new Project(process.Provenance.QualifierId); // All projects in a msbuild file must use the same BuildXL value. // TODO: Check whether this is the same BuildXL value as the other projects in this msbuild file var value = process.Provenance.OutputValueSymbol.ToString(Context.SymbolTable); project.SetProperty("DominoValue", value); project.SetProperty("ProjectGuid", Guid); project.SetProperty("SpecRoot", SpecDirectory); var relativeSpecFile = Context.GetRelativePath(SpecFilePath).ToString(Context.StringTable); project.SetProperty("DominoSpecFile", relativeSpecFile); project.AddItem("None", SpecFilePath); var dirString = SpecFilePath.GetParent(Context.PathTable).ToString(Context.PathTable); var packagePath = System.IO.Path.Combine(dirString, "package" + Names.DotDscExtension); var packageConfigPath = System.IO.Path.Combine(dirString, Names.PackageConfigDsc); if (System.IO.File.Exists(packagePath)) { project.AddItem("DominoPackageFile", AbsolutePath.Create(Context.PathTable, packagePath)); } if (System.IO.File.Exists(packageConfigPath)) { project.AddItem("DominoPackageConfigFile", AbsolutePath.Create(Context.PathTable, packageConfigPath)); } return(project); }
internal Project CreateProject(Process process) { string qualifierString = Context.QualifierTable.GetCanonicalDisplayString(process.Provenance.QualifierId); var project = new Project(qualifierString); // All projects in a msbuild file must use the same BuildXL value. // TODO: Check whether this is the same BuildXL value as the other projects in this msbuild file var value = process.Provenance.OutputValueSymbol.ToString(Context.SymbolTable); project.SetProperty("DominoValue", value); project.SetProperty("ProjectGuid", Guid); project.SetProperty("SpecRoot", SpecDirectory); // Try to get the target framework: var qualifier = Context.QualifierTable.GetQualifier(process.Provenance.QualifierId); if (qualifier.TryGetValue(Context.StringTable, "targetFramework", out var targetFramework)) { // MsBuild has its own version number so do a custom if (targetFramework.StartsWith("net") && targetFramework.Substring(3).ToCharArray().All(char.IsDigit)) { var msbuildStyleTf = "v" + string.Join(".", targetFramework.Substring(3).ToCharArray()); project.SetProperty("TargetFrameworkVersion", msbuildStyleTf); project.SetProperty("TargetFrameworkProfile", string.Empty); } } var relativeSpecFile = Context.GetRelativePath(SpecFilePath).ToString(Context.StringTable); project.SetProperty("DominoSpecFile", relativeSpecFile); project.AddItem("None", SpecFilePath); var dirString = SpecFilePath.GetParent(Context.PathTable).ToString(Context.PathTable); var packagePath = System.IO.Path.Combine(dirString, "package" + Names.DotDscExtension); var packageConfigPath = System.IO.Path.Combine(dirString, Names.PackageConfigDsc); if (System.IO.File.Exists(packagePath)) { project.AddItem("DominoPackageFile", AbsolutePath.Create(Context.PathTable, packagePath)); } if (System.IO.File.Exists(packageConfigPath)) { project.AddItem("DominoPackageConfigFile", AbsolutePath.Create(Context.PathTable, packageConfigPath)); } return(project); }
internal override void VisitProcess(Process process, ProcessType pipCategory) { string friendlyQualifier = Context.QualifierTable.GetCanonicalDisplayString(process.Provenance.QualifierId); // TODO: After fixing the qualifier in the DS, I will start using the qualifier id instead of friendly qualifier name // Context.QualifierTable.GetQualifiedOutputDirectoryPart(Context.StringTable, qualifierId).ToString(Context.StringTable); var arguments = Context.GetArgumentsDataFromProcess(process); Project project; if (!ProjectsByQualifier.TryGetValue(friendlyQualifier, out project)) { project = CreateProject(process); project.SetProperty("PlatformToolset", "v140"); FillProjectConfigurations(project); AddHeaderFiles(project); ProjectsByQualifier.Add(friendlyQualifier, project); } switch (pipCategory) { case ProcessType.Cl: IterateClArguments(project, arguments); break; case ProcessType.Link: IterateLinkArguments(project, arguments); // If this is DS, use WorkingDirectory as an output folder. var outputDir = ExtensionUtilities.IsScriptExtension(SpecFilePath.GetExtension(Context.PathTable).ToString(Context.StringTable)) ? process.WorkingDirectory : process.UniqueOutputDirectory; SetOutputDirectory(project, outputDir, OutputDirectoryType.Build); break; } }
public bool Validate() { // Spec file path validation if (string.IsNullOrWhiteSpace(SpecFilePath)) { PrintError("Missing parameter for spectrum file path"); return(false); } // Check for folder-type datasets, and replace specFilePath with the directory name if it is. SpecFilePath = MassSpecDataReaderFactory.GetDatasetName(SpecFilePath); var isDirectoryDataset = MassSpecDataReaderFactory.IsADirectoryDataset(SpecFilePath); // True if specFilePath is a directory that is NOT a supported folder-type dataset. var specPathIsDirectory = Directory.Exists(SpecFilePath) && !isDirectoryDataset; if (!File.Exists(SpecFilePath) && !specPathIsDirectory && !isDirectoryDataset) { PrintError("File not found: " + SpecFilePath); return(false); } var types = MassSpecDataReaderFactory.MassSpecDataTypeFilterList; if (!specPathIsDirectory && !(types.Select(ext => SpecFilePath.ToLower().EndsWith(ext)).Any())) { PrintError("Invalid file extension for spectrum file: (" + Path.GetExtension(SpecFilePath) + ") " + SpecFilePath); return(false); } // TODO: Handle non-.raw files in the subfolder SpecFilePaths = Directory.Exists(SpecFilePath) && !MassSpecDataReaderFactory.IsADirectoryDataset(SpecFilePath) ? Directory.GetFiles(SpecFilePath, "*.raw") : new[] { SpecFilePath }; // Database path validation if (string.IsNullOrWhiteSpace(DatabaseFilePath)) { PrintError("Missing parameter for database file path"); return(false); } if (!File.Exists(DatabaseFilePath)) { PrintError("File not found: " + DatabaseFilePath); return(false); } var dbExtension = Path.GetExtension(DatabaseFilePath).ToLower(); if (!dbExtension.Equals(".fa") && !dbExtension.Equals(".fasta")) { PrintError("Invalid extension for the database file path (" + dbExtension + ")"); return(false); } // Output directory validation if (string.IsNullOrWhiteSpace(OutputDir)) { // Must use "Path.GetFullPath" to return the absolute path when the source file is in the working directory // But, it could cause problems with too-long paths. OutputDir = specPathIsDirectory ? SpecFilePath : Path.GetDirectoryName(Path.GetFullPath(SpecFilePath)); } if (string.IsNullOrWhiteSpace(OutputDir)) { PrintError("Invalid output file directory: " + OutputDir); return(false); } if (!Directory.Exists(OutputDir)) { if (File.Exists(OutputDir) && !File.GetAttributes(OutputDir).HasFlag(FileAttributes.Directory)) { PrintError("OutputDir \"" + OutputDir + "\" is not a directory!"); return(false); } Directory.CreateDirectory(OutputDir); } // Mods file validation if (!string.IsNullOrWhiteSpace(ModsFilePath) && !File.Exists(ModsFilePath)) { PrintError("Modifications file not found: " + ModsFilePath); return(false); } try { var errorMessage = LoadModsFile(ModsFilePath); if (!string.IsNullOrWhiteSpace(errorMessage)) { PrintError(errorMessage); return(false); } } catch (Exception ex) { PrintError("Exception parsing the file for parameter -mod: " + ex.Message); return(false); } // Scans file validation if (!string.IsNullOrWhiteSpace(ScansFilePath) && !File.Exists(ScansFilePath)) { PrintError("Scans File file not found: " + ScansFilePath); return(false); } try { var errorMessage = LoadScansFile(ScansFilePath); if (!string.IsNullOrWhiteSpace(errorMessage)) { PrintError(errorMessage); return(false); } } catch (Exception ex) { PrintError("Exception parsing the file for parameter -scansFile: " + ex.Message); return(false); } // Feature file validation if (!string.IsNullOrWhiteSpace(FeatureFilePath) && !File.Exists(FeatureFilePath)) { PrintError("Feature File not found: " + FeatureFilePath); return(false); } if (!string.IsNullOrWhiteSpace(FeatureFilePath) && !Path.GetExtension(FeatureFilePath).ToLower().Equals(".csv") && !Path.GetExtension(FeatureFilePath).ToLower().Equals(".ms1ft") && !Path.GetExtension(FeatureFilePath).ToLower().Equals(".msalign")) { PrintError("Invalid extension for the Feature file path (" + Path.GetExtension(FeatureFilePath) + ")"); return(false); } // MinX/MaxX validation if (MinSequenceLength > MaxSequenceLength) { PrintError("MinPrecursorCharge (" + MinPrecursorIonCharge + ") is larger than MaxPrecursorCharge (" + MaxPrecursorIonCharge + ")!"); return(false); } if (MinProductIonCharge > MaxProductIonCharge) { PrintError("MinFragmentCharge (" + MinProductIonCharge + ") is larger than MaxFragmentCharge (" + MaxProductIonCharge + ")!"); return(false); } if (MinSequenceMass > MaxSequenceMass) { PrintError("MinSequenceMassInDa (" + MinSequenceMass + ") is larger than MaxSequenceMassInDa (" + MaxSequenceMass + ")!"); return(false); } MaxNumThreads = GetOptimalMaxThreads(MaxNumThreads); return(true); }