Exemple #1
0
 /// <summary>
 /// Creates the builder
 /// </summary>
 /// <param name="referenceBuilderFactory">Interface to create new reference builder instances</param>
 /// <param name="sourceSetDependencyFactory">Interface to create new source set dependencies</param>
 /// <param name="project">The project for which the vcxproj file will be generated</param>
 /// <param name="suite">The suite the project belongs to </param>
 /// <param name="targetDir">The build target directory </param>
 /// <param name="generator">The vcxproj generator class to be used</param>
 public VcxprojBuilder(IReferenceBuilderFactory referenceBuilderFactory, ISourceSetDependencyFactory sourceSetDependencyFactory,
                       Project project, Suite suite, [TargetRoot] IFileSystemDirectory targetDir, VcxprojGenerator generator)
 {
     this.referenceBuilderFactory    = referenceBuilderFactory;
     this.sourceSetDependencyFactory = sourceSetDependencyFactory;
     this.project   = project;
     this.suite     = suite;
     this.targetDir = targetDir;
     this.generator = generator;
 }
Exemple #2
0
        private KeyValuePair <ProjectReference, List <ProjectReference> > GenerateSampleProject(String SampleName, String SamplePath)
        {
            var InlcudeDirectories = new List <String> {
                SamplePath
            };
            var SourceDirectories = new List <String> {
                SamplePath
            };
            var Libs              = new List <String> {
            };
            var Files             = SourceDirectories.SelectMany(d => GetFilesInDirectory(d)).ToList();
            var ProjectReferences = new List <ProjectReference> {
            };

            if (ModuleDependencies.ContainsKey(SampleName))
            {
                foreach (var ReferenceModule in GetAllModuleDependencies(SampleName, false))
                {
                    InlcudeDirectories.Add(Path.GetFullPath(Path.Combine(SamplePath, Path.Combine("..", Path.Combine("..", Path.Combine("modules", Path.Combine(ReferenceModule, "include")))))));
                    ProjectReferences.Add(new ProjectReference
                    {
                        Id         = GetIdForProject(ReferenceModule),
                        Name       = ReferenceModule,
                        VirtualDir = "modules/" + ReferenceModule,
                        FilePath   = Path.Combine(BuildDirectory, Path.Combine("projects", GetProjectFileName(ReferenceModule)))
                    });
                }
            }

            var p = new Project
            {
                Name           = SampleName,
                Configurations = (new List <Configuration>
                {
                    new Configuration
                    {
                        TargetType = TargetType.Executable,
                        IncludeDirectories = InlcudeDirectories,
                        Libs = Libs,
                        Files = Files
                    },
                    new Configuration
                    {
                        TargetOperatingSystem = OperatingSystemType.iOS,
                        BundleIdentifier = SolutionName + "." + SampleName
                    }
                }).Concat(GetCommonConfigurations()).ToList()
            };

            if (Toolchain == ToolchainType.Windows_VisualC)
            {
                var VcxprojTemplateText       = Resource.GetResourceText(@"Templates\vc15\Default.vcxproj");
                var VcxprojFilterTemplateText = Resource.GetResourceText(@"Templates\vc15\Default.vcxproj.filters");
                var g = new VcxprojGenerator(p, GetIdForProject(SampleName), ProjectReferences, SamplePath, Path.Combine(BuildDirectory, "projects"), VcxprojTemplateText, VcxprojFilterTemplateText, BuildingOperatingSystem, TargetOperationSystem);
                g.Generate(EnableRebuild);
            }
            else if (Toolchain == ToolchainType.Mac_XCode)
            {
                var PbxprojTemplateText = Resource.GetResourceText(@"Templates\xcode9\Default.xcodeproj\project.pbxproj");
                var g = new PbxprojGenerator(p, ProjectReferences, SamplePath, Path.Combine(BuildDirectory, "projects"), PbxprojTemplateText, BuildingOperatingSystem, TargetOperationSystem);
                g.Generate(EnableRebuild);
            }
            else if (Toolchain == ToolchainType.CMake)
            {
                var g = new CMakeProjectGenerator(p, ProjectReferences, SamplePath, Path.Combine(BuildDirectory, "projects"), Toolchain, Compiler, BuildingOperatingSystem, TargetOperationSystem);
                g.Generate(EnableRebuild);
            }
            else
            {
                throw new NotSupportedException();
            }
            return(new KeyValuePair <ProjectReference, List <ProjectReference> >(new ProjectReference
            {
                Id = GetIdForProject(SampleName),
                Name = SampleName,
                VirtualDir = "samples",
                FilePath = Path.Combine(BuildDirectory, Path.Combine("projects", GetProjectFileName(SampleName)))
            }, ProjectReferences));
        }
