Exemple #1
0
        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);
        }
Exemple #2
0
        private static string GetExtension(SourceBuilder Builder)
        {
            switch (Builder.SelectedRule.LibraryUseType)
            {
            case BuildRules.LibraryUseTypes.Executable:
                return(EnvironmentHelper.ExecutableExtentions);

            case BuildRules.LibraryUseTypes.DynamicLibrary:
                return(EnvironmentHelper.DynamicLibraryExtentions);

            case BuildRules.LibraryUseTypes.StaticLibrary:
                return(EnvironmentHelper.StaticLibraryExtentions);
            }

            return("");
        }
Exemple #3
0
        private static void AddAllInclusionsFromDependencies(CPPProject.Profile Profile, SourceBuilder Builder)
        {
            if (Builder == null)
            {
                return;
            }

            if (Builder.SelectedRule.LibraryUseType != BuildRules.LibraryUseTypes.UseOnly)
            {
                Profile.AddPreprocessorDefinition(BuildSystemHelper.GetAPIPreprocessor(Builder.BuildRule.ModuleName, (Builder.SelectedRule.LibraryUseType == BuildRules.LibraryUseTypes.DynamicLibrary ? BuildSystemHelper.APIPreprocessorTypes.Import : BuildSystemHelper.APIPreprocessorTypes.Empty)));
                Profile.AddPreprocessorDefinition(BuildSystemHelper.GetExternPreprocessor(Builder.BuildRule.ModuleName, BuildSystemHelper.ExternPreprocessorTypes.Empty));

                string[] libFiles = FileSystemUtilites.GetAllFiles(Builder.BinariesPath, "*" + EnvironmentHelper.StaticLibraryExtentions);

                if (libFiles != null)
                {
                    foreach (string libFile in libFiles)
                    {
                        Profile.AddIncludeLibraries(libFile);
                    }
                }
            }


            if (Builder.SelectedRule.DependencyModulesName == null)
            {
                return;
            }

            foreach (string dep in Builder.SelectedRule.DependencyModulesName)
            {
                SourceBuilder builder = BuildSystem.GetSourceBuilder(dep);

                AddAllInclusionsFromDependencies(Profile, builder);
            }
        }
