コード例 #1
0
        public override void ClearCache()
        {
            string CMakeDir = ModuleDefManager.GetIntermediateDir() + "\\CMakeFiles";

            if (Directory.Exists(CMakeDir))
            {
                Directory.Delete(CMakeDir, true);
            }
        }
コード例 #2
0
        public static void ReplaceAllModule(ModuleDef md, string target, string replacement)
        {
            string VxprojPath = ModuleDefManager.GetIntermediateDir() + "\\" + md.ModuleName + ".vcxproj";

            if (!File.Exists(VxprojPath))
            {
                Console.WriteLine("Error: No project file!");
                return;
            }
            ReplaceAll(VxprojPath, target, replacement);
        }
コード例 #3
0
        public override void RunPostStep(List <ModuleDef> Modules, ModuleDef CoreModule)
        {
            string replacement        = " Win64|x64";
            string ConfigToken        = "</Configuration>";
            string ConfigreplaceToken = " Win64</Configuration>";

            VisualStudioProjectEditor.EnableUnityBuild(CoreModule);
            VisualStudioProjectEditor.ReplaceAllModule(CoreModule, "|x64", replacement);
            VisualStudioProjectEditor.ReplaceAllModule(CoreModule, ConfigToken, ConfigreplaceToken);
            foreach (ModuleDef m in Modules)
            {
                VisualStudioProjectEditor.EnableUnityBuild(m);
                VisualStudioProjectEditor.ProcessFile(m);
                VisualStudioProjectEditor.ReplaceAllModule(m, "|x64", replacement);
                VisualStudioProjectEditor.ReplaceAllModule(m, ConfigToken, ConfigreplaceToken);
            }
            string buildall = ModuleDefManager.GetIntermediateDir() + "\\ALL_Build.vcxproj";

            VisualStudioProjectEditor.ReplaceAll(buildall, "|x64", replacement);
            VisualStudioProjectEditor.ReplaceAll(buildall, ConfigToken, ConfigreplaceToken);
            string HeaderTool = ModuleDefManager.GetIntermediateDir() + "\\HeaderTool.vcxproj";

            VisualStudioProjectEditor.ReplaceAll(HeaderTool, "|x64", replacement);
            VisualStudioProjectEditor.ReplaceAll(HeaderTool, ConfigToken, ConfigreplaceToken);
            string SLNpath = ModuleDefManager.GetIntermediateDir() + "\\Engine.sln";

            foreach (BuildConfig bc in ModuleDefManager.CurrentConfigs)
            {
                string token            = "|x64.ActiveCfg = " + bc.Name + "|x64";
                string repalcementtoken = "|Win64.ActiveCfg = " + bc.Name + " Win64|x64";
                VisualStudioProjectEditor.ReplaceAll(SLNpath, token, repalcementtoken);
                token            = "|x64.Build.0 = " + bc.Name + "|x64";
                repalcementtoken = "|Win64.Build.0 = " + bc.Name + " Win64|x64";
                VisualStudioProjectEditor.ReplaceAll(SLNpath, token, repalcementtoken);
                token            = "|x64 = " + bc.Name + "|x64";
                repalcementtoken = "|Win64 = " + bc.Name + "|Win64";
                VisualStudioProjectEditor.ReplaceAll(SLNpath, token, repalcementtoken);
            }
            if (UseAllBuildWorkAround)
            {
                foreach (BuildConfig bc in ModuleDefManager.CurrentConfigs)
                {
                    string path = StringUtils.SanitizePath(ModuleDefManager.GetBinPath() + "\\" + bc.Name + "\\");
                    VisualStudioProjectEditor.SetTargetOutput(BuildAllTarget, path, CoreModule.OutputObjectName, bc.Name);
                }
            }
        }
コード例 #4
0
        public static void ProcessFile(ModuleDef md)
        {
            string VxprojPath = ModuleDefManager.GetIntermediateDir() + "\\" + md.ModuleName + ".vcxproj";

            if (!File.Exists(VxprojPath))
            {
                Console.WriteLine("Error: No project file!");
                return;
            }
            XmlDocument doc = new XmlDocument();

            doc.Load(VxprojPath);
            var nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("a", "http://schemas.microsoft.com/developer/msbuild/2003");
            PostProcessStepAddNuGet(doc, nsmgr, md);

            doc.Save(VxprojPath);
        }