Exemple #3
0
        private KeyValuePair <ProjectReference, List <ProjectReference> > GenerateTestProject(String ModuleName, String ModulePath, String TestName, Cpp.File TestFile)
        {
            var InlcudeDirectories = new List <String> {
            };
            var SourceDirectories  = new List <String> {
                Path.Combine(ModulePath, "include"), Path.Combine(ModulePath, "src")
            };
            var Libs  = new List <String> {
            };
            var Files = new List <Cpp.File> {
                TestFile
            };
            var ProjectReferences = new List <ProjectReference> {
            };

            var RelativeIncludeDirectories = new List <String>
            {
                "include",
                "src"
            };

            foreach (var RelativeIncludeDirectory in RelativeIncludeDirectories)
            {
                InlcudeDirectories.Add(Path.GetFullPath(Path.Combine(ModulePath, RelativeIncludeDirectory)));
            }
            foreach (var ReferenceModule in GetAllModuleDependencies(ModuleName, true))
            {
                InlcudeDirectories.Add(Path.GetFullPath(Path.Combine(ModulePath, Path.Combine("..", Path.Combine(ReferenceModule, "include")))));
                ProjectReferences.Add(new ProjectReference
                {
                    Id         = GetIdForProject(ReferenceModule),
                    Name       = ReferenceModule,
                    VirtualDir = "modules/" + ReferenceModule,
                    FilePath   = Path.Combine(BuildDirectory, Path.Combine("projects", GetProjectFileName(ReferenceModule)))
                });
            }

            var p = new Project
            {
                Name           = TestName,
                Configurations = (new List <Configuration>
                {
                    new Configuration
                    {
                        TargetType = TargetType.Executable,
                        IncludeDirectories = InlcudeDirectories,
                        Libs = Libs,
                        Files = Files
                    },
                }).Concat(GetCommonConfigurations()).ToList()
            };

            if (Toolchain == ToolchainType.Windows_VisualC)
            {
                var VcxprojTemplateText       = Resource.GetResourceText(@"Templates\vc15\Default.vcxproj");
                var VcxprojFilterTemplateText = Resource.GetResourceText(@"Templates\vc15\Default.vcxproj.filters");
                var g = new VcxprojGenerator(p, GetIdForProject(TestName), ProjectReferences, Path.GetDirectoryName(TestFile.Path), Path.Combine(BuildDirectory, "projects"), VcxprojTemplateText, VcxprojFilterTemplateText, BuildingOperatingSystem, TargetOperationSystem);
                g.Generate(EnableRebuild);
            }
            else if (Toolchain == ToolchainType.Mac_XCode)
            {
                var PbxprojTemplateText = Resource.GetResourceText(@"Templates\xcode9\Default.xcodeproj\project.pbxproj");
                var g = new PbxprojGenerator(p, ProjectReferences, Path.GetDirectoryName(TestFile.Path), Path.Combine(BuildDirectory, "projects"), PbxprojTemplateText, BuildingOperatingSystem, TargetOperationSystem);
                g.Generate(EnableRebuild);
            }
            else if (Toolchain == ToolchainType.CMake)
            {
                var g = new CMakeProjectGenerator(p, ProjectReferences, Path.GetDirectoryName(TestFile.Path), Path.Combine(BuildDirectory, "projects"), Toolchain, Compiler, BuildingOperatingSystem, TargetOperationSystem);
                g.Generate(EnableRebuild);
            }
            else
            {
                throw new NotSupportedException();
            }
            return(new KeyValuePair <ProjectReference, List <ProjectReference> >(new ProjectReference
            {
                Id = GetIdForProject(TestName),
                Name = TestName,
                VirtualDir = "modules/" + ModuleName,
                FilePath = Path.Combine(BuildDirectory, Path.Combine("projects", GetProjectFileName(TestName)))
            }, ProjectReferences));
        }