Esempio n. 1
0
        private bool TryToSetupIncrediBuildProcessObject(SolutionInfo solutionInfo, ref ProcessStartInfo info)
        {
            try
            {
                info.FileName = GetIncrediBuildPath();
                if (string.IsNullOrEmpty(info.FileName) || !File.Exists(info.FileName))
                {
                    _settings.Output.WriteLine(
                        "Warning: RudeBuild is setup to use IncrediBuild, but IncrediBuild doesn't seem to be installed properly.\n" +
                        "Falling back to using a regular Visual Studio build.\n" +
                        "Error: Couldn't find IncrediBuild command-line tool: " + info.FileName);
                    return(false);
                }

                string buildCommand = string.Empty;
                if (_settings.BuildOptions.Clean)
                {
                    buildCommand = "/Clean";
                }
                else if (_settings.BuildOptions.Rebuild)
                {
                    buildCommand = "/Rebuild";
                }

                info.Arguments = string.Format(" \"{0}\" {1} /cfg=\"{2}\"", _settings.ModifyFileName(solutionInfo.FilePath), buildCommand, _settings.BuildOptions.Config);
                if (!string.IsNullOrEmpty(_settings.BuildOptions.Project))
                {
                    string projectName = _settings.GlobalSettings.FileNamePrefix + _settings.BuildOptions.Project;
                    info.Arguments += string.Format(" /prj=\"{0}\"", projectName);
                }

                info.Arguments += " /UseIDEMonitor";
            }
            catch (Exception ex)
            {
                _settings.Output.WriteLine(
                    "Warning: RudeBuild is setup to use IncrediBuild, but IncrediBuild doesn't seem to be installed properly.\n" +
                    "Falling back to using a regular Visual Studio build.\n" +
                    "Error: " + ex.Message);
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        private void ValidateBuildOptions(SolutionInfo solutionInfo)
        {
            string solutionConfig = _settings.BuildOptions.Config;

            if (string.IsNullOrEmpty(solutionConfig))
            {
                throw new ArgumentException(string.Format("A solution configuration to build is required! None specified while trying to build solution {0}.", solutionInfo.Name));
            }

            if (!solutionInfo.ConfigManager.SolutionConfigs.Contains(solutionConfig))
            {
                throw new ArgumentException(string.Format("The specified solution configuration {0} does not exist in solution {1}.", solutionConfig, solutionInfo.Name));
            }

            string projectName = _settings.BuildOptions.Project;

            if (!string.IsNullOrEmpty(projectName) && null == solutionInfo.GetProjectInfo(projectName))
            {
                throw new ArgumentException(string.Format("Solution {0} doesn't contain a project called {1}!", solutionInfo.Name, projectName));
            }
        }
Esempio n. 3
0
        public bool Update(SolutionInfo solutionInfo)
        {
            if (null == ProjectNameToExcludedCppFileNameMap)
            {
                ProjectNameToExcludedCppFileNameMap = new SerializableDictionary <string, List <string> >();
            }

            bool changed = RemoveNoLongerExistingProjects(solutionInfo);

            foreach (string projectName in solutionInfo.ProjectNames)
            {
                ProjectInfo projectInfo = solutionInfo.GetProjectInfo(projectName);
                if (null == projectInfo)
                {
                    throw new InvalidDataException("SolutionInfo does not contain ProjectInfo object for project called " + projectName);
                }

                changed = RemoveNoLongerExistingCppFileNames(projectInfo) || changed;
            }

            return(changed);
        }
Esempio n. 4
0
        private void SetupDevEnvProcessObject(SolutionInfo solutionInfo, ref ProcessStartInfo info)
        {
            info.FileName = GetDevEnvPath(solutionInfo.Version);

            string buildCommand = "Build";

            if (_settings.BuildOptions.Clean)
            {
                buildCommand = "Clean";
            }
            else if (_settings.BuildOptions.Rebuild)
            {
                buildCommand = "Rebuild";
            }

            info.Arguments = string.Format(" \"{0}\" /{1} \"{2}\"", _settings.ModifyFileName(solutionInfo.FilePath), buildCommand, _settings.BuildOptions.Config);
            if (!string.IsNullOrEmpty(_settings.BuildOptions.Project))
            {
                string projectName = _settings.BuildOptions.Project;
                info.Arguments += string.Format(" /project \"{0}\"", projectName);
            }
        }
Esempio n. 5
0
        private Process CreateProcessObject(SolutionInfo solutionInfo)
        {
            var process           = new Process();
            ProcessStartInfo info = process.StartInfo;

            info.CreateNoWindow         = true;
            info.UseShellExecute        = false;
            info.ErrorDialog            = false;
            info.RedirectStandardOutput = true;
            process.OutputDataReceived += delegate(object sendingProcess, DataReceivedEventArgs line)
            {
                _settings.Output.WriteLine(line.Data);
            };

            bool useDevEnvBuildTool = true;

            if (_settings.GlobalSettings.BuildTool == BuildTool.IncrediBuild && TryToSetupIncrediBuildProcessObject(solutionInfo, ref info))
            {
                useDevEnvBuildTool = false;
            }
            else if (_settings.GlobalSettings.BuildTool == BuildTool.SN_DBS && TryToSetupSnVsBuildProcessObject(solutionInfo, ref info))
            {
                useDevEnvBuildTool = false;
            }
            else if (_settings.GlobalSettings.BuildTool == BuildTool.MsBuild && TryToSetupMsBuildProcessObject(solutionInfo, ref info))
            {
                useDevEnvBuildTool = false;
            }

            if (useDevEnvBuildTool)
            {
                SetupDevEnvProcessObject(solutionInfo, ref info);
            }

            _settings.Output.WriteLine("Launching: " + info.FileName + info.Arguments);

            return(process);
        }
Esempio n. 6
0
        public static SolutionSettings Load(Settings settings, SolutionInfo solutionInfo)
        {
            string configFilePath = GetConfigFilePath(solutionInfo);

            if (File.Exists(configFilePath))
            {
                using (TextReader textReader = new StreamReader(configFilePath))
                {
                    var deserializer = new XmlSerializer(typeof(SolutionSettings));
                    try
                    {
                        var solutionSettings = (SolutionSettings)deserializer.Deserialize(textReader);
                        return(solutionSettings);
                    }
                    catch
                    {
                        // ignore any errors
                    }
                }
            }

            return(new SolutionSettings());
        }
Esempio n. 7
0
        private void ReadWrite(string projectFileName, SolutionInfo solutionInfo, SingleProjectReaderWriterBase singleProjectReaderWriter, bool performReadOnly)
        {
            XDocument projectDocument = XDocument.Load(projectFileName);

            if (null == projectDocument)
            {
                throw new InvalidDataException("Couldn't load project file '" + projectFileName + "'.");
            }

            ProjectInfo projectInfo = singleProjectReaderWriter.ReadWrite(projectFileName, solutionInfo, projectDocument, performReadOnly);

            solutionInfo.AddProject(projectInfo);

            if (!performReadOnly)
            {
                string destProjectFileName = _settings.ModifyFileName(projectFileName);
                var    writer = new ModifiedTextFileWriter(destProjectFileName, _settings.BuildOptions.ShouldForceWriteCachedFiles());
                if (writer.Write(projectDocument.ToString()))
                {
                    _settings.Output.WriteLine("Creating project file " + destProjectFileName);
                }
            }
        }
Esempio n. 8
0
        public override ProjectInfo ReadWrite(string projectFileName, SolutionInfo solutionInfo, XDocument projectDocument, bool performReadOnly)
        {
            SolutionConfigManager.ProjectConfig projectConfig = solutionInfo.ConfigManager.GetProjectByFileName(projectFileName);
            if (null == projectConfig)
            {
                throw new InvalidDataException("Couldn't find project " + projectFileName + " in solution " + solutionInfo.Name);
            }

            XNamespace ns = projectDocument.Root.Name.Namespace;

            var fileElements            = projectDocument.Descendants(ns + "File").ToList();
            var mergableCppFileElements =
                (from element in fileElements
                 where IsMergableCppFileElement(projectConfig, ns, element, "RelativePath")
                 select element).ToList();
            var mergableCppFileNames =
                from cppFileElement in mergableCppFileElements
                select cppFileElement.Attribute("RelativePath").Value;

            var allCppFileNames =
                from element in fileElements
                where IsValidCppFileElement(ns, element, "RelativePath")
                select element.Attribute("RelativePath").Value;

            var allIncludeFileNames =
                from element in fileElements
                where IsValidIncludeFileElement(ns, element, "RelativePath")
                select element.Attribute("RelativePath").Value;

            string projectName           = Path.GetFileNameWithoutExtension(projectFileName);
            string precompiledHeaderName = GetPrecompiledHeader(projectConfig, projectDocument, ns);
            var    projectInfo           = new ProjectInfo(solutionInfo, projectName, projectFileName, mergableCppFileNames.ToList(), allCppFileNames.ToList(), allIncludeFileNames.ToList(), precompiledHeaderName);

            if (!performReadOnly)
            {
                var merger = new UnityFileMerger(_settings);
                merger.Process(projectInfo);

                foreach (XElement cppFileNameElement in mergableCppFileElements)
                {
                    string cppFileName = cppFileNameElement.Attribute("RelativePath").Value;
                    if (merger.MergedCppFileNames.Contains(cppFileName))
                    {
                        cppFileNameElement.Remove();
                    }
                }

                XElement filesElement = projectDocument.Descendants(ns + "Files").Single();
                filesElement.Add(
                    from unityFileName in merger.UnityFilePaths
                    select new XElement(ns + "File", new XAttribute("RelativePath", unityFileName)));

                if (ShouldDisablePrecompiledHeaders(projectInfo))
                {
                    DisablePrecompiledHeaders(projectDocument, ns);
                }
                if (_settings.SolutionSettings.SetBigObjCompilerFlag)
                {
                    SetBigObjCompilerFlag(projectDocument, ns);
                }
            }

            return(projectInfo);
        }
Esempio n. 9
0
        public override ProjectInfo ReadWrite(string projectFileName, SolutionInfo solutionInfo, XDocument projectDocument, bool performReadOnly)
        {
            SolutionConfigManager.ProjectConfig projectConfig = solutionInfo.ConfigManager.GetProjectByFileName(projectFileName);
            if (null == projectConfig)
            {
                throw new InvalidDataException("Couldn't find project " + projectFileName + " in solution " + solutionInfo.Name);
            }

            XNamespace ns             = projectDocument.Root.Name.Namespace;
            XElement   projectElement = GetProjectElement(projectFileName, ns, projectDocument);

            // Determine the project name and ensure the generated RudeBuild project has a ProjectName element.
            string   projectName = Path.GetFileNameWithoutExtension(projectFileName);
            XElement globalPropertyGroupElement = GetGlobalProjectPropertyGroupElement(projectFileName, ns, projectElement);
            XElement projectNameElement         = globalPropertyGroupElement.Element(ns + "ProjectName");

            if (projectNameElement == null)
            {
                globalPropertyGroupElement.Add(new XElement(ns + "ProjectName", projectName));
            }
            else
            {
                projectName = projectNameElement.Value;
            }

            var compileItemGroupElements    = GetCompileItemGroupElements(ns, projectElement);
            var mergableCppFileNames        = new List <string>();
            var mergableCppFileNameElements = new List <XElement>();

            foreach (var compileItemGroupElement in compileItemGroupElements)
            {
                mergableCppFileNameElements.AddRange(
                    from compileElement in compileItemGroupElement.Elements(ns + "ClCompile")
                    where IsMergableCppFileElement(projectConfig, ns, compileElement, "Include")
                    select compileElement);
            }
            mergableCppFileNames.AddRange(
                from compileElement in mergableCppFileNameElements
                select compileElement.Attribute("Include").Value);

            IList <string> allCppFileNames       = GetAllCppFileNames(ns, projectElement);
            IList <string> allIncludeFileNames   = GetAllIncludeFileNames(ns, projectElement);
            string         precompiledHeaderName = GetPrecompiledHeader(projectConfig, projectDocument, ns);
            var            projectInfo           = new ProjectInfo(solutionInfo, projectName, projectFileName, mergableCppFileNames, allCppFileNames, allIncludeFileNames, precompiledHeaderName);

            if (!performReadOnly)
            {
                var merger = new UnityFileMerger(_settings);
                merger.Process(projectInfo);

                foreach (XElement cppFileNameElement in mergableCppFileNameElements)
                {
                    string cppFileName = cppFileNameElement.Attribute("Include").Value;
                    if (merger.MergedCppFileNames.Contains(cppFileName))
                    {
                        AddExcludedFromBuild(ns, cppFileNameElement);
                    }
                }

                if (compileItemGroupElements.Count() > 0)
                {
                    compileItemGroupElements.First().Add(
                        from unityFileName in merger.UnityFilePaths
                        select new XElement(ns + "ClCompile", new XAttribute("Include", unityFileName)));
                }

                if (ShouldDisablePrecompiledHeaders(projectInfo))
                {
                    DisablePrecompiledHeaders(projectDocument, ns);
                }
                if (_settings.SolutionSettings.SetBigObjCompilerFlag)
                {
                    SetBigObjCompilerFlag(projectDocument, ns);
                }

                if (!string.IsNullOrEmpty(_settings.GlobalSettings.IntDirSuffix))
                {
                    SetIntDir(ns, projectElement, _settings.GlobalSettings.IntDirSuffix);
                }

                FixupProjectReferences(projectDocument, ns, _settings);

                ReadWriteFilters(projectFileName, projectConfig, merger);
            }

            return(projectInfo);
        }
Esempio n. 10
0
 public abstract ProjectInfo ReadWrite(string projectFileName, SolutionInfo solutionInfo, XDocument projectDocument, bool performReadOnly);