private static void HandleGenerateSolution(Options options) { Project mainProject; if (!Project.TryLoadFromFile(options.MainProject, out mainProject)) { Console.Error.WriteLine("Could not load main project"); return; } var additionalProjects = new List <Project>(); foreach (var additionalProjectPath in options.AdditionalProjects ?? Enumerable.Empty <string>()) { Project additionalProject; if (!Project.TryLoadFromFile(additionalProjectPath, out additionalProject)) { Console.Error.WriteLine("Could not load additional project: {0}", additionalProject); return; } additionalProjects.Add(additionalProject); } var solution = SolutionGenerator.Generate(options.SolutionName, mainProject, options.GenerateEntryProject, options.BinariesDirectory, additionalProjects); if (options.OutputDirectory == null) { Console.WriteLine(solution); } else { var configuration = new Configuration(solution, options.RobotTests.Select(x => new RobotTestSuite(x))); configuration.Save(options.OutputDirectory); } }
private static void HandleGenerateSolution(string mainProjectPath, string binariesPath, IEnumerable <string> additionalProjectsPaths, string output, bool generateEntryProject) { Project mainProject; if (!Project.TryLoadFromFile(mainProjectPath, out mainProject)) { Console.Error.WriteLine("Could not load main project"); return; } var additionalProjects = new List <Project>(); foreach (var additionalProjectPath in additionalProjectsPaths ?? Enumerable.Empty <string>()) { Project additionalProject; if (!Project.TryLoadFromFile(additionalProjectPath, out additionalProject)) { Console.Error.WriteLine("Could not load additional project: {0}", additionalProject); return; } additionalProjects.Add(additionalProject); } var solution = SolutionGenerator.Generate(mainProject, generateEntryProject, binariesPath, additionalProjects); if (output == null) { Console.WriteLine(solution); } else { solution.Save(output); solution.SaveTestsFile(Path.Combine(output, testsFileName)); } }
private static Configuration HandleCustomSolution(Options options) { var stepManager = new StepManager(); var pathHelper = new PathHelper(options.Directories.Select(Path.GetFullPath)); var uiSelectionStep = new UiStep(pathHelper); var robotTestsStep = new RobotTestsStep("Choose robot tests:", pathHelper); stepManager .AddStep(uiSelectionStep) .AddStep(new ProjectsListStep <CpuCoreProject>("Choose supported architectures:", pathHelper)) .AddStep(new ProjectsListStep <ExtensionProject>("Choose extensions libraries:", pathHelper)) .AddStep(new PluginStep("Choose plugins:", pathHelper)) .AddStep(new ProjectsListStep <TestsProject>("Choose tests:", pathHelper)) .AddStep(robotTestsStep) .AddStep(new ProjectsListStep <UnknownProject>("Choose other projects:", pathHelper)) .Run(); if (stepManager.IsCancelled) { return(null); } return(new Configuration( SolutionGenerator.Generate(options.SolutionName, uiSelectionStep.UIProject, options.GenerateEntryProject, options.OutputDirectory, stepManager.GetSteps <ProjectsListStep>().SelectMany(x => x.AdditionalProjects).Union(uiSelectionStep.UIProject.GetAllReferences())), robotTestsStep.SelectedTests)); }
private static Solution GenerateAllProjects(string binariesPath, bool generateEntryProject, IEnumerable <string> paths) { var fullPaths = paths.Select(Path.GetFullPath).ToArray(); Scanner.Instance.ScanDirectories(fullPaths); var mainProject = Scanner.Instance.Projects.OfType <UiProject>().FirstOrDefault(); if (mainProject == null) { Console.Error.WriteLine("No UI project found. Exiting"); Environment.Exit(ErrorResultCode); } return(SolutionGenerator.GenerateWithAllReferences(mainProject, generateEntryProject, binariesPath, Scanner.Instance.Projects.Where(x => !(x is UnknownProject)))); }
private static Solution HandleCustomSolution(string outputPath, bool generateEntryProject, IEnumerable <string> directories) { var stepManager = new StepManager(); var pathHelper = new PathHelper(directories.Select(Path.GetFullPath)); stepManager.AddStep(new UiStep(pathHelper)); stepManager.AddStep(new ProjectsListStep <CpuCoreProject>("Choose supported architectures:", pathHelper)); stepManager.AddStep(new ProjectsListStep <ExtensionProject>("Choose extensions libraries:", pathHelper)); stepManager.AddStep(new PluginStep("Choose plugins:", pathHelper)); stepManager.AddStep(new ProjectsListStep <TestsProject>("Choose tests:", pathHelper)); stepManager.AddStep(new ProjectsListStep <UnknownProject>("Choose other projects:", pathHelper)); stepManager.Run(); return(stepManager.IsCancelled ? null : SolutionGenerator.Generate(stepManager.GetStep <UiStep>().UIProject, generateEntryProject, outputPath, stepManager.GetSteps <ProjectsListStep>().SelectMany(x => x.AdditionalProjects).Union(stepManager.GetStep <UiStep>().UIProject.GetAllReferences()))); }
public static Solution GenerateWithAllReferences(UiProject mainProject, bool generateEntryProject, string binariesPath, IEnumerable <Project> extraProjects = null) { if (extraProjects == null) { extraProjects = new Project[0]; } var extensionProjects = Scanner.Instance.Projects.OfType <ExtensionProject>(); var pluginProjects = Scanner.Instance.Projects.OfType <PluginProject>().Where(x => !x.PluginModes.Any() || x.PluginModes.Contains(mainProject.UiType)); var projects = extensionProjects .Union(extraProjects) .Union(extraProjects.SelectMany(x => x.GetAllReferences())) .Union(extensionProjects.SelectMany(x => x.GetAllReferences())) .Union(pluginProjects) .Union(pluginProjects.SelectMany(x => x.GetAllReferences())).ToList(); return(SolutionGenerator.Generate(mainProject, generateEntryProject, binariesPath, projects)); }
private static Configuration GenerateAllProjects(Options options) { Scanner.Instance.ScanDirectories(options.Directories.Select(Path.GetFullPath), options.Exclude); var mainProject = (options.MainProject != null) ? Scanner.Instance.Elements.OfType <UiProject>().Where(x => x.Path == options.MainProject).SingleOrDefault() : Scanner.Instance.Elements.OfType <UiProject>().OrderByDescending(x => x.Name == "CLI").FirstOrDefault(); if (mainProject == null) { Console.Error.WriteLine("No UI project found. Exiting"); Environment.Exit(ErrorResultCode); } return(new Configuration( SolutionGenerator.GenerateWithAllReferences(options.SolutionName, mainProject, options.GenerateEntryProject, options.BinariesDirectory, Scanner.Instance.Elements.OfType <Project>().Where(x => !(x is UnknownProject))), Scanner.Instance.Elements.OfType <RobotTestSuite>())); }
private static int HandleInteractive(List <string> directories, string binariesDirectory, string outputDirectory, bool generateEntryProject) { // check if "dialog" application is available if (!TryFind("dialog")) { Console.Error.WriteLine("The 'dialog' application is necessary to run in interactive mode"); return(ErrorResultCode); } if (directories == null || directories.All(x => string.IsNullOrEmpty(x))) { var directoryDialog = new InputboxDialog(Title, "Provide directories to scan (colon-separated):", "."); if (directoryDialog.Show() != DialogResult.Ok) { return(CancelResultCode); } directories = directoryDialog.Value.Split(new [] { ':' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } if (!directories.Any()) { new MessageDialog("Error", "No directories to scan provided! Exiting.").Show(); return(ErrorResultCode); } Solution solution = null; var infobox = new Infobox("Scanning directories..."); infobox.Show(); Scanner.Instance.ScanDirectories(directories); var actions = new List <Tuple <string, string> > { Tuple.Create("All", "Generate solution file with all projects"), Tuple.Create("Custom", "Generate custom solution file"), Tuple.Create("Clean", "Remove generated configuration") }; foreach (var uiType in Scanner.Instance.Projects.OfType <UiProject>().Select(x => x.UiType).Distinct().OrderByDescending(x => x)) { actions.Insert(1, Tuple.Create(uiType, string.Format("Generate solution file for {0} with references", uiType))); } var actionDialog = new MenuDialog(Title, "Welcome to the Emul8 bootstrap configuration.\nUse this script to generate your own Emul8.sln file.\n\nChoose action:", actions); if (actionDialog.Show() != DialogResult.Ok) { return(CancelResultCode); } try { var key = actionDialog.SelectedKeys.First(); switch (key) { case "All": solution = GenerateAllProjects(binariesDirectory, generateEntryProject, directories); break; case "Custom": solution = HandleCustomSolution(binariesDirectory, generateEntryProject, directories); break; case "Clean": Cleaner.Clean(outputDirectory); new MessageDialog(Title, "Solution cleaned.").Show(); return(CleanedResultCode); default: var mainProject = Scanner.Instance.Projects.OfType <UiProject>().SingleOrDefault(x => x.UiType == key); if (mainProject == null) { new MessageDialog("Bootstrap failure", string.Format("Could not load {0} project. Exiting", key)).Show(); return(ErrorResultCode); } solution = SolutionGenerator.GenerateWithAllReferences(mainProject, generateEntryProject, binariesDirectory); break; } } catch (DirectoryNotFoundException e) { new MessageDialog("Error", e.Message).Show(); return(ErrorResultCode); } if (solution == null) { new MessageDialog("Bootstrap failure", "Couldn't generate the solution file: no project file found in the directories provided. Exiting").Show(); return(ErrorResultCode); } var confirmDialog = new YesNoDialog(Title, "Are you sure you want to create the solution file?"); if (confirmDialog.Show() != DialogResult.Ok) { return(CancelResultCode); } solution.Save(outputDirectory); solution.SaveTestsFile(Path.Combine(outputDirectory, testsFileName)); new MessageDialog(Title, "Solution file created successfully!").Show(); return(0); }