Beispiel #1
0
        private void AddExtraIncludeFilter(StringBuilder sb, Header file)
        {
            var filename = file.Name;
            var action   = OccSource.GetAction(filename); // In filters file for extras

            sb.AppendLine($"    <{action} Include=\"{filename}\">");
            sb.AppendLine($"      <Filter>{sourceFiles}\\Extra\\{file.JustFolderName}</Filter>");
            sb.AppendLine($"    </{action}>");
        }
Beispiel #2
0
        private void AddInclude(StringBuilder sb, OccPackage package, string file)
        {
            var action   = OccSource.GetAction(file); // In filters file
            var filename = Path.Combine(package.SourceRelativeFolder, file);

            sb.AppendLine($"    <{action} Include=\"{filename}\">");
            sb.AppendLine($"      <Filter>{sourceFiles}\\{package.Lib.Name}\\{package.Name}</Filter>");
            sb.AppendLine($"    </{action}>");
        }
Beispiel #3
0
 public OccLib(OccSource source)
 {
     _source = source;
 }
Beispiel #4
0
        public bool MakeProject()
        {
            bool sourcetagfound     = false;
            var  packageFoldersList = string.Join(";", packageFolders.ToArray());
            var  replaceAdditional  = $"      <AdditionalIncludeDirectories>{packageFoldersList};$(CSF_OPT_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>";
            var  reIncludeAction    = new Regex("<(?<action>[\\S]+) *Include=\"(?<file>[^\"]+?)(\\.(?<ext>[\\w]+))?\" */>", RegexOptions.Compiled);
            var  itemGroup          = new Regex(" *<ItemGroup *[^>]*>");

            using (var newProject = csProjNew.CreateText())
                using (var read = csProj.OpenText())
                {
                    string conditionalBuffer = "";
                    string line;
                    while ((line = read.ReadLine()) != null)
                    {
                        // manage conditional buffer
                        //
                        if (itemGroup.IsMatch(line))
                        {
                            conditionalBuffer = line;
                            continue;
                        }

                        if (conditionalBuffer != "")
                        {
                            if (line.Contains("</ItemGroup>"))
                            {
                                conditionalBuffer = "";
                                continue;
                            }
                        }

                        // include actions
                        //
                        var t = reIncludeAction.Match(line);
                        if (t.Success)
                        {
                            if (t.Groups["file"].Value.Contains("OCC\\src"))
                            {
                                // skip line
                                continue;
                            }
                        }

                        // any skipped line before this
                        //
                        if (conditionalBuffer != "")
                        {
                            newProject.WriteLine(conditionalBuffer);
                            conditionalBuffer = "";
                        }

                        // AdditionalIncludeDirectories
                        if (line.Contains("<AdditionalIncludeDirectories"))
                        {
                            newProject.WriteLine(replaceAdditional);
                            continue;
                        }

                        // populate occ source
                        // <!-- occSource -->
                        if (line.Contains("<!-- occSource -->"))
                        {
                            sourcetagfound = true;
                            // populate source
                            foreach (var package in AllPackages())
                            {
                                newProject.WriteLine($"  <ItemGroup Label=\"{package.Name}\">");

                                foreach (var file in package.FileNames())
                                {
                                    var action   = OccSource.GetAction(file); // action for project file
                                    var filename = Path.Combine(package.SourceRelativeFolder, file);
                                    newProject.WriteLine($"    <{action} Include=\"{filename}\" />");
                                }
                                newProject.WriteLine($"  </ItemGroup>");
                            }
                            if (_extraHeaders.Any())
                            {
                                newProject.WriteLine($"  <ItemGroup Label=\"Extra\">");
                                foreach (var extraHeader in _extraHeaders)
                                {
                                    var action = OccSource.GetAction(extraHeader.Name); // action for extra header in project file
                                    newProject.WriteLine($"    <{action} Include=\"{extraHeader.Name}\" />");
                                }
                                newProject.WriteLine($"  </ItemGroup>");
                            }
                        }
                        newProject.WriteLine(line);
                    }
                }
            return(sourcetagfound);
        }
Beispiel #5
0
 public OccPackage(OccSource source)
 {
     _source = source;
 }