Ejemplo n.º 1
0
        private void BuildGameImpl(IEnumerable <Type> typesToInclude, IEnumerable <string> additionalOptions)
        {
            _steps = GetFinalSteps(typesToInclude, additionalOptions);

            var registry = new OptionsRegistry();

            registry.Collect(_steps);

            var cmdOptions = registry.ProcessOptions(additionalOptions);
            var envOptions = registry.ProcessEnvironment();

            var optionsStr = string.Join("\n", cmdOptions.Concat(envOptions).Select(t => $"    '{t.Item1}' = '{t.Item2}'"));

            Debug.Log($"Running build with options:\n{optionsStr}");

            DumpBuildParameters();

            foreach (var a in _steps.OfType <IRunPreBuild>())
            {
                a.OnPreBuild(this);
            }

            foreach (var a in _steps.OfType <IRunPostBuild>().Reverse())
            {
                a.OnPostBuild(this);
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <object> ParseMultipleMethodTest(object[] valuesToTest)
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });
            r.ProcessOptions(new[] { $"-mlt_values_step={string.Join( ",", valuesToTest )}" });
            return(s.MultipleValues);
        }
Ejemplo n.º 3
0
        public void ParseFloatProp()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });
            r.ProcessOptions(new[] { "-flt=1.5" });

            Assert.That(s.FloatProp, Is.EqualTo(1.5f));
        }
Ejemplo n.º 4
0
        public void ParseIntMethod()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });
            r.ProcessOptions(new[] { "-intm=123" });

            Assert.That(s.IntProp, Is.EqualTo(123));
        }
Ejemplo n.º 5
0
        public void ParseStringMethod()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });
            r.ProcessOptions(new[] { "-strm=value" });

            Assert.That(s.StringProp, Is.EqualTo("value"));
        }
Ejemplo n.º 6
0
        public void ParseEnumMethod()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });
            r.ProcessOptions(new[] { "-enmm=webgl" });

            Assert.That(s.EnumProp, Is.EqualTo(BuildTarget.WebGL));
        }
Ejemplo n.º 7
0
        public void ParseBoolMethod()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });
            r.ProcessOptions(new[] { "-bolm=true" });

            Assert.That(s.BoolProp, Is.EqualTo(true));
        }
Ejemplo n.º 8
0
        public void CollectPrivateOpts()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag2();

            r.Collect(new[] { s });
            var names = r.AvailableOptions.Select(o => o.Name);

            Assert.That(names, Contains.Item("private_prop"));
            Assert.That(names, Contains.Item("private_mthd"));
        }
Ejemplo n.º 9
0
        public void ParseEnvVariableOptionValueCurlyBraces()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });
            Environment.SetEnvironmentVariable("STR_VALUE", "value");
            r.ProcessOptions(new[] { "-str=${STR_VALUE}" });

            Assert.That(s.StringProp, Is.EqualTo("value"));
        }
Ejemplo n.º 10
0
        public void CollectPublicOpts()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag2();

            r.Collect(new[] { s });
            var names = r.Select(o => o.Item1);

            Assert.That(names, Contains.Item("public_prop"));
            Assert.That(names, Contains.Item("public_mthd"));
        }
Ejemplo n.º 11
0
        public void ParseEnvVariableOption()
        {
            var r = new OptionsRegistry();
            var s = new OptionsBag();

            r.Collect(new[] { s });

            Environment.SetEnvironmentVariable("str", "value");
            r.ProcessEnvironment();

            Assert.That(s.StringProp, Is.EqualTo("value"));
        }
        private Exception ValidateCommandLine()
        {
            var tmpOptions = new OptionsRegistry();

            tmpOptions.Collect(_steps);

            try
            {
                tmpOptions.ProcessOptions(_selectedOptions.Select(o => $"-{o.Name}={o.Value}"));
                return(null);
            }
            catch (Exception e)
            {
                return(e);
            }
        }
        private void OnEnable()
        {
            titleContent = new GUIContent("CLI.Build Inspector");
            minSize      = new Vector2(700, 500);

            _steps = Builder.BuildStepsList();

            try
            {
                var options = new OptionsRegistry();
                options.Collect(_steps);

                _optionsList = options.AvailableOptions.OrderBy(option => option.Name).ToList();
            }
            catch (Exception e)
            {
                _collectException = e;
                Debug.LogException(e);
            }
        }
Ejemplo n.º 14
0
        private List <IBuildStep> GetFinalSteps(IEnumerable <Type> typesToInclude, IEnumerable <string> additionalOptions)
        {
            const string includeStepsName = "include_steps";
            const string excludeStepsName = "exclude_steps";

            string includeStepsValue = string.Empty;
            string excludeStepsValue = string.Empty;

            var optionsRegistry = new OptionsRegistry();

            optionsRegistry.Register <string>(includeStepsName, value => includeStepsValue = value);
            optionsRegistry.Register <string>(excludeStepsName, value => excludeStepsValue = value);

            optionsRegistry.ProcessOptions(additionalOptions);

            if (!string.IsNullOrEmpty(includeStepsValue) && !string.IsNullOrEmpty(excludeStepsValue))
            {
                throw new NotSupportedException($"Using {includeStepsName} and {excludeStepsName} commands at the same time is not supported.");
            }

            var steps = typesToInclude.Any() ? BuildStepsList(typesToInclude) : BuildStepsList();

            if (!string.IsNullOrEmpty(includeStepsValue))
            {
                var stepsToInclude = GetSteps(includeStepsValue).ToArray();
                CheckStepsForCorrectData(stepsToInclude, steps);
                return(steps.Where(step => stepsToInclude.Contains(step.GetType().Name)).ToList());
            }

            if (!string.IsNullOrEmpty(excludeStepsValue))
            {
                var stepsToExclude = GetSteps(excludeStepsValue).ToArray();
                CheckStepsForCorrectData(stepsToExclude, steps);
                return(steps.Where(step => !stepsToExclude.Contains(step.GetType().Name)).ToList());
            }

            return(steps);
        }