AvalonStudio.Toolchains.Standard.StandardToolChain.Build C# (CSharp) 메소드

Build() 공개 메소드

public Build ( IConsole console, IProject project, string label = "", IEnumerable defines = null ) : Task
console IConsole
project IProject
label string
defines IEnumerable
리턴 Task
        public async Task<bool> Build(IConsole console, IProject project, string label = "", IEnumerable<string> defines = null)
		{
            if(!ValidateToolchainExecutables(console))
            {
                return false;
            }

			console.Clear();

            var result = await PreBuild(console, project);

            console.WriteLine("Starting Build...");
            
			terminateBuild = !result;

			SetFileCount(project as IStandardProject);
			buildCount = 0;

			var compiledProjects = new List<CompileResult>();

            List<Definition> injectedDefines = new List<Definition>();

            if (defines != null)
            {
                foreach (var define in defines)
                {
                    var injectableDefinition = new Definition() { Global = true, Value = define };
                    (project as IStandardProject).Defines.Add(injectableDefinition);
                    injectedDefines.Add(injectableDefinition);
                }
            }       

			if (!terminateBuild)
			{
				await CompileProject(console, project as IStandardProject, project as IStandardProject, compiledProjects);

				if (!terminateBuild)
				{
					await WaitForCompileJobs();

					foreach (var compiledReference in compiledProjects)
					{
						result = compiledReference.ExitCode == 0;

						if (!result)
						{
							break;
						}
					}

					if (result)
					{
						var linkedReferences = new CompileResult();
						linkedReferences.Project = project as IStandardProject;

						foreach (var compiledProject in compiledProjects)
						{
							if (compiledProject.Project.Location != project.Location)
							{
								var linkResult = Link(console, project as IStandardProject, compiledProject, linkedReferences);
                            }
							else
							{
								// if (linkedReferences.Count > 0)
								{
									linkedReferences.ObjectLocations = compiledProject.ObjectLocations;
									linkedReferences.NumberOfObjectsCompiled = compiledProject.NumberOfObjectsCompiled;
									var linkResult = Link(console, project as IStandardProject, linkedReferences, linkedReferences, label);
                                    result = await PostBuild(console, project, linkResult);
								}
							}

							if (linkedReferences.ExitCode != 0)
							{
								result = false;
								break;
							}
						}
					}

					ClearBuildFlags(project as IStandardProject);
				}
			}

			console.WriteLine();

			if (terminateBuild)
			{
				result = false;
			}

			if (result)
			{
				console.WriteLine("Build Successful");
			}
			else
			{
				console.WriteLine("Build Failed");
			}

            foreach(var define in injectedDefines)
            {
                (project as IStandardProject).Defines.Remove(define);
            }

            project.Save();

			return result;
		}