private static void AddDependency(CPPProject.Profile Profile, string Dependency) { SourceBuilder builder = BuildSystem.GetSourceBuilder(Dependency); if (builder == null) { return; } Profile.AddIncludeDirectories(FileSystemUtilites.GetParentDirectory(builder.sourcePathRoot)); Profile.AddIncludeDirectories(FileSystemUtilites.PathSeperatorCorrection(builder.sourcePathRoot)); if (builder.SelectedRule.GenerateReflection) { Profile.AddIncludeDirectories(builder.generatedFilesPath); AddDependency(Profile, BuildSystemHelper.ReflectionModuleName); } if (builder.SelectedRule.IncludesPath != null) { foreach (string includePath in builder.SelectedRule.IncludesPath) { Profile.AddIncludeDirectories(FileSystemUtilites.PathSeperatorCorrection(builder.sourcePathRoot + includePath)); } } if (builder.SelectedRule.LibraryUseType == BuildRules.LibraryUseTypes.UseOnly) { string[] temp = builder.SelectedRule.LibrariesPath; if (temp != null) { foreach (string file in temp) { Profile.AddIncludeLibraries(builder.sourcePathRoot + FileSystemUtilites.PathSeperatorCorrection(file)); } } } //else //{ // profile.AddPreprocessorDefinition(BuildSystemHelper.GetAPIPreprocessor(builder.SelectedRule.TargetName, BuildSystemHelper.APIPreprocessorValues.Import)); // string[] libFiles = FileSystemUtilites.GetAllFiles(builder.BinariesPath, "*" + EnvironmentHelper.StaticLibraryExtentions); // if (libFiles != null) // foreach (string libFile in libFiles) // profile.AddIncludeLibraries(libFile); //} AddAllInclusionsFromDependencies(Profile, builder); }
public static bool Create() { RuleLibraryBuilder rulesBuilder = new RuleLibraryBuilder(EnvironmentHelper.ProcessDirectory); if (!rulesBuilder.Build()) { return(false); } CPPProject projectFile = new CPPProject(); foreach (ProjectBase.ProfileBase.BuildConfigurations configuration in BuildConfigurations) { foreach (ProjectBase.ProfileBase.PlatformTypes platform in PlatformTypes) { foreach (BuildRules buildRule in rulesBuilder.Rules) { foreach (BuildRules.RuleBase rule in buildRule.Rules) { if (rule.LibraryUseType != BuildRules.LibraryUseTypes.Executable) { continue; } CPPProject.Profile profile = (CPPProject.Profile)projectFile.CreateProfile(); profile.Name = buildRule.ModuleName; profile.BuildConfiguration = configuration; profile.PlatformType = platform; profile.OutputType = ProjectBase.ProfileBase.OutputTypes.Makefile; profile.OutputPath = EnvironmentHelper.FinalOutputDirectory + rule.TargetName + EnvironmentHelper.ExecutableExtentions; profile.IntermediatePath = EnvironmentHelper.IntermediateDirectory; profile.NMakeBuildCommandLine = string.Format("\"$(SolutionDir)Binaries/Frontend.exe\" -Action BuildEngine -Architecture {0} -Configuration {1}", platform, configuration); profile.NMakeReBuildCommandLine = string.Format("\"$(SolutionDir)Binaries/Frontend.exe\" -Action RebuildEngine -Architecture {0} -Configuration {1}", platform, configuration); profile.NMakeCleanCommandLine = string.Format("\"$(SolutionDir)Binaries/Frontend.exe\" -Action CleanEngine -Architecture {0} -Configuration {1}", platform, configuration); //profile.AddIncludeDirectories("$(ProjectDir)"); foreach (BuildRules buildRule1 in rulesBuilder.Rules) { foreach (BuildRules.RuleBase rule1 in buildRule1.Rules) { profile.AddIncludeDirectories(FileSystemUtilites.GetParentDirectory(buildRule1.Path)); profile.AddIncludeDirectories(FileSystemUtilites.PathSeperatorCorrection(buildRule1.Path)); profile.AddIncludeDirectories(FileSystemUtilites.PathSeperatorCorrection(profile.IntermediatePath + rule1.TargetName + EnvironmentHelper.PathSeparator + BuildSystemHelper.GeneratedPathName)); if (rule1.IncludesPath != null) { foreach (string includePath in rule1.IncludesPath) { profile.AddIncludeDirectories(FileSystemUtilites.PathSeperatorCorrection(buildRule1.Path + includePath)); } } profile.AddPreprocessorDefinition(BuildSystemHelper.GetAPIPreprocessor(rule1.TargetName, BuildSystemHelper.APIPreprocessorTypes.Empty)); profile.AddPreprocessorDefinition(BuildSystemHelper.GetExternPreprocessor(rule1.TargetName, BuildSystemHelper.ExternPreprocessorTypes.Empty)); if (rule1.PreprocessorDefinitions != null) { foreach (string pd in rule1.PreprocessorDefinitions) { profile.AddPreprocessorDefinition(pd); } } } } profile.AddPreprocessorDefinition(BuildSystemHelper.GetConfigurationModePreprocessor(configuration)); profile.AddPreprocessorDefinition(BuildSystemHelper.GetPlatformPreprocessor(EnvironmentHelper.Platform)); profile.AddPreprocessorDefinition(BuildSystemHelper.GetPlatformTypesPreprocessor(platform)); profile.AddPreprocessorDefinition(BuildSystemHelper.GetModuleNamePreprocessor("")); } } } } string[] files = FileSystemUtilites.GetAllFiles(WorkingDirectory, EnvironmentHelper.CSharpFileExtensions); foreach (string file in files) { projectFile.AddExtraFile(file); } files = FileSystemUtilites.GetAllFiles(WorkingDirectory, EnvironmentHelper.HeaderFileExtensions); foreach (string file in files) { projectFile.AddIncludeFile(file); } files = FileSystemUtilites.GetAllFiles(WorkingDirectory, EnvironmentHelper.CompileFileExtensions); foreach (string file in files) { projectFile.AddCompileFile(file); } MicrosoftVCProjectGenerator generator = new MicrosoftVCProjectGenerator(); generator.ToolsVersion = MSBuildProcess.Info.ToolsVersion; File.WriteAllText(ProjectFilePath, generator.Generate(projectFile, true)); File.WriteAllText(ProjectFilePath + ".filters", generator.GenerateFilter(projectFile, WorkingDirectory)); return(true); }