Example #1
0
        //kompilacija proekta
        public string Compile(PascalABCCompiler.IProjectInfo project, bool rebuild, string RuntimeServicesModule, bool ForRun, bool RunWithEnvironment)
        {
            ProjectService.SaveProject();
            Workbench.WidgetController.CompilingButtonsEnabled = false;
            Workbench.CompilerConsoleWindow.ClearConsole();
            CompilerOptions1.SourceFileName  = project.Path;
            CompilerOptions1.OutputDirectory = project.OutputDirectory;
            CompilerOptions1.ProjectCompiled = true;
            if (project.ProjectType == PascalABCCompiler.ProjectType.WindowsApp)
            {
                CompilerOptions1.OutputFileType = PascalABCCompiler.CompilerOptions.OutputType.WindowsApplication;
            }
            ErrorsList.Clear();
            CompilerOptions1.Rebuild = rebuild;
            CompilerOptions1.Locale  = PascalABCCompiler.StringResourcesLanguage.CurrentTwoLetterISO;
            CompilerOptions1.UseDllForSystemUnits = false;
            CompilerOptions1.RunWithEnvironment   = RunWithEnvironment;
            bool savePCU = Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate;

            if (Path.GetDirectoryName(CompilerOptions1.SourceFileName).ToLower() == ((string)WorkbenchStorage.StandartDirectories[Constants.LibSourceDirectoryIdent]).ToLower())
            {
                Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = false;
            }
            if (RuntimeServicesModule != null)
            {
                CompilerOptions1.StandartModules.Add(new PascalABCCompiler.CompilerOptions.StandartModule(RuntimeServicesModule, PascalABCCompiler.CompilerOptions.StandartModuleAddMethod.RightToMain, PascalABCCompiler.SyntaxTree.LanguageId.C | PascalABCCompiler.SyntaxTree.LanguageId.PascalABCNET | PascalABCCompiler.SyntaxTree.LanguageId.CommonLanguage));
            }

            string ofn = Workbench.VisualEnvironmentCompiler.Compile(CompilerOptions1);

            Workbench.VisualEnvironmentCompiler.Compiler.InternalDebug.PCUGenerate = savePCU;

            if (RuntimeServicesModule != null)
            {
                CompilerOptions1.RemoveStandartModuleAtIndex(CompilerOptions1.StandartModules.Count - 1);
            }

            if (Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList.Count != 0 || Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0)
            {
                List <PascalABCCompiler.Errors.Error> ErrorsAndWarnings = new List <PascalABCCompiler.Errors.Error>();
                List <PascalABCCompiler.Errors.Error> Errors            = Workbench.ErrorsManager.CreateErrorsList(Workbench.VisualEnvironmentCompiler.Compiler.ErrorsList);
                AddErrors(ErrorsAndWarnings, Errors);
                //if (!ForRun)
                AddWarnings(ErrorsAndWarnings, Workbench.VisualEnvironmentCompiler.Compiler.Warnings);
                Workbench.ErrorsListWindow.ShowErrorsSync(ErrorsAndWarnings, Errors.Count != 0 || (Workbench.VisualEnvironmentCompiler.Compiler.Warnings.Count != 0 && !ForRun));
            }
            return(ofn);
        }