Пример #1
0
            private static void ProcessProjectSubdirectory(Project TheProject, string CurrentSourceFilesDirectory = null)
            {
                if (CurrentSourceFilesDirectory == null)
                    CurrentSourceFilesDirectory = TheProject.Location;
                ProcessSourceFilesInDirectory(TheProject, CurrentSourceFilesDirectory);

                foreach (var CurrentSubdirectory in Directory.EnumerateDirectories(CurrentSourceFilesDirectory))
                {
                    /**/ if (File.Exists(Path.Combine(CurrentSubdirectory, ".gdproj.cs")) && (!Target.IsMonolithicBuild()))
                    {   // This directory contains separate project.
                        ProcessProjectDirectory(CurrentSourceFilesDirectory);
                        continue;
                    }

                    string ProjectSubdirectoryName = Path.GetFileName(CurrentSubdirectory);
                    if (ProjectSubdirectoryName[0] == '_')
                    {   // This is a specific service directory.
                        switch(ProjectSubdirectoryName)
                        {
                            case "_Build": continue;
                            case "_DLLResources": goto ProcessProjectSubdirectoryLabel;
                            case "_Dependencies": DependenciesResolver.ProcessDirectory(TheProject, CurrentSubdirectory); continue;
                            default:
                                throw new ProjectException(string.Format("Unparsed service directory '{0}' is located in '{1}'", ProjectSubdirectoryName, CurrentSubdirectory));
                        }
                    }

                ProcessProjectSubdirectoryLabel:
                    ProcessProjectSubdirectory(TheProject, CurrentSubdirectory);
                }
            }
 public static void ProcessDirectory(Project TheProject, string DependenciesDirectory)
 {
     foreach (var DependencyDirectory in Directory.EnumerateDirectories(DependenciesDirectory))
     {
         TheProject.Dependencies.Add(new Dependency(DependencyDirectory));
     }
 }
Пример #3
0
        private static void GeneratesFiltersFile(Project TheProject)
        {
            using (XmlTextWriter FiltersConfig = new XmlTextWriter(string.Format("{0}/_Build/{1}.vcxproj.filters", TheProject.Location, TheProject.Name), null))
            {
                FiltersConfig.Formatting = Formatting.Indented;
                FiltersConfig.Indentation = 4;
                FiltersConfig.WriteStartDocument();
                FiltersConfig.WriteComment(Copyright);
                FiltersConfig.WriteStartElement("Project", MSBuild2003Namespace);
                FiltersConfig.WriteAttributeString("ToolsVersion", "4.0");

                FiltersConfig.WriteStartElement("ItemGroup");
                foreach (var Folder in TheProject.Folders)
                {   // Generating new filers
                    FiltersConfig.WriteStartElement("Filter");
                    FiltersConfig.WriteAttributeString("Include", Folder.Replace('/', '\\'));
                    FiltersConfig.WriteElementString("UniqueIdentifier", string.Format("{{{0}}}", Guid.NewGuid().ToString()));
                    FiltersConfig.WriteEndElement();
                }
                FiltersConfig.WriteEndElement();

                FiltersConfig.WriteStartElement("ItemGroup");
                foreach (var SourceFile in TheProject.SourceFiles)
                {   // Generating new filers
                    string FilterName = SourceFile.RelativeFileFolder;
                    CreateElementBySourceFileType(FiltersConfig, SourceFile.FileType);
                    FiltersConfig.WriteAttributeString("Include", SourceFile.AbsoluteFilePath.Replace('/', '\\'));
                    if (!string.IsNullOrEmpty(FilterName))
                        FiltersConfig.WriteElementString("Filter", FilterName.Replace('/', '\\'));
                    FiltersConfig.WriteEndElement();
                }
                FiltersConfig.WriteEndElement();

                FiltersConfig.WriteEndElement();
                FiltersConfig.WriteEndDocument();
            }
        }