Exemple #4
0
        private void GenerateAndBuildProjectFile(bool ForceToRebuild)
        {
            LogCurrentInfo();

            if (!ForceToRebuild && !MustCompile())
            {
                state = States.AlreadyUpdated;
                return;
            }

            CPPProject cppProj = new CPPProject();

            CPPProject.Profile profile = (CPPProject.Profile)cppProj.CreateProfile();

            profile.AssemblyName       = SelectedRule.TargetName;
            profile.OutputType         = BuildSystemHelper.LibraryUseTypesToOutputType(SelectedRule.LibraryUseType);
            profile.OutputPath         = BinariesPath;
            profile.Optimization       = CPPProject.Profile.Optimizations.Disabled;
            profile.MinimalRebuild     = true;
            profile.PlatformType       = BuildSystem.PlatformType;
            profile.BuildConfiguration = BuildSystem.BuildConfiguration;

            if (profile.BuildConfiguration == ProjectBase.ProfileBase.BuildConfigurations.Debug)
            {
                profile.GenerateDebugInformation = true;

                //if (SelectedRule.LibraryUseType == BuildRules.LibraryUseTypes.Executable)
                //	profile.RuntimeLibrary = CPPProject.Profile.RuntimeLibraries.MultiThreadedDebug;
                //else
                profile.RuntimeLibrary = CPPProject.Profile.RuntimeLibraries.MultiThreadedDebugDLL;
            }
            else if (profile.BuildConfiguration == ProjectBase.ProfileBase.BuildConfigurations.Release)
            {
                profile.GenerateDebugInformation = false;

                //if (SelectedRule.LibraryUseType == BuildRules.LibraryUseTypes.Executable)
                //	profile.RuntimeLibrary = CPPProject.Profile.RuntimeLibraries.MultiThreaded;
                //else
                profile.RuntimeLibrary = CPPProject.Profile.RuntimeLibraries.MultiThreadedDLL;
            }

            profile.AddIncludeDirectories(EnvironmentHelper.ProcessDirectory);
            profile.AddIncludeDirectories(sourcePathRoot);
            profile.AddIncludeDirectories(generatedFilesPath);
            if (SelectedRule.DependencyModulesName != null)
            {
                foreach (string dep in SelectedRule.DependencyModulesName)
                {
                    AddDependency(profile, dep);
                }
            }

            if (SelectedRule.GenerateReflection)
            {
                AddDependency(profile, BuildSystemHelper.ReflectionModuleName);
            }

            profile.AddPreprocessorDefinition(BuildSystemHelper.GetModuleNamePreprocessor(BuildRule.ModuleName));
            profile.AddPreprocessorDefinition(BuildSystemHelper.GetAPIPreprocessor(BuildRule.ModuleName, BuildSystemHelper.APIPreprocessorTypes.Export));
            profile.AddPreprocessorDefinition(BuildSystemHelper.GetExternPreprocessor(BuildRule.ModuleName, BuildSystemHelper.ExternPreprocessorTypes.Fill));
            if (SelectedRule.PreprocessorDefinitions != null)
            {
                foreach (string def in SelectedRule.PreprocessorDefinitions)
                {
                    profile.AddPreprocessorDefinition(def);
                }
            }

            profile.AddPreprocessorDefinition(BuildSystemHelper.GetConfigurationModePreprocessor(BuildSystem.BuildConfiguration));
            profile.AddPreprocessorDefinition(BuildSystemHelper.GetPlatformPreprocessor(EnvironmentHelper.Platform));
            profile.AddPreprocessorDefinition(BuildSystemHelper.GetPlatformTypesPreprocessor(BuildSystem.PlatformType));

            if (SelectedRule.DependencyStaticLibraries != null)
            {
                foreach (string lib in SelectedRule.DependencyStaticLibraries)
                {
                    profile.AddIncludeLibraries(lib);
                }
            }

            string[] files = FileSystemUtilites.GetAllFiles(sourcePathRoot, EnvironmentHelper.HeaderFileExtensions);
            foreach (string file in files)
            {
                cppProj.AddIncludeFile(file);

                string outputBasePath = generatedFilesPath + Path.GetFileNameWithoutExtension(file);

                if (SelectedRule.GenerateReflection)
                {
                    string outputBaseFileName = outputBasePath + ".Reflection";
                    if (ParseForReflection(file, outputBaseFileName))
                    {
                        cppProj.AddIncludeFile(outputBaseFileName + ".h");
                        cppProj.AddCompileFile(outputBaseFileName + ".cpp");
                    }
                }

                if (SelectedRule.GenerateWrapper)
                {
                    string outputBaseFileName = outputBasePath + ".Wrapper";
                    if (ParseForWrapper(file, outputBaseFileName))
                    {
                        cppProj.AddIncludeFile(outputBaseFileName + ".h");
                        cppProj.AddCompileFile(outputBaseFileName + ".cpp");

                        wrapperCSFiles.Add(outputBaseFileName + ".cs");
                    }
                }
            }

            if (SelectedRule.IncludeModulesName != null)
            {
                foreach (string moduleName in SelectedRule.IncludeModulesName)
                {
                    SourceBuilder builder = BuildSystem.GetSourceBuilder(moduleName);

                    if (builder == null)
                    {
                        continue;
                    }

                    profile.AddIncludeDirectories(builder.sourcePathRoot);
                    profile.AddPreprocessorDefinition(BuildSystemHelper.GetAPIPreprocessor(builder.BuildRule.ModuleName, BuildSystemHelper.APIPreprocessorTypes.Empty));
                    profile.AddPreprocessorDefinition(BuildSystemHelper.GetExternPreprocessor(builder.BuildRule.ModuleName, BuildSystemHelper.ExternPreprocessorTypes.Empty));
                }
            }

            if (SelectedRule.AdditionalIncludeDirectory != null)
            {
                foreach (string dir in SelectedRule.AdditionalIncludeDirectory)
                {
                    string dirInfo = FileSystemUtilites.PathSeperatorCorrection(dir);

                    if (dirInfo.StartsWith("" + EnvironmentHelper.PathSeparator))
                    {
                        dirInfo = dirInfo.Substring(1);
                    }

                    profile.AddIncludeLibraryDirectories(sourcePathRoot + dirInfo);
                }
            }

            files = FileSystemUtilites.GetAllFiles(sourcePathRoot, EnvironmentHelper.CompileFileExtensions);
            foreach (string file in files)
            {
                cppProj.AddCompileFile(file);
            }

            if (SelectedRule.AdditionalCompileFile != null)
            {
                foreach (string file in SelectedRule.AdditionalCompileFile)
                {
                    cppProj.AddCompileFile(EnvironmentHelper.ProcessDirectory + file);
                }
            }

            profile.IntermediatePath = intermediateModulePath;

            BuildProjectFile(profile);
        }