Exemplo n.º 1
0
        public override void Build(ProjectBase.ProfileBase ProjectProfile)
        {
            string projPath = ProjectProfile.IntermediatePath + ProjectProfile.AssemblyName;

            MSBuildProjectGenerator projectGenerator = null;

            if (ProjectProfile is CPPProject.Profile)
            {
                MicrosoftVCProjectGenerator generator = new MicrosoftVCProjectGenerator();
                projectGenerator       = generator;
                generator.ToolsVersion = Info.ToolsVersion;

                projPath += ".vcxproj";
            }
            else if (ProjectProfile is CSProject.Profile)
            {
                projectGenerator = new MicrosoftCSProjectGenerator();

                projPath += ".csproj";
            }

            File.WriteAllText(projPath, projectGenerator.Generate(ProjectProfile.Project, false));

            Build(projPath, ProjectProfile.BuildConfiguration, ProjectProfile.PlatformType);
        }
        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);
        }