コード例 #1
0
        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";
        }
コード例 #2
0
 public static string RelativeToABS(List <string> Paths)
 {
     for (int i = 0; i < Paths.Count; i++)
     {
         Paths[i] = SanitizePath(ModuleDefManager.GetSourcePath()) + "/" + Paths[i];
     }
     return(ArrayStringQuotes(Paths.ToArray()));
 }
コード例 #3
0
        public override void GenerateList(List <ModuleDef> Modules, ModuleDef CoreModule, List <BuildConfig> buildConfigs)
        {
            Console.WriteLine("Running CMake");
            Console.WriteLine("Targeting Platform " + SingleTargetPlatform.Name);
            GenHeader(buildConfigs);
            ProcessModule(CoreModule);

            foreach (ModuleDef M in Modules)
            {
                ProcessModule(M);
            }
            {//Header tool project
                OutputData += "add_custom_target(" + HeaderToolTarget + " DEPENDS  always_rebuild)\n";
                string headertoolString = StringUtils.SanitizePath(ModuleDefManager.GetSourcePath() + "/EngineHeaderTool.exe \" ");
                Console.WriteLine("Game Module is " + CoreModule.GameModuleName);
                OutputData += "add_custom_command(TARGET " + HeaderToolTarget + "  PRE_BUILD  \nCOMMAND \"" + headertoolString +
                              " -Name " + CoreModule.GameModuleName + " )\n";
                OutputData += "set_target_properties(" + HeaderToolTarget + " PROPERTIES FOLDER " + "Build/" + ")\n";
            }
            if (UseAllBuildWorkAround)
            {
                OutputData += "add_custom_target(" + BuildAllTarget + " ALL)\n";
                if (PreBuild_HeaderTool)
                {
                    OutputData += "add_dependencies(" + BuildAllTarget + " " + HeaderToolTarget + ")\n";
                }
                foreach (ModuleDef M in Modules)
                {
                    OutputData += "add_dependencies(" + BuildAllTarget + " " + M.ModuleName + ")\n";
                }
                //A Workaround is used here to set the correct directories for running the project
                OutputData += "set_target_properties(" + BuildAllTarget + " PROPERTIES FOLDER " + "Targets/" + ")\n";

                OutputData += "set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT " + BuildAllTarget + ")\n";
            }
            else
            {
                ModuleDef Temp_GMOut = null;
                foreach (ModuleDef M in Modules)
                {
                    if (M.ModuleOutputType == ModuleDef.ModuleType.EXE)
                    {
                        Temp_GMOut = M;
                        break;
                    }
                }
                foreach (ModuleDef M in Modules)
                {
                    OutputData += "add_dependencies(" + Temp_GMOut.ModuleName + " " + M.ModuleName + ")\n";
                }
                OutputData += "set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT " + Temp_GMOut.ModuleName + ")\n";
            }

            WriteToFile(ModuleDefManager.GetSourcePath());
        }
コード例 #4
0
        public override void Execute()
        {
            string SDKVersion = ModuleDefManager.TargetRulesObject.GetWinSDKVer();
            string Arg        = " -DCMAKE_SYSTEM_VERSION=" + SDKVersion + " -DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" + SDKVersion;
            string Vs17Args   = "\"Visual Studio 15 2017 Win64\"" + Arg;
            string Vs15Args   = "\"Visual Studio 14 2015 Win64\"" + Arg;
            string CmakeArgs  = "-G  " + (UseVs17 ? Vs17Args : Vs15Args) + " \"" + ModuleDefManager.GetSourcePath() + "\"";
            string Cmakeexe   = "cmake";

            if (FindLocalCmake())
            {
                Cmakeexe = CmakeLocalPath;
            }
            int code = ProcessUtils.RunProcess(Cmakeexe, CmakeArgs);

            Console.WriteLine("Cmake finished with Code: " + code);
        }
