Esempio n. 1
0
        public override bool PushPlatformFilter(PlatformID[] Types, string extra = "")
        {
            string Platforms = "";

            for (int i = 0; i < Types.Length; i++)
            {
                if (Types[i] == PlatformID.Invalid)
                {
                    PopFilter();
                    return(false);
                }
                if (PlatformDefinition.GetDefinition(Types[i]) == null)
                {
                    continue;
                }
                Platforms += PlatformDefinition.GetDefinition(Types[i]).Name;
                if (Types.Length > 1 && i != (Types.Length - 1))
                {
                    Platforms += " or ";
                }
            }
            outputdata += "filter{";
            if (extra.Length > 0)
            {
                outputdata += "\"" + extra + "\",";
            }
            outputdata += "\"platforms:" + Platforms;
            outputdata += "\"}\n";
            return(true);
        }
        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");
        }
 void LinkDirectiories()
 {
     foreach (BuildConfig bc in CurrentConfigs)
     {
         if (bc.CurrentPackageType != BuildConfiguration.PackageType.Editor)
         {
             LinkPackageDir("DerivedDataCache", bc.Name, PlatformDefinition.GetDefinition(PlatformDefinition.WindowsID));
             LinkPackageDir("Content", bc.Name, PlatformDefinition.GetDefinition(PlatformDefinition.WindowsID));
         }
     }
 }
Esempio n. 4
0
 public override bool PushFilter(PlatformID Type, string BuildType)
 {
     if (Type == PlatformID.Invalid)
     {
         PopFilter();
         return(false);
     }
     if (PlatformDefinition.GetDefinition(Type) == null)
     {
         return(false);
     }
     outputdata += "filter{\"platforms:" + PlatformDefinition.GetDefinition(Type).Name + "\", " + BuildType + "}\n";
     return(true);
 }
Esempio n. 5
0
        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";
            }
        }
Esempio n. 6
0
 bool IsValid(PlatformID type)
 {
     return(PlatformDefinition.GetDefinition(type) != null);
 }