Пример #4
0
            private static void ProcessSourceFilesInDirectory(Project TheProject, string CurrentSourceFilesDirectory)
            {
                Uri ProjectRootDirectoryUri = new Uri(TheProject.Location);
                string ProjectDirectoryName = Path.GetFileName(TheProject.Location);
                string FolderRelativePath = ProjectRootDirectoryUri.MakeRelativeUri(new Uri(CurrentSourceFilesDirectory)).ToString();
                if (!string.IsNullOrEmpty(FolderRelativePath))
                {
                    FolderRelativePath = FolderRelativePath.Substring(ProjectDirectoryName.Length);
                    if (!string.IsNullOrEmpty(FolderRelativePath))
                    {
                        FolderRelativePath = FolderRelativePath.Remove(0, 1);
                        TheProject._Folders.Add(FolderRelativePath);
                    }
                }

                if (File.Exists(Path.Combine(CurrentSourceFilesDirectory, ".gdexclude")))
                {   // This directory is excluded from build.
                    string ExcludeMarkAbsoluteFilePath = Path.Combine(CurrentSourceFilesDirectory, ".gdexclude");
                    TheProject._SourceFiles.Add(new SourceFile(SourceFileType.SupportFile, ExcludeMarkAbsoluteFilePath, FolderRelativePath));
                    TheProject._Checksumm += ExcludeMarkAbsoluteFilePath.GetHashCode();
                    return;
                }

                foreach (var SourceAbsoluteFilePath in Directory.EnumerateFiles(CurrentSourceFilesDirectory))
                {
                    string SourceFileName = Path.GetFileNameWithoutExtension(SourceAbsoluteFilePath);
                    string SourceFileExtension = Path.GetExtension(SourceAbsoluteFilePath);
                    if (string.IsNullOrEmpty(SourceFileExtension) || string.IsNullOrEmpty(SourceFileName))
                        continue;

                    SourceFileType Type;
                    switch (SourceFileExtension)
                    {
                        case ".c":
                        case ".cc":
                        case ".cpp":
                        case ".cxx":
                            Type = SourceFileType.SourceCode;
                            break;

                        case ".h":
                        case ".hh":
                        case ".hpp":
                        case ".hxx":
                            Type = SourceFileType.HeaderFile;
                            break;

                        case ".inl":
                            Type = SourceFileType.InlineImpl;
                            break;

                        case ".natvis":
                            if (Target.IsWinAPIPlatform())
                            {   // NATive VISualizer Visual Studio file.
                                Type = SourceFileType.SupportFile;
                                break;
                            }

                            continue;

                        case ".rc":
                            if (Target.IsWinAPIPlatform())
                            {   // We support .RC files only on windows platforms.
                                Type = SourceFileType.ResourceScript;
                                break;
                            }

                            Type = SourceFileType.SupportFile;
                            break;

                        case ".m":
                        case ".mm":
                        case ".swift":
                            if (Target.IsCocoaPlatform())
                            {   // We support Objective-C files only on Cocoa platforms.
                                Type = SourceFileType.SourceCode;
                                break;
                            }

                            Type = SourceFileType.SupportFile;
                            break;

                        default:
                            ConsoleOutput.WriteLine(SourceAbsoluteFilePath, "warning: skipping file '{0}' with unknown extension '{1}'", SourceAbsoluteFilePath, SourceFileExtension);
                            continue;
                    }

                    TheProject._SourceFiles.Add(new SourceFile(Type, SourceAbsoluteFilePath, FolderRelativePath));
                    TheProject._Checksumm += SourceAbsoluteFilePath.GetHashCode();
                }
            }
Пример #5
0
 public override void GenerateProject(Project TheProject)
 {
     GeneratesFiltersFile(TheProject);
     GeneratesProjectFile(TheProject);
 }
