internal static void CleanupBuildCallbacks()
 {
     buildTargetProcessors = null;
     buildPreprocessors    = null;
     buildPostprocessors   = null;
     sceneProcessors       = null;
     previousFlags         = BuildCallbacks.None;
 }
 internal static void CleanupBuildCallbacks()
 {
     processors.buildTargetProcessors          = null;
     processors.buildPreprocessors             = null;
     processors.buildPostprocessors            = null;
     processors.sceneProcessors                = null;
     processors.buildPreprocessorsWithReport   = null;
     processors.buildPostprocessorsWithReport  = null;
     processors.sceneProcessorsWithReport      = null;
     processors.filterBuildAssembliesProcessor = null;
     processors.shaderProcessors               = null;
     previousFlags = BuildCallbacks.None;
 }
示例#3
0
        public void DefaultBuildTasks_PostScriptsCallbacks()
        {
            bool scriptsCallbackCalled = false;

            IBuildParameters buildParameters = GetBuildParameters();
            IBuildResults    results         = new BuildResults();
            BuildCallbacks   callback        = new BuildCallbacks();

            callback.PostScriptsCallbacks = (parameters, buildResults) =>
            {
                scriptsCallbackCalled = true;
                return(ReturnCode.Success);
            };

            ReturnCode exitCode = RunTask <PostScriptsCallback>(buildParameters, results, callback);

            Assert.AreEqual(ReturnCode.Success, exitCode);
            Assert.IsTrue(scriptsCallbackCalled);
        }
示例#4
0
        public void DefaultBuildTasks_PostDependencyCallback()
        {
            bool dependencyCallbackCalled = false;

            IBuildParameters buildParameters = GetBuildParameters();
            IDependencyData  dep             = GetDependencyData();
            BuildCallbacks   callback        = new BuildCallbacks();

            callback.PostDependencyCallback = (parameters, data) =>
            {
                dependencyCallbackCalled = true;
                return(ReturnCode.Success);
            };

            ReturnCode exitCode = RunTask <PostDependencyCallback>(buildParameters, dep, callback);

            Assert.AreEqual(ReturnCode.Success, exitCode);
            Assert.IsTrue(dependencyCallbackCalled);
        }
