Ejemplo n.º 1
0
        public void CheckForModifications()
        {
            var xdoc = XDocument.Load(VcxprojFile.FullName);
            var ns = xdoc.Root.GetDefaultNamespace();
            var includes = xdoc.Root.Descendants(ns + "ItemGroup").Elements(ns + "ClInclude").Select(e => e.Attribute("Include").Value).ToList();
            var sources = xdoc.Root.Descendants(ns + "ItemGroup").Elements(ns + "ClCompile").Select(e => e.Attribute("Include").Value).ToList();

            var removedIncludes = _includes.Except(includes).ToList();
            var addedIncludes = includes.Except(_includes).ToList();

            var removedSources = _sources.Except(sources).ToList();
            var addedSources = sources.Except(_sources).ToList();

            if (addedIncludes.Any())
            {
                Console.WriteLine("header files added!");
                var doc = GypDocument.Load(GypFile);
                var si = doc.Root.Element("targets").Children.First().Element("sources").Children.Select(c => c.Value).Select(Unexpand).ToList();

                // Ugle decision here. Check the name of the variable. Better would to check which of the variables has most .h files or .cpp files
                var headerVariable = si.First(sourceVariable => sourceVariable.Contains("header"));

                // stream edit each gypi and and the new headers to the variable
                var gypis = doc.Root.Children.First().Children.Select(c => c.Value).ToList();
                foreach (var gypi in gypis)
                {
                    var ms = new MemoryStream();
                    var gypiPath = Path.Combine(GypFile.Directory.FullName, gypi);

                    // stream-edit the gypi for non intrusive edits
                    var editor = new GypStreamEditor(gypiPath, new StreamWriter(ms));
                    editor.AddStringToArray(headerVariable, addedIncludes);
                    var wasModified = editor.Go();

                    if (wasModified)
                    {
                        // ovewrite the old gypi file
                        File.WriteAllBytes(gypiPath, ms.ToArray());

                        // Update
                        foreach (var addedInclude in addedIncludes)
                        {
                            _includes.Add(addedInclude);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void z()
 {
     var streamEditor = new GypStreamEditor(@"F:\src\sdk\rebtel_sdk\trunk\src\main.gypi", System.Console.Out);
     streamEditor.AddStringToArray("rebrtc_header_files", new [] {"foo.h"});
     streamEditor.Go();
 }
Ejemplo n.º 3
0
 public void numbers()
 {
     var streamEditor = new GypStreamEditor(@"F:\src\sdk\rebtel_sdk\trunk\gyp\common.gypi", System.Console.Out);
     streamEditor.Go();
 }