private void BuildMainExecutable(TaskGraph graph, BuildOptions buildOptions) { if (IsPreBuilt) { return; } var outputPath = Path.Combine(buildOptions.OutputFolder, buildOptions.Platform.GetLinkOutputFileName(OutputName, LinkerOutput.Executable)); var exeBuildOptions = Builder.GetBuildOptions(this, buildOptions.Platform, buildOptions.Toolchain, buildOptions.Architecture, buildOptions.Configuration, buildOptions.WorkingDirectory); exeBuildOptions.LinkEnv.Output = LinkerOutput.Executable; var rules = Builder.GenerateRulesAssembly(); var buildData = new Builder.BuildData { Rules = rules, Target = this, Graph = graph, TargetOptions = exeBuildOptions, Platform = buildOptions.Platform, Toolchain = buildOptions.Toolchain, Architecture = buildOptions.Architecture, Configuration = buildOptions.Configuration, }; // Build Main module var mainModule = rules.GetModule("Main"); var mainModuleOutputPath = Path.Combine(exeBuildOptions.IntermediateFolder, mainModule.Name); if (!Directory.Exists(mainModuleOutputPath)) { Directory.CreateDirectory(mainModuleOutputPath); } var mainModuleOptions = new BuildOptions { Target = this, Platform = buildOptions.Platform, Toolchain = buildOptions.Toolchain, Architecture = buildOptions.Architecture, Configuration = buildOptions.Configuration, CompileEnv = (CompileEnvironment)exeBuildOptions.CompileEnv.Clone(), LinkEnv = (LinkEnvironment)exeBuildOptions.LinkEnv.Clone(), IntermediateFolder = mainModuleOutputPath, OutputFolder = mainModuleOutputPath, WorkingDirectory = exeBuildOptions.WorkingDirectory, HotReloadPostfix = exeBuildOptions.HotReloadPostfix, }; mainModuleOptions.SourcePaths.Add(mainModule.FolderPath); mainModule.Setup(mainModuleOptions); mainModuleOptions.MergeSourcePathsIntoSourceFiles(); mainModuleOptions.CompileEnv.PreprocessorDefinitions.Add("FLAXENGINE_API=" + buildOptions.Toolchain.DllImport); Builder.BuildModuleInner(buildData, mainModule, mainModuleOptions, false); // Link executable exeBuildOptions.LinkEnv.InputLibraries.Add(Path.Combine(buildOptions.OutputFolder, buildOptions.Platform.GetLinkOutputFileName(OutputName, LinkerOutput.SharedLibrary))); foreach (var e in mainModuleOptions.OutputFiles) { exeBuildOptions.LinkEnv.InputFiles.Add(e); } foreach (var e in mainModuleOptions.DependencyFiles) { exeBuildOptions.DependencyFiles.Add(e); } foreach (var e in mainModuleOptions.OptionalDependencyFiles) { exeBuildOptions.OptionalDependencyFiles.Add(e); } exeBuildOptions.Libraries.AddRange(mainModuleOptions.Libraries); exeBuildOptions.DelayLoadLibraries.AddRange(mainModuleOptions.DelayLoadLibraries); exeBuildOptions.ScriptingAPI.Add(mainModuleOptions.ScriptingAPI); buildOptions.Toolchain.LinkFiles(graph, exeBuildOptions, outputPath); }