コード例 #5
0
        public static void SetTargetOutput(string Targetname, string outdir, string TargetNamestr, string config)
        {
            string VxprojPath = ModuleDefManager.GetIntermediateDir() + "\\" + Targetname + ".vcxproj";

            if (!File.Exists(VxprojPath))
            {
                Console.WriteLine("Error: No project file!");
                return;
            }
            XmlDocument doc = new XmlDocument();

            doc.Load(VxprojPath);
            var nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("a", "http://schemas.microsoft.com/developer/msbuild/2003");
            //  string Conditionstr = "'$(Configuration)|$(Platform)'=='" + config + "Win64|x64'";
            string  Conditionstr = "'$(Configuration)|$(Platform)'=='" + config + "|x64'";
            string  Querry       = "//a:PropertyGroup[@Condition=\"" + Conditionstr + "\"]";
            XmlNode target       = doc.SelectSingleNode(Querry, nsmgr);

            if (target == null)
            {
                XmlNode newnode = doc.CreateElement("PropertyGroup", doc.DocumentElement.NamespaceURI);
                doc.DocumentElement.InsertAfter(newnode, doc.DocumentElement.FirstChild);
                XmlAttribute attrib = doc.CreateAttribute("Condition");
                attrib.Value = Conditionstr;
                newnode.Attributes.Append(attrib);
                target = newnode;
            }

            XmlNode OutDir = doc.CreateElement("OutDir", doc.DocumentElement.NamespaceURI);

            OutDir.InnerText = outdir;
            target.AppendChild(OutDir);
            XmlNode TargetName = doc.CreateElement("TargetName", doc.DocumentElement.NamespaceURI);

            TargetName.InnerText = TargetNamestr;
            target.AppendChild(TargetName);

            doc.Save(VxprojPath);
        }
コード例 #6
0
        public static void EnableUnityBuild(ModuleDef md)
        {
            if (!CanModuleUnity(md))
            {
                return;
            }
            Console.WriteLine("Experimental VS Unity Build running on module " + md.ModuleName);
            string VxprojPath = ModuleDefManager.GetIntermediateDir() + "\\" + md.ModuleName + ".vcxproj";

            if (!File.Exists(VxprojPath))
            {
                Console.WriteLine("Error: No project file!");
                return;
            }
            XmlDocument doc = new XmlDocument();

            doc.Load(VxprojPath);
            XmlNode target = doc.SelectSingleNode("//EnableUnitySupport");

            if (target == null)
            {
                XmlNode newnode = doc.CreateNode(XmlNodeType.Element, "PropertyGroup", doc.DocumentElement.NamespaceURI);
                doc.DocumentElement.InsertAfter(newnode, doc.DocumentElement.FirstChild);
                XmlNode a = doc.CreateNode(XmlNodeType.Element, "EnableUnitySupport", doc.DocumentElement.NamespaceURI);
                a.InnerText = "true";
                newnode.AppendChild(a);
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("a", "http://schemas.microsoft.com/developer/msbuild/2003");
                XmlNodeList complies = doc.SelectNodes("//a:ClCompile", nsmgr);
                foreach (XmlNode x in complies)
                {
                    XmlNode value = doc.CreateNode(XmlNodeType.Element, "IncludeInUnityFile", doc.DocumentElement.NamespaceURI);
                    value.InnerText = "true";//<IncludeInUnityFile>true</IncludeInUnityFile>
                    x.AppendChild(value);
                }

                ProcessExpections(doc, nsmgr, md);

                doc.Save(VxprojPath);
            }
        }
コード例 #7
0
 public static int RunProcess(string File, string CmakeArgs)
 {
     System.Diagnostics.Process          process   = new System.Diagnostics.Process();
     System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
     startInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
     startInfo.FileName               = File;
     startInfo.Arguments              = CmakeArgs;
     startInfo.WorkingDirectory       = ModuleDefManager.GetIntermediateDir();
     startInfo.RedirectStandardOutput = true;
     startInfo.UseShellExecute        = false;
     process.StartInfo = startInfo;
     process.Start();
     while (!process.HasExited)
     {
         using (StreamReader reader = process.StandardOutput)
         {
             string result = reader.ReadToEnd();
             Console.Write(result);
         }
     }
     process.WaitForExit();
     return(process.ExitCode);
 }
コード例 #8
0
        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);
        }
コード例 #9
0
 static string GetSettingFilePath()
 {
     return(ModuleDefManager.GetIntermediateDir() + "\\SettingCache.xml");
 }