Beispiel #1
0
        public override void Execute()
        {
            StorageDescriptor pluginCache = new StorageDescriptor(Application.CacheDirectory, PluginCacheFileName, path.Name);

            if (pluginCache.Load())
            {
                foreach (StorageContainer node in pluginCache.Nodes.Values)
                {
                    if (!node.Validate())
                    {
                        pluginCache.Clear();
                        break;
                    }
                }
            }
            StorageContainer assemblyNode; if (!pluginCache.TryGetNode(PluginAssemblyStorageAlias, out assemblyNode))

            {
                List <FileSystemDescriptor> files = Application.GetPluginFiles(path);
                if (files.Count > 0)
                {
                    FileDescriptor assemblyFile = Compile(files);
                    assemblyNode = pluginCache.Store(assemblyFile, PluginAssemblyStorageAlias);

                    foreach (FileDescriptor mixin in files)
                    {
                        pluginCache.Store(mixin);
                    }
                    pluginCache.Save();
                }
                else
                {
                    Application.Warning(SeverityFlags.None, "Plugin '{0}' has no code files to compile", path.Name);
                }
                files = null;
            }
            if (assemblyNode != null && assemblyNode.Element.Exists())
            {
                Assembly assembly = Assembly.LoadFrom(assemblyNode.Element.GetAbsolutePath());
                Type     type     = assembly.GetType <IPlugin>();
                if (type != null)
                {
                    instance = type.CreateInstance <IPlugin>();

                    if (instance != null)
                    {
                        instance.Load();
                        return;
                    }
                }
                Application.Warning(SeverityFlags.None, "'{0}' is not a plugin", path.GetAbsolutePath());
            }
        }
Beispiel #2
0
        private static void LoadMixins()
        {
            StorageDescriptor mixinCache = new StorageDescriptor(Application.CacheDirectory, ModuleCacheFileName);

            if (mixinCache.Load())
            {
                foreach (StorageContainer node in mixinCache.Nodes.Values)
                {
                    if (!node.Validate())
                    {
                        mixinCache.Clear();
                        break;
                    }
                }
            }
            StorageContainer assemblyNode; if (!mixinCache.TryGetNode(MixinAssemblyStorageAlias, out assemblyNode))

            {
                Filter filter = new Filter();

                SetMixinFilter(filter);
                List <FileSystemDescriptor> mixins = Application.SdkDirectory.FindFiles(filter);
                if (mixins.Count > 0)
                {
                    FileDescriptor assemblyFile = Compile(mixins);
                    assemblyNode = mixinCache.Store(assemblyFile, MixinAssemblyStorageAlias);

                    foreach (FileDescriptor mixin in mixins)
                    {
                        mixinCache.Store(mixin);
                    }
                    mixinCache.Save();
                }
                filter = null;
                mixins = null;
            }
            MixinManager.RegisterMixins(Assembly.GetExecutingAssembly());
            if (assemblyNode != null && assemblyNode.Element.Exists())
            {
                MixinManager.RegisterMixins(Assembly.LoadFrom(assemblyNode.Element.GetAbsolutePath()));
            }
        }
Beispiel #3
0
        public override void Execute()
        {
            LoadInput();

            List <Project> projects = new List <Project>();

            foreach (TaskPin inputPin in inputPins)
            {
                projects.Add(inputPin.Data as Project);
            }

            Analyzer.GetModulePaths().ParallelFor((location) =>
            {
                foreach (TaskPin inputPin in inputPins)
                {
                    if ((inputPin.Data as FileDescriptor).Location.Contains(location))
                    {
                        return;
                    }
                }

                foreach (BuildTarget target in CompilerServices.Targets)
                {
                    Project module; if (!ProjectLookup.FromCache(target, SystemTags.Cpp, location, out module))
                    {
                        List <FileSystemDescriptor> files = Application.GetProjectFiles(location, ProjectLookup.Extensions);
                        if (files.Count > 0)
                        {
                            module = ProjectLookup.CreateProject(module, files);
                        }
                    }

                    module.AssemblyType = OutputAssemblyType.Static;
                    module.IsModule     = true;

                    lock (projects)
                        if (!projects.Contains(module))
                        {
                            Application.Log(SeverityFlags.Full, "Loaded {0} module {1}::{2}", ToolDisplayName, module.Name, module.Target.TechnicalName);
                            projects.Add(module);
                        }
                }
            });
            projects.ParallelFor((project) =>
            {
                StorageDescriptor cache = project.Cache;
                if (project.IsCached)
                {
                    cache.Nodes.Values.ParallelFor((element) =>
                    {
                        if (element.Tag == ReferenceStorageTag)
                        {
                            projects.Where(x => x.Target.Id == project.Target.Id).ParallelFor((reference) =>
                            {
                                if (reference == element.Element as FileDescriptor)
                                {
                                    Application.Log(SeverityFlags.Full, "Cached {0} module {1}::{2}", ToolDisplayName, reference.Name, reference.Target.TechnicalName);
                                    lock (project)
                                        project.References.Add(reference);
                                }
                            });
                        }
                        else if (element.Tag == ExternalStorageTag)
                        {
                            project.Externals.Add(element.Element as FileDescriptor);
                        }
                    });
                }
                else
                {
                    DependencyResolver.ConnectFiles(project, projects);

                    foreach (Project referene in project.References)
                    {
                        cache.Store <ReferenceContainer>(referene).Tag = ReferenceStorageTag;
                    }
                    foreach (FileDescriptor referene in project.Externals)
                    {
                        cache.Store <ReferenceContainer>(referene).Tag = ExternalStorageTag;
                    }

                    cache.Save();
                }
            });

            foreach (TaskPin inputPin in inputPins)
            {
                outputPins.Add(new FlaggedPin(this, inputPin.Data, SystemTags.Cpp));
            }

            for (int i = 0; i < inputPins.Count; i++)
            {
                foreach (Project reference in (outputPins[i].Data as Project).References)
                {
                    outputPins.Add(new FlaggedPin(this, reference, SystemTags.Cpp));
                }
            }

            if (printProjectStack)
            {
                PathDescriptor outputPath = Application.GetDeploymentPath(SystemTags.Analytics);
                if (!outputPath.Exists())
                {
                    try
                    {
                        outputPath.Create();
                    }
                    catch { }
                }

                ReferenceGraph moduleGraph = new ReferenceGraph();
                foreach (Project project in projects)
                {
                    project.Files.Nodes.ParallelFor((file) =>
                    {
                        file.Rect = Rectangle.Empty;
                        file.Slot = null;
                    });
                    project.Files.Save(outputPath, string.Format("{0}.cpp", project.Name));
                    AddProjectToGraph(moduleGraph, project);
                }
                moduleGraph.Save(outputPath, "CppModules");
            }
        }