Exemplo n.º 1
0
 public void GatherIncludes()
 {
     for (int i = 0; i < IncludeDirectories.Count; i++)
     {
         if (IncludeDirectories[i].Contains("$"))
         {
             continue;
         }
         IncludeDirectories[i] = StringUtils.SanitizePath(ModuleDefManager.GetRootPath() + IncludeDirectories[i]);
     }
 }
Exemplo n.º 2
0
 //this allows a cmake install to be placed in a folder called CmakeLocal
 bool FindLocalCmake()
 {
     CmakeLocalPath = ModuleDefManager.GetRootPath() + "\\CmakeLocal\\CMake\\bin";
     if (!Directory.Exists(CmakeLocalPath))
     {
         return(false);
     }
     CmakeLocalPath += "\\cmake.exe";
     if (!File.Exists(CmakeLocalPath))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
        public override void Execute()
        {
            string premakeExe = ModuleDefManager.GetRootPath() + "\\Scripts\\premake5.exe";
            string Args       = (Use2019 ? "vs2019" : "vs2017 ") + " --file=\"" + DefinitionFile + "\"";
            int    code       = -1;

            try
            {
                code = ProcessUtils.RunProcess(premakeExe, Args);
            }
            catch
            { }
            Console.WriteLine("PreMake finished with Code: " + code);
        }
Exemplo n.º 4
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] = "";
             }
         }
     }
 }
Exemplo n.º 5
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
     {
     }
 }
