예제 #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);
            }
        }
예제 #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);
        }
예제 #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));
        }
예제 #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));
        }
예제 #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"));
        }
예제 #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));
        }
예제 #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));
        }
예제 #8
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"));
        }
        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);
            }
        }
예제 #10
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);
        }