Example #1
0
        public MainViewModel()
        {
            DownloadDepotTools = new CommandHandler {
                Action = OnDownloadDepotTools
            };
            UpdateDepotTools = new CommandHandler {
                Action = OnUpdateDepotTools
            };
            BrowseSource = new CommandHandler {
                Action = OnBrowseSource
            };
            DownloadSource = new CommandHandler {
                Action = OnDownloadSource
            };
            UpdateSource = new CommandHandler {
                Action = OnUpdateSource
            };
            GetOptionsAvailable = new CommandHandler {
                Action = OnUpdateOptions
            };
            OpenReadMe = new CommandHandler {
                Action = OnOpenReadMe
            };
            ExploreConfiguration = new CommandHandler {
                Action = OnExploreConfiguration
            };
            ConfigureBuild = new CommandHandler {
                Action = OnConfigureBuild
            };
            BrowseBuildFolder = new CommandHandler {
                Action = OnBrowseBuild
            };
            MoveAvailable = new CommandHandler {
                Action = OnMoveAvailable
            };
            MoveSelected = new CommandHandler {
                Action = OnMoveSelected
            };
            BrowseWindowsKit = new CommandHandler {
                Action = OnBrowseWindowsKit
            };
            BuildV8 = new CommandHandler {
                Action = OnBuildV8
            };

            // The available options are those that are not selected
            foreach (var option in Config.BuildOptions)
            {
                if (option.Selected)
                {
                    SelectedOptions.Add(option);
                }
                else
                {
                    AvailableOptions.Add(option);
                }
            }
            InvokePropertyChanged(nameof(Config));
        }
Example #2
0
 public void AddOption(string option)
 //Añade una opción a las disponibles de la Stage
 {
     if (option != null)
     {
         AvailableOptions.Add(new Option(option));
     }
     else
     {
         string err_msg = "Error al cargar las opciones";
         throw new GameFlowError(err_msg);
     }
 }
        public void CheckAvailability()
        {
            AvailableOptions.Clear();

            foreach (IAccomodation accomodation in _accomodationList)
            {
                if (accomodation.HasSameLocationAs(_selectedLocation))
                {
                    if (accomodation.HasRoomsAvailableIn(_reservation.ReservationPeriod))
                    {
                        Option option = new Option(accomodation, accomodation.GetBestOptionFor(_reservation));
                        option.ComputeTotalPriceFor(_reservation.ReservationPeriod);
                        AvailableOptions.Add(option);
                    }
                }
            }
        }
Example #4
0
        private async void OnUpdateOptions()
        {
            try
            {
                EnableButtons(false);

                var workingFolder = Path.Combine(Config.SourceFolder, "v8");
                var configFolder  = (Application.Current as App).ConfigFolder;
                var genFolder     = Path.Combine(configFolder, "Downloads", "out.gn", "defaults");
                var argsFileName  = Path.Combine(configFolder, "Downloads", "gn_defaults.txt");

                if (!Directory.Exists(workingFolder))
                {
                    MessageBox.Show($"You must select an existing V8 source folder for the depot_tools to be able to produce a list "
                                    + "of available compiler options", $"V8 folder not found - '{workingFolder}'");
                    StatusText = "Updating build options failed";
                    return;
                }
                if (Directory.Exists(genFolder))
                {
                    try
                    {
                        FileSystem.DeleteDirectory(genFolder, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show($"Cannot delete '{genFolder}'; is that folder open in another program?"
                                        , $"Building V8 failed");
                        StatusText = $"failed to delete '{genFolder}'";
                        return;
                    }
                }

                var batch = new BatchFile
                {
                    WorkingDirectory = workingFolder,
                    Model            = this,
                    Title            = $"retrieving the list of available build options",
                };
                if (!CheckPython(batch.PythonFileName))
                {
                    return;
                }

                // batch.Commands.Add($"call python tools\\dev\\v8gen.py gen -b {Config.BuildConfiguration} \"{genFolder}\" --no-goma");
                var gnFileName = Path.Combine(Config.DepotToolsFolder, "gn.py");
                batch.Commands.Add($"\"{batch.PythonFileName}\" \"{gnFileName}\" gen \"{genFolder}\"");
                batch.Commands.Add($"\"{batch.PythonFileName}\" \"{gnFileName}\" args \"{genFolder}\" --list >{argsFileName}");
                StatusText = batch.Title;
                StatusText = await batch.Run();

                //var installer = CreateInstaller();
                //StatusText = "Extracting build options";
                //installer.WorkingDirectory = Path.Combine(Config.SourceFolder, "v8");

                //installer.Arguments = $"/k title Generating a list of build options & gn gen \"{genFolder}\" & gn args \"{genFolder}\" --list >{argsFileName}";
                //await Task.Run(() => Process.Start(installer).WaitForExit());

                var existingOptions = new Dictionary <string, BuildOption>(StringComparer.OrdinalIgnoreCase);
                foreach (var option in Config.BuildOptions)
                {
                    existingOptions[option.Name] = option;
                }
                AvailableOptions.Clear();
                SelectedOptions.Clear();

                StatusText = "Parsing build options";
                Config.BuildOptions.Clear();
                var               lines              = File.ReadAllLines(argsFileName);
                BuildOption       currentOption      = null;
                OptionParserState state              = OptionParserState.None;
                StringBuilder     descriptionBuilder = null;
                for (var ii = 0; ii < lines.Length; ++ii)
                {
                    var line = lines[ii];
                    switch (state)
                    {
                    case OptionParserState.None:
                    case OptionParserState.Name:
                        descriptionBuilder = new StringBuilder();
                        var name = line.Trim();
                        if (existingOptions.TryGetValue(name, out currentOption))
                        {
                            existingOptions.Remove(name);
                        }
                        else
                        {
                            currentOption = new Configuration.BuildOption
                            {
                                Name = line
                            };
                        }
                        if (currentOption.Selected)
                        {
                            SelectedOptions.Add(currentOption);
                        }
                        else
                        {
                            AvailableOptions.Add(currentOption);
                        }
                        Config.BuildOptions.Add(currentOption);
                        state = OptionParserState.Current;
                        break;

                    case OptionParserState.Current:
                        currentOption.Default = line.Split('=')[1].Trim();
                        state = OptionParserState.From;
                        break;

                    case OptionParserState.From:
                        state = OptionParserState.Blank;
                        break;

                    case OptionParserState.Blank:
                        state = OptionParserState.Description;
                        break;

                    case OptionParserState.Description:
                        if (!string.IsNullOrEmpty(line) && line[0] != ' ')
                        {
                            --ii;       // Reparse this line, it's the next name
                            currentOption.Description = descriptionBuilder.ToString().Trim();
                            state = OptionParserState.Name;
                        }
                        else
                        {
                            descriptionBuilder.Append(' ');
                            descriptionBuilder.Append(line.Trim());
                        }
                        break;
                    }
                }
                if (currentOption != null && descriptionBuilder != null && (descriptionBuilder.Length > 0))
                {
                    currentOption.Description = descriptionBuilder.ToString();
                }
                StatusText = "Ready";
            }
            finally
            {
                EnableButtons(true);
            }
        }