Exemplo n.º 1
0
        internal bool Build(EditorCompilation editorCompilation)
        {
            if (editorCompilation.IsCompilationTaskCompiling())
            {
                return(false);
            }

            if (status != AssemblyBuilderStatus.NotStarted)
            {
                throw new Exception(string.Format("Cannot start AssemblyBuilder with status {0}. Expected {1}", status, AssemblyBuilderStatus.NotStarted));
            }

            var scriptAssembly = editorCompilation.CreateScriptAssembly(this);

            compilationTask = new CompilationTask(new ScriptAssembly[] { scriptAssembly }, scriptAssembly.OutputDirectory,
                                                  EditorScriptCompilationOptions.BuildingEmpty, CompilationTaskOptions.StopOnFirstError, 1);

            compilationTask.OnCompilationStarted += (assembly, phase) =>
            {
                editorCompilation.InvokeAssemblyCompilationStarted(assemblyPath);
                OnCompilationStarted(assembly, phase);
            };

            compilationTask.OnCompilationFinished += (assembly, messages) =>
            {
                editorCompilation.InvokeAssemblyCompilationFinished(assemblyPath, messages);
                OnCompilationFinished(assembly, messages);
            };

            compilationTask.Poll();

            editorCompilation.AddAssemblyBuilder(this);

            return(true);
        }
Exemplo n.º 2
0
        internal bool Build(EditorCompilation editorCompilation)
        {
            bool result;

            if (editorCompilation.IsCompilationTaskCompiling())
            {
                result = false;
            }
            else
            {
                if (this.status != AssemblyBuilderStatus.NotStarted)
                {
                    throw new Exception(string.Format("Cannot start AssemblyBuilder with status {0}. Expected {1}", this.status, AssemblyBuilderStatus.NotStarted));
                }
                ScriptAssembly scriptAssembly = editorCompilation.CreateScriptAssembly(this);
                this.compilationTask = new CompilationTask(new ScriptAssembly[]
                {
                    scriptAssembly
                }, scriptAssembly.OutputDirectory, EditorScriptCompilationOptions.BuildingEmpty, 1);
                this.compilationTask.OnCompilationStarted += delegate(ScriptAssembly assembly, int phase)
                {
                    editorCompilation.InvokeAssemblyCompilationStarted(this.assemblyPath);
                    this.OnCompilationStarted(assembly, phase);
                };
                this.compilationTask.OnCompilationFinished += delegate(ScriptAssembly assembly, List <UnityEditor.Scripting.Compilers.CompilerMessage> messages)
                {
                    editorCompilation.InvokeAssemblyCompilationFinished(this.assemblyPath, messages);
                    this.OnCompilationFinished(assembly, messages);
                };
                this.compilationTask.Poll();
                editorCompilation.AddAssemblyBuilder(this);
                result = true;
            }
            return(result);
        }
Exemplo n.º 3
0
        internal bool Build(EditorCompilation editorCompilation)
        {
            if (editorCompilation.IsCompilationTaskCompiling() ||
                editorCompilation.IsAnyAssemblyBuilderCompiling())
            {
                return(false);
            }

            if (status != AssemblyBuilderStatus.NotStarted)
            {
                throw new Exception(string.Format("Cannot start AssemblyBuilder with status {0}. Expected {1}", status, AssemblyBuilderStatus.NotStarted));
            }

            var assembly   = editorCompilation.CreateScriptAssembly(this);
            var assemblies = assembly.AllRecursiveScripAssemblyReferencesIncludingSelf().ToArray();

            // Start clean everytime
            const string beeAssemblyBuilderDirectory = "Library/BeeAssemblyBuilder";
            string       beeAssemblyBuilderDirectoryInProjectDirectory =
                string.IsNullOrEmpty(editorCompilation.projectDirectory)
                ? beeAssemblyBuilderDirectory
                : Path.Combine(editorCompilation.projectDirectory, beeAssemblyBuilderDirectory);

            if (Directory.Exists(beeAssemblyBuilderDirectoryInProjectDirectory))
            {
                Directory.Delete(beeAssemblyBuilderDirectoryInProjectDirectory, true);
            }

            var debug = compilerOptions.CodeOptimization == CodeOptimization.Debug;

            var buildRequest = UnityBeeDriver.BuildRequestFor(EditorCompilation.ScriptCompilationBuildProgram, editorCompilation, $"{(int)assembly.BuildTarget}{"AB"}", beeAssemblyBuilderDirectory);

            buildRequest.DataForBuildProgram.Add(() => BeeScriptCompilation.ScriptCompilationDataFor(editorCompilation, assemblies, debug, assembly.OutputDirectory, assembly.BuildTarget, true));
            buildRequest.Target = Constants.ScriptAssembliesTarget;

            activeBeeBuild = new BeeScriptCompilationState
            {
                assemblies        = new[] { assembly },
                ActiveBuild       = BeeDriver.BuildAsync(buildRequest),
                editorCompilation = editorCompilation,
            };

            editorCompilation.AddAssemblyBuilder(this);

            InvokeBuildStarted();
            return(true);
        }