Ejemplo n.º 1
0
        public static void RunTaskGuarded(BindTask task)
        {
            Stopwatch sw = null;

            if (!(Program.ConsoleWriter.Instance is null))
            {
                Program.ConsoleWriter.Instance.CurrentName.Value = task.Name;
                sw = Stopwatch.StartNew();
            }

            try
            {
                RunTask(task, sw);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine($"Unhandled exception: {ex}");
                if (sw is not null)
                {
                    Program.ConsoleWriter.Instance.Timings.Value =
                        new KeyValuePair <string, (TimeSpan, bool)>(task.Name, (sw.Elapsed, false));
                    return;
                }
            }

            if (sw is not null)
            {
                Program.ConsoleWriter.Instance.Timings.Value =
                    new KeyValuePair <string, (TimeSpan, bool)>(task.Name, (sw.Elapsed, true));
            }
        }
Ejemplo n.º 2
0
        private static void RunTask(BindTask task, Stopwatch?sw)
        {
            foreach (var typeMap in task.TypeMaps)
            {
                var toAdd = new List <KeyValuePair <string, string> >();
                foreach (var kvp in typeMap)
                {
                    if (kvp.Key.StartsWith("$include"))
                    {
                        toAdd.Add(kvp);
                    }
                }

                foreach (var kvp in toAdd)
                {
                    var includedMap = JsonConvert.DeserializeObject <Dictionary <string, string> >
                                          (File.ReadAllText(kvp.Value));
                    typeMap.Remove(kvp.Key);
                    foreach (var includedKvp in includedMap)
                    {
                        typeMap.Add(includedKvp.Key, includedKvp.Value);
                    }
                }
            }

            Profile profile;

            if (ShouldConvert(task.Controls))
            {
                Console.WriteLine("Profile conversion started!");
                var tsb4     = sw?.Elapsed.TotalSeconds;
                var profiles = new List <Profile>();
                if (task.Mode == ConverterMode.ConvertConstruct)
                {
                    foreach (var src in task.Sources)
                    {
                        var rawProfiles = ProfileConverter.ReadProfiles
                                          (
                            task.ConverterOpts.Reader.ToLower() switch
                        {
                            "gl" => new OpenGLReader(),
                            "cl" => new OpenCLReader(),
                            "vk" => new VulkanReader(),
                            _ => throw new ArgumentException("Couldn't find a reader with that name")
                        }, task.ConverterOpts.Constructor.ToLower() switch
Ejemplo n.º 3
0
        public static void RunTaskUnguarded(BindTask task)
        {
            Stopwatch sw = null;

            if (!(Program.ConsoleWriter.Instance is null))
            {
                Program.ConsoleWriter.Instance.CurrentName.Value = task.Name;
                sw = Stopwatch.StartNew();
            }

            RunTask(task, sw);

            if (sw is not null)
            {
                Program.ConsoleWriter.Instance.Timings.Value =
                    new KeyValuePair <string, (TimeSpan, bool)>(task.Name, (sw.Elapsed, true));
            }
        }
Ejemplo n.º 4
0
 public static void RunTask(BindTask task) => RunTask(task, null);