public List <String> GetLibraries(String projectName, String configuration, String plateform) { List <String> outIncludes = new List <String>(); ProjectStruct projData = GetProject(projectName); if (projData.Dependencies != null) { foreach (String dependency in projData.Dependencies) { ProjectStruct SubProject = GetProject(dependency); if (SubProject.ProjectType == "StaticLibrary") { outIncludes.Add(SolutionAbsolutePath + "\\" + solutionData.LibraryOutputFolder + "\\" + configuration + "\\" + plateform + "\\" + SubProject.ProjectName + "\\" + SubProject.ProjectName + ".lib"); foreach (String subLibrary in GetLibraries(SubProject.ProjectName, configuration, plateform)) { outIncludes.Add(subLibrary); } } } } if (projData.AdditionalLibraries != null) { foreach (String dependency in projData.AdditionalLibraries) { outIncludes.Add(SolutionAbsolutePath + "\\" + dependency); } } return(outIncludes); }
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); } } }
public List <String> GetIncludes(String ProjectName) { List <String> outIncludes = new List <String>(); ProjectStruct projData = GetProject(ProjectName); outIncludes.Add(Path.GetDirectoryName(projData.ProjectFileAbsolutePath) + "\\" + projData.IncludesPath); if (projData.Dependencies != null) { foreach (String dependency in projData.Dependencies) { foreach (String subInclude in GetIncludes(dependency)) { outIncludes.Add(subInclude); } } } if (projData.AdditionalIncludes != null) { foreach (String include in projData.AdditionalIncludes) { outIncludes.Add(SolutionAbsolutePath + "\\" + include); } } return(outIncludes); }
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"); }
private static void SetConfigurationParameters(ProjectStruct inProject) { SolutionStruct solutionData = SolutionAnalyzer.Get().solutionData; for (int i = 0; i < 4; ++i) { String Configuration = (i > 1) ? "Debug" : "Release"; String Plateform = (i % 2 == 0) ? "Win32" : "x64"; ProjLibrary.BeginXmlCategory("PropertyGroup", "Condition=\"'$(Configuration)|$(Platform)'=='" + Configuration + "|" + Plateform + "'\" Label=\"Configuration\""); { if (inProject.ProjectType == "StaticLibrary") { ProjLibrary.AddXmlValue("ConfigurationType", "StaticLibrary"); } if (Configuration == "Debug") { ProjLibrary.AddXmlValue("UseDebugLibraries", "true"); } if (Configuration != "Debug") { ProjLibrary.AddXmlValue("UseDebugLibraries", "false"); } ProjLibrary.AddXmlValue("PlatformToolset", solutionData.PlatformToolset); ProjLibrary.AddXmlValue("WholeProgramOptimization", "false"); ProjLibrary.AddXmlValue("CharacterSet", "MultiByte"); ProjLibrary.AddXmlValue("CharacterSet", "MultiByte"); } ProjLibrary.EndXmlCategory("PropertyGroup"); } }
private static void SetProjectConfigs(ProjectStruct inProject) { SolutionStruct solutionData = SolutionAnalyzer.Get().solutionData; ProjLibrary.BeginXmlCategory("PropertyGroup", "Label =\"Globals\""); { ProjLibrary.AddXmlValue("VCProjectVersion", solutionData.ToolVersion); ProjLibrary.AddXmlValue("ProjectGuid", inProject.ProjectName); ProjLibrary.AddXmlValue("RootNamespace", inProject.ProjectName); ProjLibrary.AddXmlValue("WindowsTargetPlatformVersion", solutionData.WindowTargetPlateformVersion); } ProjLibrary.EndXmlCategory("PropertyGroup"); }
private static void SetPropertyPath(ProjectStruct inProject) { SolutionStruct solutionData = SolutionAnalyzer.Get().solutionData; for (int i = 0; i < 4; ++i) { String Configuration = (i > 1) ? "Debug" : "Release"; String Plateform = (i % 2 == 0) ? "Win32" : "x64"; ProjLibrary.BeginXmlCategory("PropertyGroup", "Condition=\"'$(Configuration)|$(Platform)'=='" + Configuration + "|" + Plateform + "'\""); { ProjLibrary.AddXmlValue("IncludePath", SolutionAnalyzer.StackStringList(SolutionAnalyzer.Get().GetIncludes(inProject.ProjectName)) + "$(IncludePath)"); ProjLibrary.AddXmlValue("LibraryPath", "$(SolutionDir)" + solutionData.LibraryOutputFolder + "\\" + Configuration + "\\" + Plateform + "\\" + inProject.ProjectName + ";$(LibraryPath)"); ProjLibrary.AddXmlValue("OutDir", "$(SolutionDir)" + (inProject.ProjectType == "StaticLibrary" ? solutionData.LibraryOutputFolder : solutionData.ExecutableOutputFolder) + "\\" + Configuration + "\\" + Plateform + "\\" + inProject.ProjectName + "\\"); ProjLibrary.AddXmlValue("IntDir", "$(SolutionDir)" + solutionData.BinariesFolder + "\\" + Configuration + "\\" + Plateform + "\\" + inProject.ProjectName + "\\"); } ProjLibrary.EndXmlCategory("PropertyGroup"); } }
public static String BuildVcxprojString(ProjectStruct inProject) { ProjLibrary.BeginXmlEdition(); ProjLibrary.BeginXmlCategory("Project", "DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\""); { AddConfigurations(); SetProjectConfigs(inProject); ProjLibrary.AddXmlValue("Import", "", "Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\""); SetConfigurationParameters(inProject); ProjLibrary.AddXmlValue("Import", "", "Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\""); ImportLabels(); SetPropertyPath(inProject); SetCompilationValues(inProject); IncludeSourceFiles(inProject); ProjLibrary.AddXmlValue("Import", "", "Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""); ProjLibrary.AddXmlValue("ImportGroup", "", "Label=\"ExtensionTargets\""); } ProjLibrary.EndXmlCategory("Project"); return(ProjLibrary.GetXmlString()); }
public static String BuildUserFileString(ProjectStruct inProject) { SolutionStruct solutionData = SolutionAnalyzer.Get().solutionData; ProjLibrary.BeginXmlEdition(); ProjLibrary.BeginXmlCategory("Project", "ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\""); { for (int i = 0; i < 4; ++i) { String Configuration = (i > 1) ? "Debug" : "Release"; String Plateform = (i % 2 == 0) ? "Win32" : "x64"; ProjLibrary.BeginXmlCategory("PropertyGroup", "Condition=\"'$(Configuration)|$(Platform)'=='" + Configuration + "|" + Plateform + "'\" Label=\"Configuration\""); { ProjLibrary.AddXmlValue("LocalDebuggerWorkingDirectory", "$(SolutionDir)" + solutionData.ExecutableOutputFolder + "\\" + Configuration + "\\" + Plateform + "\\" + inProject.ProjectName + "\\"); ProjLibrary.AddXmlValue("DebuggerFlavor", "WindowsLocalDebugger"); } ProjLibrary.EndXmlCategory("PropertyGroup"); } } ProjLibrary.EndXmlCategory("Project"); return(ProjLibrary.GetXmlString()); }
private static void SetCompilationValues(ProjectStruct inProject) { SolutionStruct solutionData = SolutionAnalyzer.Get().solutionData; for (int i = 0; i < 4; ++i) { String Configuration = (i > 1) ? "Debug" : "Release"; String Plateform = (i % 2 == 0) ? "Win32" : "x64"; ProjLibrary.BeginXmlCategory("ItemDefinitionGroup", "Condition=\"'$(Configuration)|$(Platform)' == '" + Configuration + "|" + Plateform + "'\""); { ProjLibrary.BeginXmlCategory("ClCompile"); { ProjLibrary.AddXmlValue("WarningLevel", "Level3"); ProjLibrary.AddXmlValue("Optimization", "Disabled"); ProjLibrary.AddXmlValue("SDLCheck", "true"); ProjLibrary.AddXmlValue("ConformanceMode", "true"); ProjLibrary.AddXmlValue("RuntimeLibrary", "MultiThreadedDebugDLL"); ProjLibrary.AddXmlValue("MultiProcessorCompilation", "true"); ProjLibrary.AddXmlValue("FavorSizeOrSpeed", "Speed"); } ProjLibrary.EndXmlCategory("ClCompile"); ProjLibrary.BeginXmlCategory("Link"); { try { ProjLibrary.AddXmlValue("AdditionalDependencies", SolutionAnalyzer.StackStringList(SolutionAnalyzer.Get().GetLibraries(inProject.ProjectName, Configuration, Plateform)) + "%(AdditionalDependencies)"); } catch (Exception e) { Console.WriteLine(e.Message + "\nBuild libraries then rebuild solution files before compiling executables"); } } ProjLibrary.EndXmlCategory("Link"); } ProjLibrary.EndXmlCategory("ItemDefinitionGroup"); } }
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()); }