Пример #6
0
        private static void GeneratesProjectFile(Project TheProject)
        {
            string Platform = GetPlatformString();
            using (XmlTextWriter ProjectConfig = new XmlTextWriter(string.Format("{0}/_Build/{1}.vcxproj", TheProject.Location, TheProject.Name), null))
            {
                ProjectConfig.Formatting = Formatting.Indented;
                ProjectConfig.Indentation = 4;
                ProjectConfig.WriteStartDocument();
                ProjectConfig.WriteComment(Copyright);
                ProjectConfig.WriteStartElement("Project", MSBuild2003Namespace);
                ProjectConfig.WriteAttributeString("ToolsVersion", "14.0");
                ProjectConfig.WriteAttributeString("DefaultTargets", "Build");

                ProjectConfig.WriteStartElement("ItemGroup");
                ProjectConfig.WriteAttributeString("Label", "ProjectConfigurations");
                foreach (var Configuration in Configurations)
                {
                    ProjectConfig.WriteStartElement("ProjectConfiguration");
                    ProjectConfig.WriteAttributeString("Include", new StringBuilder(Configuration.ToString()).Append('|').Append(Platform).ToString());
                    ProjectConfig.WriteElementString("Configuration", Configuration.ToString());
                    ProjectConfig.WriteElementString("Platform", Platform);
                    ProjectConfig.WriteEndElement();
                }
                ProjectConfig.WriteEndElement();

                ProjectConfig.WriteStartElement("ItemGroup");
                foreach (var SourceFile in TheProject.SourceFiles)
                {
                    CreateElementBySourceFileType(ProjectConfig, SourceFile.FileType);
                    ProjectConfig.WriteAttributeString("Include", SourceFile.AbsoluteFilePath.Replace('/', '\\'));
                    ProjectConfig.WriteEndElement();
                }
                ProjectConfig.WriteEndElement();

                ProjectConfig.WriteStartElement("PropertyGroup");
                ProjectConfig.WriteAttributeString("Label", "Globals");
                ProjectConfig.WriteElementString("ProjectGuid", string.Format("{{{0}}}", Guid.NewGuid().ToString().ToUpper()));
                ProjectConfig.WriteElementString("RootNamespace", TheProject.Name);
                ProjectConfig.WriteEndElement();

                ProjectConfig.WriteStartElement("Import");
                ProjectConfig.WriteAttributeString("Project", @"$(VCTargetsPath)\Microsoft.Cpp.Default.props");
                ProjectConfig.WriteEndElement();

                // Global Project properties:
                foreach (var Configuration in Configurations)
                {
                    ProjectConfig.WriteStartElement("PropertyGroup");
                    ProjectConfig.WriteAttributeString("Condition", GenerateCondition(Configuration));
                    ProjectConfig.WriteAttributeString("Label", "Configuration");
                    ProjectConfig.WriteElementString("ConfigurationType", TheProject.BuildType.ToString());
                    ProjectConfig.WriteElementString("PlatformToolset", "CTP_Nov2013");
                    ProjectConfig.WriteElementString("CharacterSet", "MultiByte");
                    ProjectConfig.WriteEndElement();
                }

                ProjectConfig.WriteStartElement("Import");
                ProjectConfig.WriteAttributeString("Project", @"$(VCTargetsPath)\Microsoft.Cpp.props");
                ProjectConfig.WriteEndElement();

                // Default property values.
                foreach (var Configuration in Configurations)
                {
                    ProjectConfig.WriteStartElement("ImportGroup");
                    ProjectConfig.WriteAttributeString("Condition", GenerateCondition(Configuration));
                    ProjectConfig.WriteAttributeString("Label", "PropertySheets");
                    ProjectConfig.WriteStartElement("Import");
                    ProjectConfig.WriteAttributeString("Project", @"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props");
                    ProjectConfig.WriteAttributeString("Condition", @"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')");
                    ProjectConfig.WriteAttributeString("Label",  "LocalAppDataPlatform");
                    ProjectConfig.WriteEndElement();
                    ProjectConfig.WriteEndElement();
                }

                // Configurations
                // Strange "UserMacros" node.
                ProjectConfig.WriteStartElement("PropertyGroup");
                ProjectConfig.WriteAttributeString("Label", "UserMacros");
                ProjectConfig.WriteEndElement();

                // Visual studio additional paths.
                foreach (var Configuration in Configurations)
                {
                    ProjectConfig.WriteStartElement("PropertyGroup");
                    ProjectConfig.WriteAttributeString("Condition", GenerateCondition(Configuration));
                    ProjectConfig.WriteElementString("TargetName", TheProject.Name + ((Configuration == TargetConfiguration.Debug) ? ".Debug" : ""));
                    ProjectConfig.WriteElementString("OutDir", TheProject.BuildType == ProjectBuildType.StaticLibrary ? @"$(GODDAMN_SDK)lib\" : @"$(GODDAMN_SDK)bin\");

                    StringBuilder IncludePathes = new StringBuilder();
                    foreach (var Dependency in TheProject.Dependencies)
                        IncludePathes.Append(Dependency.HeaderLocations).Append(Path.PathSeparator);
                    IncludePathes.Append(Path.Combine(BuildSystem.SDKPath, "source")).Append(Path.PathSeparator);
                    IncludePathes.Append(@"$(IncludePath)");
                    ProjectConfig.WriteElementString("IncludePath", IncludePathes.ToString());
                    ProjectConfig.WriteEndElement();
                }

                // C++ Compiler/Linker properties.
                foreach (var Configuration in Configurations)
                {
                    bool IsDebugConfiguration = (Configuration == TargetConfiguration.Debug);
                    ProjectConfig.WriteStartElement("ItemDefinitionGroup");
                    ProjectConfig.WriteAttributeString("Condition", GenerateCondition(Configuration));
                    ProjectConfig.WriteStartElement("ClCompile");
                    StringBuilder PreprocessorDefinitions = new StringBuilder();
                    foreach (var PreprocessorDefinition in TheProject.PreprocessorDefinitions)
                        PreprocessorDefinitions.Append(PreprocessorDefinition).Append(Path.PathSeparator);
                    PreprocessorDefinitions.Append(IsDebugConfiguration ? "_DEBUG" : "NDEBUG").Append(Path.PathSeparator);

                    if (TheProject.BuildType == ProjectBuildType.DynamicLibrary)
                        PreprocessorDefinitions.Append("_WINDLL").Append(Path.PathSeparator);

                    PreprocessorDefinitions.Append(@"%(PreprocessorDefinition)");
                    ProjectConfig.WriteElementString("PreprocessorDefinitions", PreprocessorDefinitions.ToString());

                    ProjectConfig.WriteElementString("Optimization", IsDebugConfiguration ? "Disabled" : "Full");
                    ProjectConfig.WriteElementString("WarningLevel", "Level4");
                    ProjectConfig.WriteElementString("TreatWarningAsError", "true");
                    ProjectConfig.WriteElementString("PrecompiledHeader", "NotUsing");
                    ProjectConfig.WriteElementString("CallingConvention", "FastCall");
                //  ProjectConfig.WriteElementString("ExceptionHandling", "false");
                    ProjectConfig.WriteElementString("RuntimeTypeInfo", "false");
                    ProjectConfig.WriteElementString("FavorSizeOrSpeed", "Speed");
                    ProjectConfig.WriteElementString("DisableSpecificWarnings", "4100;4127;4189;4201;4301;4458;4456;4505;4714");
                    ProjectConfig.WriteEndElement();

                    ProjectConfig.WriteStartElement("Link");
                    StringBuilder AdditionalDependencies = new StringBuilder();
                    foreach (var AdditionalDependency in TheProject.Dependencies)
                        AdditionalDependencies.Append(AdditionalDependency.ResolveDependency(Configuration)).Append(Path.PathSeparator);
                    AdditionalDependencies.Append(@"winmm.lib;imm32.lib;version.lib;");
                    AdditionalDependencies.Append(@"%(AdditionalDependencies)");
                    ProjectConfig.WriteElementString("AdditionalDependencies", AdditionalDependencies.ToString());
                    ProjectConfig.WriteElementString("GenerateDebugInformation", IsDebugConfiguration.ToString());

                    if (TheProject.IsPlugin)
                        ProjectConfig.WriteElementString("AdditionalOptions", @"/EXPORT:EnginePluginEntry %(AdditionalOptions)");
                    if (TheProject.BuildType == ProjectBuildType.DynamicLibrary)
                        ProjectConfig.WriteElementString("ImportLibrary", @"$(GODDAMN_SDK)lib\$(TargetName).lib");
                    ProjectConfig.WriteEndElement();
                    ProjectConfig.WriteEndElement();
                }

                ProjectConfig.WriteStartElement("Import");
                ProjectConfig.WriteAttributeString("Project", @"$(VCTargetsPath)\Microsoft.Cpp.targets");
                ProjectConfig.WriteEndElement();

                ProjectConfig.WriteEndElement();
                ProjectConfig.WriteEndDocument();
            }
        }
Пример #7
0
 public abstract void GenerateProject(Project TheProject);