private void GatherSolution()
        {
            String solutionFile = "";

            try
            {
                solutionFile = ProjLibrary.GetFilesInDirectory(SolutionAbsolutePath, ".conf")[0];
            }
            catch
            {
                Console.WriteLine("Failed to find solution in '" + SolutionAbsolutePath + "' folder (verify .conf files)");
            }

            try
            {
                StreamReader fs = new StreamReader(solutionFile);
                solutionData = JsonConvert.DeserializeObject <SolutionStruct>(fs.ReadToEnd());

                Console.WriteLine("#################################### Begin generation for " + solutionData.Name + " ####################################");
            }
            catch
            {
                Console.WriteLine("Failed to parse solution config path : " + solutionFile);
            }
        }
        private void GatherProjects()
        {
            List <String> projectsFiles = ProjLibrary.GetFilesInDirectory(SolutionAbsolutePath, ".proj");

            Projects = new List <ProjectStruct>();

            foreach (String project in projectsFiles)
            {
                try
                {
                    StreamReader  fs          = new StreamReader(project);
                    ProjectStruct projectData = JsonConvert.DeserializeObject <ProjectStruct>(fs.ReadToEnd());

                    foreach (ProjectStruct Project in Projects)
                    {
                        if (Project.ProjectName == projectData.ProjectName)
                        {
                            throw new InvalidDataException("Duplicated project name : " + projectData.ProjectName);
                        }
                    }
                    projectData.ProjectFileAbsolutePath = Path.GetFullPath(project);
                    Projects.Add(projectData);
                    Console.WriteLine(" --- Importing project '" + projectData.ProjectName + "'");
                }
                catch (Exception error)
                {
                    Console.WriteLine("Failed to parse project " + project + " :\n" + error);
                }
            }
        }
Exemple #3
0
        private static void IncludeSourceFiles(ProjectStruct inProject)
        {
            ProjLibrary.BeginXmlCategory("ItemGroup");
            {
                foreach (String file in ProjLibrary.GetFilesInDirectory(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), ".h"))
                {
                    if (file.Substring(file.Length - 2, 2) == ".h")
                    {
                        ProjLibrary.AddXmlValue("ClInclude", "", "Include=\"" + Path.GetRelativePath(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), file) + "\"");
                    }
                }
            }
            ProjLibrary.EndXmlCategory("ItemGroup");

            ProjLibrary.BeginXmlCategory("ItemGroup");
            {
                foreach (String file in ProjLibrary.GetFilesInDirectory(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), ".cpp"))
                {
                    ProjLibrary.AddXmlValue("ClCompile", "", "Include=\"" + Path.GetRelativePath(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), file) + "\"");
                }
                foreach (String file in ProjLibrary.GetFilesInDirectory(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), ".c"))
                {
                    ProjLibrary.AddXmlValue("ClCompile", "", "Include=\"" + Path.GetRelativePath(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), file) + "\"");
                }
            }
            ProjLibrary.EndXmlCategory("ItemGroup");
        }
Exemple #4
0
        public static String BuildFilterString(ProjectStruct inProject)
        {
            List <String> Paths = new List <String>();

            ProjLibrary.BeginXmlEdition();
            ProjLibrary.BeginXmlCategory("Project", "DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"");
            {
                ProjLibrary.BeginXmlCategory("ItemGroup");
                {
                    foreach (String file in ProjLibrary.GetFilesInDirectory(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), ".h"))
                    {
                        String relativePath = Path.GetRelativePath(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), file);
                        ProjLibrary.BeginXmlCategory("ClInclude", "Include=" + "\"" + relativePath + "\"");
                        {
                            AddUniquePath(Path.GetDirectoryName(relativePath), ref Paths);
                            ProjLibrary.AddXmlValue("Filter", Path.GetDirectoryName(relativePath));
                        }
                        ProjLibrary.EndXmlCategory("ClInclude");
                    }
                }
                ProjLibrary.EndXmlCategory("ItemGroup");
                ProjLibrary.BeginXmlCategory("ItemGroup");
                {
                    foreach (String file in ProjLibrary.GetFilesInDirectory(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), ".cpp"))
                    {
                        String relativePath = Path.GetRelativePath(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), file);
                        ProjLibrary.BeginXmlCategory("ClCompile", "Include=" + "\"" + relativePath + "\"");
                        {
                            AddUniquePath(Path.GetDirectoryName(relativePath), ref Paths);
                            ProjLibrary.AddXmlValue("Filter", Path.GetDirectoryName(relativePath));
                        }
                        ProjLibrary.EndXmlCategory("ClCompile");
                    }
                }
                ProjLibrary.EndXmlCategory("ItemGroup");
                ProjLibrary.BeginXmlCategory("ItemGroup");
                {
                    foreach (String file in ProjLibrary.GetFilesInDirectory(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), ".c"))
                    {
                        String relativePath = Path.GetRelativePath(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), file);
                        ProjLibrary.BeginXmlCategory("ClCompile", "Include=" + "\"" + relativePath + "\"");
                        {
                            AddUniquePath(Path.GetDirectoryName(relativePath), ref Paths);
                            ProjLibrary.AddXmlValue("Filter", Path.GetDirectoryName(relativePath));
                        }
                        ProjLibrary.EndXmlCategory("ClCompile");
                    }
                }
                ProjLibrary.EndXmlCategory("ItemGroup");

                foreach (String dir in ProjLibrary.GetSubfoldersInDirectory(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath)))
                {
                    AddUniquePath(Path.GetDirectoryName(Path.GetRelativePath(Path.GetDirectoryName(inProject.ProjectFileAbsolutePath), dir)), ref Paths);
                }

                ProjLibrary.BeginXmlCategory("ItemGroup");
                {
                    foreach (String path in Paths)
                    {
                        ProjLibrary.BeginXmlCategory("Filter", "Include=" + "\"" + path + "\"");
                        {
                            ProjLibrary.AddXmlValue("UniqueIdentifier", "{" + path + "}");
                        }
                        ProjLibrary.EndXmlCategory("Filter");
                    }
                }
                ProjLibrary.EndXmlCategory("ItemGroup");
            }
            ProjLibrary.EndXmlCategory("Project");

            return(ProjLibrary.GetXmlString());
        }