Beispiel #1
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context"> </param>
        /// <returns>Returns a set of generated files, in suite relative paths</returns>
        public override ISet <TargetRelativePath> Run(IBuildContext context)
        {
            var          vcxprojPath   = project.Name + ".vcxproj";
            const string csversionPath = "version.cpp";

            var csversion = project.GetVersionSupport() ? project.RootDirectory.CreateTextFile(csversionPath) : null;

            using (var fsproj = project.RootDirectory.GetChildDirectory("cpp").CreateTextFile(vcxprojPath))
            {
                var references = new HashSet <TargetRelativePath>();
                foreach (var refBuilder in context.GetDependencies(this).OfType <IReferenceBuilder>().Where(r => r.Reference.Type == ReferenceType.Build))
                {
                    var builderResults = context.GetResults(refBuilder);
                    references.UnionWith(builderResults);
                }

                generator.Generate(project, references, fsproj, csversion, csversionPath);
            }

            if (csversion != null)
            {
                csversion.Close();
                csversion.Dispose();
            }

            return(new HashSet <TargetRelativePath>(
                       new[]
            {
                new TargetRelativePath(String.Empty,
                                       suite.SuiteRoot.GetRelativePathFrom(targetDir,
                                                                           Path.Combine(suite.SuiteRoot.GetRelativePath(project.RootDirectory), "cpp", vcxprojPath))),
            }));
        }
Beispiel #2
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context"> </param>
        /// <returns>Returns a set of generated files, in suite relative paths</returns>
        public ISet <TargetRelativePath> Run(IBuildContext context)
        {
            var vcxprojPath = project.Name + ".vcxproj";

            using (var fsproj = project.RootDirectory.GetChildDirectory("cpp").CreateTextFile(vcxprojPath))
            {
                var references = new HashSet <TargetRelativePath>();
                foreach (var refBuilder in context.GetDependencies(this).OfType <IReferenceBuilder>().Where(r => r.Reference.Type == ReferenceType.Build))
                {
                    var builderResults = context.GetResults(refBuilder);
                    references.UnionWith(builderResults);
                }

                generator.Generate(project, references, fsproj);
            }

            return(new HashSet <TargetRelativePath>(
                       new[]
            {
                new TargetRelativePath(String.Empty,
                                       suite.SuiteRoot.GetRelativePathFrom(targetDir,
                                                                           Path.Combine(suite.SuiteRoot.GetRelativePath(project.RootDirectory), "cpp", vcxprojPath))),
            }));
        }
Beispiel #3
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));
        }
Beispiel #4
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));
        }