public void AddPackage(RosPackageInfo packageInfo, bool isOptional = false) { if (packageInfo == null) { throw new ArgumentNullException(nameof(packageInfo)); } if (!_availablePackages.Contains(packageInfo)) { if (_availablePackages.Any(p => string.Equals(p.Name, packageInfo.Name))) { throw new InvalidOperationException("Package with the same name already exists."); } _availablePackages.Add(packageInfo); } if (isOptional) { // Set mandatory if any other mandatory package // depends on this package var existingDependency = _mandatoryPackages .SelectMany(p => p.Parser.PackageDependencies) .Any(p => string.Equals(p, packageInfo.Name)); isOptional = !existingDependency; } if (!isOptional) { SetMandatoryInternal(packageInfo); } }
private void SetMandatoryInternal(RosPackageInfo packageInfo) { if (_mandatoryPackages.Any(x => x.PackageInfo == packageInfo)) { return; } var messageParser = RosMessageParserFactory.Create(packageInfo, this); var context = new CodeGenerationPackageContext(packageInfo, messageParser); _mandatoryPackages.Add(context); // Add dependencies to build pipeline foreach (var dependentUponPackageName in context.Parser.PackageDependencies) { var dependentUponPackage = _availablePackages.FirstOrDefault(p => string.Equals(p.Name, dependentUponPackageName)); if (dependentUponPackage != null) { SetMandatoryInternal(dependentUponPackage); } } }
public ProjectCodeGenerationDirectoryContext GetPackageTempDir(RosPackageInfo packageInfo) { if (_disposed) { throw new ObjectDisposedException("The object is already disposed"); } var tempPath = Path.Combine(BaseTempPath, packageInfo.Name, packageInfo.Version); if (_projectTempDirectories.TryGetValue(tempPath, out var context)) { return(context); } var tempDirectory = new DirectoryInfo(tempPath); if (tempDirectory.Exists) { tempDirectory.Delete(true); } tempDirectory.Create(); context = new ProjectCodeGenerationDirectoryContext(OutputDirectory, tempDirectory, NugetTempDirectory); _projectTempDirectories.Add(tempPath, context); return(context); }
public static IRosMessagePackageParser Create(RosPackageInfo rosPackageInfo, CodeGenerationContext context) { if (rosPackageInfo.IsMetaPackage) { return(new RosMetaPackageParser(rosPackageInfo, context)); } else { return(new RosMessagePackageParser(rosPackageInfo, context)); } }
public bool TryGetPackageInfo(out RosPackageInfo packageInfo) { try { packageInfo = PackageInfo; return(true); } catch { packageInfo = null; return(false); } }
public void SetMandatory(RosPackageInfo packageInfo) { if (packageInfo == null) { throw new ArgumentNullException(nameof(packageInfo)); } if (!_availablePackages.Contains(packageInfo)) { throw new InvalidOperationException("Package is not in the list of available packages. Call AddPackage before."); } SetMandatoryInternal(packageInfo); }
private static IEnumerable <RosPackageFolder> FindInternal(string basePath, BuildType type) { var packageFolders = new List <RosPackageFolder>(); if (RosPackageInfo.IsPackageFolder(basePath)) { packageFolders.Add(new RosPackageFolder(basePath, type)); } else { foreach (var directory in Directory.GetDirectories(basePath)) { packageFolders.AddRange(FindInternal(directory, type)); } } return(packageFolders); }
public RosPackageFolder(string path, BuildType type) { if (path == null) { throw new ArgumentNullException(nameof(path)); } path = System.IO.Path.GetFullPath(path); if (!Directory.Exists(path)) { throw new DirectoryNotFoundException($"Directory {path} does not exit."); } if (!RosPackageInfo.IsPackageFolder(path)) { throw new InvalidOperationException($"Directory {path} is not a ROS package folder (package.xml file is missing)."); } Path = path; BuildStrategy = type; }
public CodeGenerationPackageContext(RosPackageInfo packageInfo, IRosMessagePackageParser parser) { PackageInfo = packageInfo ?? throw new ArgumentNullException(nameof(packageInfo)); Parser = parser ?? throw new ArgumentNullException(nameof(parser)); }