示例#5
0
        public void DefaultBuildTasks_PostPackingCallback()
        {
            bool packingCallbackCalled = false;

            IBuildParameters buildParams = GetBuildParameters();
            IDependencyData  dep         = GetDependencyData();
            IBundleWriteData writeData   = new BundleWriteData();
            BuildCallbacks   callback    = new BuildCallbacks();

            callback.PostPackingCallback = (parameters, data, arg3) =>
            {
                packingCallbackCalled = true;
                return(ReturnCode.Success);
            };

            ReturnCode exitCode = RunTask <PostPackingCallback>(buildParams, dep, writeData, callback);

            Assert.AreEqual(ReturnCode.Success, exitCode);
            Assert.IsTrue(packingCallbackCalled);
        }
        internal static void InitializeBuildCallbacks(BuildCallbacks findFlags)
        {
            if (findFlags == previousFlags)
            {
                return;
            }

            CleanupBuildCallbacks();
            previousFlags = findFlags;

            bool findBuildProcessors  = (findFlags & BuildCallbacks.BuildProcessors) == BuildCallbacks.BuildProcessors;
            bool findSceneProcessors  = (findFlags & BuildCallbacks.SceneProcessors) == BuildCallbacks.SceneProcessors;
            bool findTargetProcessors = (findFlags & BuildCallbacks.BuildTargetProcessors) == BuildCallbacks.BuildTargetProcessors;
            bool findFilterProcessors = (findFlags & BuildCallbacks.FilterAssembliesProcessors) == BuildCallbacks.FilterAssembliesProcessors;
            bool findShaderProcessors = (findFlags & BuildCallbacks.ShaderProcessors) == BuildCallbacks.ShaderProcessors;

            var postProcessBuildAttributeParams = new Type[] { typeof(BuildTarget), typeof(string) };

            foreach (var t in EditorAssemblies.GetAllTypesWithInterface <IOrderedCallback>())
            {
                if (t.IsAbstract || t.IsInterface)
                {
                    continue;
                }

                // Defer creating the instance until we actually add it to one of the lists
                object instance = null;

                if (findBuildProcessors)
                {
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.buildPreprocessors);
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.buildPreprocessorsWithReport);
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.buildPostprocessors);
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.buildPostprocessorsWithReport);
                }

                if (findSceneProcessors)
                {
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.sceneProcessors);
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.sceneProcessorsWithReport);
                }

                if (findTargetProcessors)
                {
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.buildTargetProcessors);
                }

                if (findFilterProcessors)
                {
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.filterBuildAssembliesProcessor);
                }

                if (findShaderProcessors)
                {
                    AddToListIfTypeImplementsInterface(t, ref instance, ref processors.shaderProcessors);
                }
            }

            if (findBuildProcessors)
            {
                foreach (var m in EditorAssemblies.GetAllMethodsWithAttribute <Callbacks.PostProcessBuildAttribute>())
                {
                    if (ValidateMethod <Callbacks.PostProcessBuildAttribute>(m, postProcessBuildAttributeParams))
                    {
                        AddToList(new AttributeCallbackWrapper(m), ref processors.buildPostprocessorsWithReport);
                    }
                }
            }

            if (findSceneProcessors)
            {
                foreach (var m in EditorAssemblies.GetAllMethodsWithAttribute <Callbacks.PostProcessSceneAttribute>())
                {
                    if (ValidateMethod <Callbacks.PostProcessSceneAttribute>(m, Type.EmptyTypes))
                    {
                        AddToList(new AttributeCallbackWrapper(m), ref processors.sceneProcessorsWithReport);
                    }
                }
            }

            if (processors.buildPreprocessors != null)
            {
                processors.buildPreprocessors.Sort(CompareICallbackOrder);
            }
            if (processors.buildPreprocessorsWithReport != null)
            {
                processors.buildPreprocessorsWithReport.Sort(CompareICallbackOrder);
            }
            if (processors.buildPostprocessors != null)
            {
                processors.buildPostprocessors.Sort(CompareICallbackOrder);
            }
            if (processors.buildPostprocessorsWithReport != null)
            {
                processors.buildPostprocessorsWithReport.Sort(CompareICallbackOrder);
            }
            if (processors.buildTargetProcessors != null)
            {
                processors.buildTargetProcessors.Sort(CompareICallbackOrder);
            }
            if (processors.sceneProcessors != null)
            {
                processors.sceneProcessors.Sort(CompareICallbackOrder);
            }
            if (processors.sceneProcessorsWithReport != null)
            {
                processors.sceneProcessorsWithReport.Sort(CompareICallbackOrder);
            }
            if (processors.filterBuildAssembliesProcessor != null)
            {
                processors.filterBuildAssembliesProcessor.Sort(CompareICallbackOrder);
            }
            if (processors.shaderProcessors != null)
            {
                processors.shaderProcessors.Sort(CompareICallbackOrder);
            }
        }
        internal static void InitializeBuildCallbacks(BuildCallbacks findFlags)
        {
            if (findFlags == previousFlags)
            {
                return;
            }

            CleanupBuildCallbacks();
            previousFlags = findFlags;

            bool findBuildProcessors             = (findFlags & BuildCallbacks.BuildProcessors) == BuildCallbacks.BuildProcessors;
            bool findSceneProcessors             = (findFlags & BuildCallbacks.SceneProcessors) == BuildCallbacks.SceneProcessors;
            bool findTargetProcessors            = (findFlags & BuildCallbacks.BuildTargetProcessors) == BuildCallbacks.BuildTargetProcessors;
            var  postProcessBuildAttributeParams = new Type[] { typeof(BuildTarget), typeof(string) };

            foreach (var t in EditorAssemblies.GetAllTypesWithInterface <IOrderedCallback>())
            {
                if (t.IsAbstract || t.IsInterface)
                {
                    continue;
                }
                object instance = null;
                if (findBuildProcessors)
                {
                    if (ValidateType <IPreprocessBuild>(t))
                    {
                        AddToList(instance = Activator.CreateInstance(t), ref buildPreprocessors);
                    }

                    if (ValidateType <IPostprocessBuild>(t))
                    {
                        AddToList(instance = instance == null ? Activator.CreateInstance(t) : instance, ref buildPostprocessors);
                    }
                }

                if (findSceneProcessors && ValidateType <IProcessScene>(t))
                {
                    AddToList(instance = instance == null ? Activator.CreateInstance(t) : instance, ref sceneProcessors);
                }

                if (findTargetProcessors && ValidateType <IActiveBuildTargetChanged>(t))
                {
                    AddToList(instance = instance == null ? Activator.CreateInstance(t) : instance, ref buildTargetProcessors);
                }
            }

            if (findBuildProcessors)
            {
                foreach (var m in EditorAssemblies.GetAllMethodsWithAttribute <Callbacks.PostProcessBuildAttribute>())
                {
                    if (ValidateMethod <Callbacks.PostProcessBuildAttribute>(m, postProcessBuildAttributeParams))
                    {
                        AddToList(new AttributeCallbackWrapper(m), ref buildPostprocessors);
                    }
                }
            }

            if (findSceneProcessors)
            {
                foreach (var m in EditorAssemblies.GetAllMethodsWithAttribute <Callbacks.PostProcessSceneAttribute>())
                {
                    if (ValidateMethod <Callbacks.PostProcessSceneAttribute>(m, Type.EmptyTypes))
                    {
                        AddToList(new AttributeCallbackWrapper(m), ref sceneProcessors);
                    }
                }
            }

            if (buildPreprocessors != null)
            {
                buildPreprocessors.Sort(CompareICallbackOrder);
            }
            if (buildPostprocessors != null)
            {
                buildPostprocessors.Sort(CompareICallbackOrder);
            }
            if (buildTargetProcessors != null)
            {
                buildTargetProcessors.Sort(CompareICallbackOrder);
            }
            if (sceneProcessors != null)
            {
                sceneProcessors.Sort(CompareICallbackOrder);
            }
        }