void AddCustomTargets(List <ModuleDef> Modules, List <BuildConfig> buildConfigs) { List <PlatformDefinition> Platforms = PlatformDefinition.GetDefaultPlatforms(); outputdata += "group \" Build/\"\n"; outputdata += "project \"HeaderTool\"\n"; outputdata += "kind (\"Makefile\")\n"; string headertoolString = StringUtils.SanitizePath(ModuleDefManager.GetSourcePath() + "\\EngineHeaderTool.exe "); headertoolString += " -Name " + ModuleDefManager.CoreModule.GameModuleName; Console.WriteLine("Game Module is " + ModuleDefManager.CoreModule.GameModuleName); outputdata += "buildcommands {\" " + headertoolString + " \"}\n"; foreach (PlatformDefinition PD in Platforms) { if (PD == null) { continue; } foreach (BuildConfig Bc in buildConfigs) { if (Bc.CurrentPackageType == BuildConfiguration.PackageType.Package) { PushFilter(PD.TypeId, "\"configurations:" + Bc.Name + "\""); outputdata += " buildcommands{\"$(MSBuildProjectDirectory)/../Binaries/Win64/Release/StandaloneShaderComplier.exe " + PD.Name + "\"}\n"; } } } PopFilter(); // outputdata += "buildoutputs { '" + StringUtils.SanitizePath(ModuleDefManager.GetIntermediate Dir() + "\\Generated\\Core\\Core\\Components\\LightComponent.generated.h") + "' }\n"; }
public void Run() { LogStage("Generate Stage"); CurrentConfigs = BuildConfiguration.GetDefaultConfigs(); Directory.CreateDirectory(GetIntermediateDir()); GatherModuleFiles(); PlatformDefinition.Init(Interfaces); if (USEPREMAKE) { gen = new PreMakeGenerator(); } else { gen = new CmakeGenerator(); } //core module Is Special! CoreModule = TargetRulesObject.GetCoreModule(); for (int i = ALLModules.Count - 1; i >= 0; i--) { if (ALLModules[i].IsGameModule && ALLModules[i].ModuleName != CoreModule.GameModuleName) { ALLModules.RemoveAt(i); } } ALLModules.Add(CoreModule); if (LogDebug) { foreach (ModuleDef M in ALLModules) { Console.WriteLine("Found module " + M.ModuleName); } } Projectdata.LibSearchPaths.AddRange(TargetRulesObject.LibSearchPaths); PreProcessModules(); Projectdata.PopulateLibs(); ProcessModules(); LogStage("Generate project files stage"); if (!SettingCache.IsCacheValid()) { gen.ClearCache(); Console.WriteLine("Cache Is Invalid, clearing..."); } gen.SingleTargetPlatform = PlatformDefinition.GetDefinition(PlatformDefinition.WindowsID); gen.GenerateList(ALLModules, CoreModule, CurrentConfigs); gen.Execute(); LogStage("Post Gen"); gen.RunPostStep(NonCoreModuleObjects, CoreModule); LogStage("Copy DLLs"); FileUtils.CreateShortcut("EngineSolution.sln", GetRootPath(), GetIntermediateDir() + "\\Engine.sln"); Projectdata.CopyDllsToConfig(PlatformDefinition.GetDefaultPlatforms(), CurrentConfigs, ALLModules); LinkDirectiories(); SettingCache.Save(); LogStage("Complete"); }
public override void GenerateList(List <ModuleDef> Modules, ModuleDef CoreModule, List <BuildConfig> buildConfigs) { Console.WriteLine("Running Premake"); ModuleDefManager.Instance.PatchPremakeFileHeader(ref outputdata); outputdata += "workspace 'Engine'\n"; outputdata += " location \"" + StringUtils.SanitizePath(ModuleDefManager.GetIntermediateDir()) + "\"\n"; string OutputDir = StringUtils.SanitizePath(ModuleDefManager.GetBinPath()); outputdata += " targetdir \"" + OutputDir + "\"\n"; string Configurations = ""; foreach (BuildConfig B in buildConfigs) { Configurations += "\"" + B.Name + "\","; } outputdata += " configurations {" + Configurations + " }\n"; outputdata += "--Platform Definitions\n"; List <PlatformDefinition> Platforms = PlatformDefinition.GetDefaultPlatforms(); string PlatformData = ""; foreach (PlatformDefinition PDef in Platforms) { PlatformData += "\"" + PDef.Name + "\","; } outputdata += " platforms { " + PlatformData + " }\n"; foreach (PlatformDefinition PDef in Platforms) { outputdata += "filter{\"platforms:" + PDef.Name + "\"}\n"; outputdata += " system \"" + PDef.SystemType + "\"\n"; outputdata += " architecture \"" + PDef.ProcessorArch + "\"\n"; outputdata += " defines{" + StringUtils.ArrayStringQuotesComma(PDef.Defines.ToArray()) + " }\n"; outputdata += " systemversion \"" + PDef.SystemVersion + "\"\n"; } PopFilter(); PushPlatformFilter(PlatformDefinition.WindowsID); foreach (BuildConfig B in buildConfigs) { outputdata += "filter{\"configurations:" + B.Name + "\"}\n"; if (B.CurrentType == BuildConfiguration.BuildType.Debug) { outputdata += " defines { \"DEBUG\" } \n symbols \"On\"\n"; } else if (B.CurrentType == BuildConfiguration.BuildType.Release) { outputdata += " defines { \"NDEBUG\" } \n optimize \"On\" \n"; } } PopFilter(); AddCustomTargets(Modules, buildConfigs); CoreModule.ModuleDepends.Add("HeaderTool"); AddModule(CoreModule, buildConfigs); foreach (ModuleDef m in Modules) { if (m.IsOutputEXE && m.ModuleOutputType == ModuleDef.ModuleType.EXE) { foreach (ModuleDef mn in Modules) { m.ModuleDepends.Add(mn.ModuleName); } } AddModule(m, buildConfigs); } File.WriteAllText(DefinitionFile, outputdata); }
void AddModule(ModuleDef m, List <BuildConfig> buildConfigs) { List <PlatformDefinition> Platforms = PlatformDefinition.GetDefaultPlatforms(); m.GatherSourceFiles(); m.GatherIncludes(); string AllSourceFiles = StringUtils.ArrayStringQuotesComma(m.ModuleSourceFiles.ToArray()); string ExtraSourceFiles = StringUtils.ArrayStringQuotesComma(m.ModuleExtraFiles.ToArray()); List <string> ABSSourceFiles = m.ModuleSourceFiles; string ALLFiles = AllSourceFiles + ", " + ExtraSourceFiles; outputdata += "\n--Begin Module " + m.ModuleName + "\n"; outputdata += "group \"" + StringUtils.SanitizePath(m.SolutionFolderPath) + "\"\n"; outputdata += "project '" + m.ModuleName + "' \n"; if (m.ModuleOutputType == ModuleDef.ModuleType.EXE) { if (m.UseConsoleSubSystem) { outputdata += " kind \"ConsoleApp\"\n"; } else { outputdata += " kind \"WindowedApp\"\n"; } } else if (m.ModuleOutputType == ModuleDef.ModuleType.LIB) { outputdata += " kind \"StaticLib\"\n"; } else { outputdata += " kind \"SharedLib\"\n"; } outputdata += " language \"" + ConvertLanguage(m) + "\"\n"; outputdata += " flags {\"NoImportLib\"}\n"; outputdata += " editandcontinue \"Off\" \n"; outputdata += " cppdialect \"C++17\"\n"; PushPlatformFilter(PlatformDefinition.WindowsID); outputdata += " buildoptions {\"/bigobj\"}\n"; outputdata += " flags {\"NoImportLib\", \"MultiProcessorCompile\"}\n"; PopFilter(); ModuleDefManager.Instance.OnPreMakeWriteModule(m, ref outputdata); if (PushPlatformFilter(PlatformDefinition.AndroidID)) { outputdata += " buildoptions {\"-frtti -fexceptions\" }\n"; outputdata += " cppdialect \"C++14\"\n"; PopFilter(); } if (m.PCH.Length > 0) { outputdata += " pchheader \"" + m.PCH + ".h\"\n"; outputdata += " pchsource (\"" + StringUtils.SanitizePath(ModuleDefManager.GetSourcePath() + "/" + m.SourceFileSearchDir) + "/" + m.PCH + ".cpp\")\n"; outputdata += " forceincludes {\"" + m.PCH + ".h\"} \n"; } outputdata += " files {" + ALLFiles + "}\n"; if (m.PCH.Length > 0) { outputdata += " pchsource (\"" + StringUtils.SanitizePath(ModuleDefManager.GetSourcePath() + "/" + m.SourceFileSearchDir) + "/" + m.PCH + ".cpp\")\n"; } List <string> Dirs = new List <string>(); m.GetIncludeDirs(ref Dirs); if (m != ModuleDefManager.CoreModule) { ModuleDefManager.CoreModule.GetIncludeDirs(ref Dirs); } outputdata += " includedirs {" + StringUtils.ArrayStringQuotesComma(Dirs.ToArray()) + "}\n"; if (m.LaunguageType == ModuleDef.ProjectType.ManagedCPP) { outputdata += " clr \"on\"\n"; } if (m.UnsupportedPlatforms.Count > 0) { outputdata += "removeplatforms { " + StringUtils.ArrayStringQuotesComma(m.UnsupportedPlatforms.ToArray()) + "}\n"; } if (m.ModuleDepends.Count > 0) { outputdata += "dependson {" + StringUtils.ArrayStringQuotesComma(m.ModuleDepends.ToArray()) + "}\n"; } if (m.ExcludedFolders.Count > 0) { outputdata += "removefiles { " + StringUtils.ArrayStringQuotesComma(m.ExcludedFolders.ToArray()) + " }\n"; } if (m.ExcludeConfigs.Count > 0) { outputdata += "removeconfigurations{" + StringUtils.ArrayStringQuotesComma(m.ExcludeConfigs.ToArray()) + "};\n"; } if (m.ExcludedFoldersNew.Count > 0) { foreach (FolderPlatformPair p in m.ExcludedFoldersNew) { PushPlatformFilter(p.Platforms.ToArray(), "files:" + p.FolderName); outputdata += "flags{ \"ExcludeFromBuild\" }\n "; PopFilter(); } } List <PlatformID> MergePlatoforms = new List <PlatformID>(); foreach (PlatformDefinition PD in Platforms) { if (MergePlatoforms.Contains(PD.TypeId)) { continue; } List <PlatformID> AllOthers = new List <PlatformID>(); PlatformDefinition.TryAddPlatfromsFromString("!" + PD.Name, ref AllOthers); for (int i = AllOthers.Count - 1; i >= 0; i--) { if (PlatformDefinition.GetDefinition(AllOthers[i]) != null && PlatformDefinition.GetDefinition(AllOthers[i]).ExcludedPlatformFolder == PD.ExcludedPlatformFolder) { MergePlatoforms.Add(AllOthers[i]); AllOthers.RemoveAt(i); } } foreach (PlatformID i in AllOthers) { if (PlatformDefinition.GetDefinition(i) != null) { PlatformID[] d = { i }; PushPlatformFilter(d, "files:" + PD.ExcludedPlatformFolder); outputdata += "flags{\"ExcludeFromBuild\"}\n "; PopFilter(); } } } //outputdata += " filter{\"files:**.*\",\"platforms:Win64\"}\n flags{\"ExcludeFromBuild\"}\n "; outputdata += " filter{\"files:**.hlsl\"}\n flags{\"ExcludeFromBuild\"}\n "; PopFilter(); foreach (PlatformDefinition PD in Platforms) { if (PD == null) { continue; } foreach (BuildConfig Bc in buildConfigs) { string Links = CreateLibs(m, Bc, PD); if (Links.Length > 0) { PushFilter(PD.TypeId, "\"configurations:" + Bc.Name + "\""); outputdata += " links { " + Links + "}\n"; string OutputDir = StringUtils.SanitizePath(ModuleDefManager.GetBinPath()) + "/" + PD.Name + "/" + Bc.Name; outputdata += " targetdir (\"" + OutputDir + "\")\n"; if (m.OutputObjectName.Length != 0) { outputdata += " targetname \"" + m.OutputObjectName + "\"\n"; } List <string> Defines = new List <string>(); List <string> LibDirs = new List <string>(); Defines.AddRange(m.PreProcessorDefines); Defines.AddRange(Bc.Defines); foreach (ExternalModuleDef ExtraMods in m.ExternalModules) { if (!ExtraMods.UnsupportedPlatformsTypes.Contains(PD.TypeId)) { Defines.AddRange(ExtraMods.Defines); LibDirs.AddRange(ExtraMods.LibDirs); } } outputdata += " defines{" + StringUtils.ArrayStringQuotesComma(Defines.ToArray()) + " }\n"; outputdata += " libdirs{" + StringUtils.ArrayStringQuotesComma(LibDirs.ToArray()) + " }\n"; PopFilter(); } } } PopFilter(); if (m.IsCoreModule) { outputdata += "prebuildcommands(\"$(MSBuildProjectDirectory)/../Scripts/WriteCommit.bat\")\n"; } }