Exemplo n.º 6
0
        public void ProcessModule(ModuleDef Module)
        {
            if (Module.Processed)
            {
                return;
            }
            OutputData += "#-------------Module Start " + Module.ModuleName + "----------------\n";
            Module.GatherSourceFiles();
            Module.GatherIncludes();
            if (Module.LaunguageType == ModuleDef.ProjectType.CSharp)
            {
                OutputData += CmakeCSharpProject.GetModule(Module);
                return;
            }
            Module.PreProcessorDefines.AddRange(SingleTargetPlatform.Defines);
            string AllSourceFiles   = StringUtils.ArrayStringQuotes(Module.ModuleSourceFiles.ToArray());
            string ExtraSourceFiles = StringUtils.ArrayStringQuotes(Module.ModuleExtraFiles.ToArray());
            string ALLFiles         = StringUtils.RelativeToABS(Module.ModuleSourceFiles) + ExtraSourceFiles;

            if (Module.ModuleOutputType == ModuleDef.ModuleType.ModuleDLL)
            {
                OutputData += "add_library( " + Module.ModuleName + " MODULE " + ALLFiles + ")\n";
            }
            else if (Module.ModuleOutputType == ModuleDef.ModuleType.DLL)
            {
                OutputData += "add_library( " + Module.ModuleName + " SHARED " + ALLFiles + ")\n";
            }
            else if (Module.ModuleOutputType == ModuleDef.ModuleType.LIB)
            {
                OutputData += "add_library( " + Module.ModuleName + " STATIC " + ALLFiles + ")\n";
            }
            else if (Module.ModuleOutputType == ModuleDef.ModuleType.EXE)
            {
                OutputData += "add_executable( " + Module.ModuleName + " " + ALLFiles + ")\n";
                OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES ENABLE_EXPORTS On)\n";
            }

            if (Module.UseConsoleSubSystem)
            {
                OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES LINK_FLAGS ${CMAKE_EXE_LINKER_CONSOLE_FLAGS})\n";

                foreach (BuildConfig bc in ModuleDefManager.CurrentConfigs)
                {
                    string OutputDir = StringUtils.SanitizePath(ModuleDefManager.GetBinPath() + "\\Tools\\" + bc.Name + "\\");
                    OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES RUNTIME_OUTPUT_DIRECTORY_" + bc.Name.ToUpper() + " \"" + OutputDir + "\")\n";
                }
            }
            if (Module.OutputObjectName.Length > 0)
            {
                OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES OUTPUT_NAME \"" + Module.OutputObjectName + "\")\n";
            }
            if (Module.SolutionFolderPath.Length == 0)
            {
                Module.SolutionFolderPath = "Engine/Modules";
            }
            OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES FOLDER " + Module.SolutionFolderPath + ")\n";

            if (Module.ModuleLibs.Count != 0)
            {
                OutputData += "target_link_libraries(" + Module.ModuleName + " " + StringUtils.ArrayStringQuotes(Module.ModuleLibs.ToArray()) + ")\n";
            }
            if (PreBuild_HeaderTool)
            {
                OutputData += "add_dependencies(" + Module.ModuleName + " " + HeaderToolTarget + ")\n";
            }
            if (Module.LaunguageType == ModuleDef.ProjectType.ManagedCPP)
            {
                //Module.ModuleDepends.Add("CSharpCore");
            }
            if (Module.ModuleDepends.Count != 0)
            {
                OutputData += "target_link_libraries(" + Module.ModuleName + " " + StringUtils.ArrayStringQuotes(Module.ModuleDepends.ToArray()) + ")\n";
            }
            VisualStudioProjectEditor.ProcessNuGetPacks(Module);
            List <string> Dirs = new List <string>();

            Module.GetIncludeDirs(ref Dirs);
            if (Module != ModuleDefManager.CoreModule)
            {
                ModuleDefManager.CoreModule.GetIncludeDirs(ref Dirs);
            }
            if (Dirs.Count > 0)
            {
#if true
                OutputData += "target_include_directories(" + Module.ModuleName + " PRIVATE " + StringUtils.ArrayStringQuotes(Dirs.ToArray()) + ")\n";
#else
                OutputData += "include_directories(" + Module.ModuleName + " " + ArrayStringQuotes(Dirs.ToArray()) + ")\n";
#endif
                Dirs.Clear();
            }
            OutputData += "source_group(TREE \"" + StringUtils.SanitizePath(ModuleDefManager.GetRootPath()) + "\" REGULAR_EXPRESSION \"*.h\" FILES " + ALLFiles + ")\n";

            OutputData += "set_source_files_properties(" + ExtraSourceFiles + " PROPERTIES HEADER_FILE_ONLY ON)\n";
            OutputData += "set_target_properties( " + Module.ModuleName + " PROPERTIES GHS_NO_SOURCE_GROUP_FILE OFF)\n";
            if (Module.UseCorePCH)
            {
                Module.PCH = ModuleDefManager.CoreModule.PCH;
            }
            if (Module.PCH.Length != 0)
            {
                string PCHString        = /*"Source/" +*/ /*Module.SourceFileSearchDir + "/"+*/ Module.PCH;
                string pchstring        = "/FI" + PCHString + ".h";
                string SharedHeaderData = " /Yu" + PCHString + ".h ";
                if (Module.UseCorePCH)
                {
                    SharedHeaderData = "";
                }
#if false
                if (Module.UseCorePCH)
                {
                    SharedHeaderData = "/Fp" + ModuleDefManager.CoreModule.ModuleName + ".dir" + "/$(Configuration)/" + ModuleDefManager.CoreModule.ModuleName + ".pch";
                }
#endif
                OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES COMPILE_FLAGS \"" + SharedHeaderData + pchstring + "\" )\n";

                if (!Module.UseCorePCH)
                {
                    OutputData += "SET_SOURCE_FILES_PROPERTIES(\"" + Module.SourceFileSearchDir + "/" + Module.PCH + ".cpp\" COMPILE_FLAGS \"/Yc" + PCHString + ".h\" )\n";
                }
            }

            if (VisualStudioProjectEditor.CanModuleUnity(Module))
            {
                Module.PreProcessorDefines.Add("WITH_UNITY");
            }
            OutputData += "target_compile_definitions(" + Module.ModuleName + " PRIVATE " + StringUtils.ListStringDefines(Module.PreProcessorDefines) + ")\n";
            ///WHOLEARCHIVE
            if (Module.ModuleDepends.Count > 0 && Module.ModuleOutputType == ModuleDef.ModuleType.LIB)
            {
                string WholeDataString = "";
                foreach (string s in Module.ModuleDepends)
                {
                    WholeDataString += "/WHOLEARCHIVE:" + s + " ";
                }
                OutputData += "SET_TARGET_PROPERTIES(" + Module.ModuleName + " PROPERTIES LINK_FLAGS_DEBUG " + WholeDataString + " )\n";
            }
            if (Module.NeedsCore && Module != ModuleDefManager.CoreModule)
            {
                OutputData += "add_dependencies(" + Module.ModuleName + " Core )\n";
            }
            if (Module.IsCoreModule)
            {
                string VersionGetterString = StringUtils.SanitizePath(ModuleDefManager.GetRootPath() + "/Scripts/WriteCommit.bat ");
                OutputData += "add_custom_command(TARGET " + Module.ModuleName + "  PRE_BUILD  \nCOMMAND \"" + VersionGetterString + "\" )\n";
            }
            if (Module.LaunguageType == ModuleDef.ProjectType.ManagedCPP)
            {
                //Imported_common_language_runtime
                OutputData += "set_property(TARGET " + Module.ModuleName + " PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION \"v4.6.1\")\n";
                OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES COMMON_LANGUAGE_RUNTIME \"\")\n";

                //OutputData += "SET (MANAGEDFLAGS \"${CMAKE_CXX_FLAGS}\")\n";
                //OutputData += "SET (MANAGEDFLAGS_D \"${CMAKE_CXX_FLAGS_DEBUG}\")\n";
                //OutputData += "STRING(REPLACE \"/EHsc\" \"/EHa\" MANAGEDFLAGS ${MANAGEDFLAGS}) \n STRING(REPLACE \"/RTC1\" \"\" MANAGEDFLAGS_D ${MANAGEDFLAGS_D})\n";
                //OutputData += "set_target_properties(" + Module.ModuleName + " PROPERTIES COMPILE_FLAGS \"${CMAKE_CXX_FLAGS}" + "/clr" + "\" )\n";
                OutputData += "set_property(TARGET " + Module.ModuleName + " PROPERTY VS_DOTNET_REFERENCES  \"System\" " + StringUtils.ArrayStringQuotes(Module.NetReferences.ToArray()) + " )\n";
            }
            Module.Processed = true;
        }