コード例 #5
0
 public void GatherSourceFiles()
 {
     if (ModuleSourceFiles.Count != 0)
     {
         return;
     }
     if (LaunguageType == ProjectType.CSharp)
     {
         GetFiles("*.cs");
         ModuleSourceFiles.RemoveAll(IsBuildfile);
     }
     else
     {
         GetFiles("*.h");
         GetFiles("*.hpp");
         GetFiles("*.c");
         GetFiles("*.cpp");
         GetFiles("*.rc");
         GetFiles("*.cs", ModuleDefManager.GetSourcePath() + "\\" + SourceFileSearchDir, true);
         if (IsCoreModule)
         {
             GetFiles("*.hlsl", ModuleDefManager.GetRootPath() + "\\Shaders", false);
             GetFiles("*.h", ModuleDefManager.GetRootPath() + "\\Shaders", false);
             ModuleExtraFiles.Add(StringUtils.SanitizePath(ModuleDefManager.GetSourcePath() + "\\Core.Target.cs"));
         }
     }
     for (int i = 0; i < ModuleSourceFiles.Count; i++)
     {
         foreach (string folder in ExcludedFolders)
         {
             string Safe = folder.Replace("*", "");
             if (ModuleSourceFiles[i].Contains(Safe))
             {
                 ModuleSourceFiles[i] = "";
             }
         }
     }
 }
コード例 #6
0
 void GetFiles(string Type, string path, bool Source)
 {
     try
     {
         string[] files = Directory.GetFiles(path, Type, SearchOption.AllDirectories);
         for (int i = 0; i < files.Length; i++)
         {
             files[i] = files[i].Replace(ModuleDefManager.GetSourcePath() + "\\", "");
             files[i] = files[i].Replace(ModuleDefManager.GetRootPath() + "\\", "../");
             files[i] = StringUtils.SanitizePath(files[i]);
         }
         if (Source)
         {
             ModuleSourceFiles.AddRange(files);
         }
         else
         {
             ModuleExtraFiles.AddRange(files);
         }
     }
     catch
     {
     }
 }
コード例 #7
0
        public static void ProcessExpections(XmlDocument doc, XmlNamespaceManager nsmgr, ModuleDef md)
        {
            List <string> Excludes = new List <string>();

            foreach (string path in md.UnityBuildExcludedFolders)
            {
                Excludes.AddRange(FileUtils.GetFilePaths(ModuleDefManager.GetSourcePath() + "\\" + md.ModuleName + "\\" + path, "*.cpp", true));
                Console.WriteLine("Excluded " + path + " from unity build for module " + md.ModuleName);
            }

            XmlNodeList cl = doc.SelectNodes("//a:ItemGroup", nsmgr);

            foreach (string s in Excludes)
            {
                string parsed  = StringUtils.SanitizePathToDoubleBack(s);
                string RelPath = parsed.Replace(StringUtils.SanitizePathToDoubleBack(Directory.GetCurrentDirectory()), "..");
                //..\Source\Core\AI\Core\AIBase.cpp
                XmlNodeList cc = doc.SelectNodes("//a:ClCompile[*]", nsmgr);
                foreach (XmlNode nn in cc)
                {
                    if (nn.Attributes.Count > 0)
                    {
                        if (nn.Attributes[0].Value == RelPath)
                        {
                            foreach (XmlNode child in nn.ChildNodes)
                            {
                                if (child.Name == "IncludeInUnityFile")
                                {
                                    child.InnerText = "false";
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
 public PreMakeGenerator()
 {
     DefinitionFile = StringUtils.SanitizePath(ModuleDefManager.GetSourcePath() + "/premake.lua");
 }
コード例 #9
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";
            }
        }
コード例 #10
0
        void GetFiles(string Type)
        {
            string path = ModuleDefManager.GetSourcePath() + "\\" + SourceFileSearchDir;

            GetFiles(Type, path, true);
        }