コード例 #1
0
        /// <summary>
        /// Get the results for each compiled files
        /// </summary>
        protected override void GetProcessResults()
        {
            base.GetProcessResults();

            // end of successful execution action
            if (!ExecutionFailed)
            {
                try {
                    Parallel.ForEach(CompiledFiles, file => {
                        file.ReadCompilationResults(Env.IoEncoding, _processStartDir);
                        file.ComputeRequiredDatabaseReferences(Env, AnalysisModeSimplifiedDatabaseReferences);
                    });

                    // set UoeExecutionCompilationStoppedException exception
                    for (int i = 0; i < HandledExceptions.Count; i++)
                    {
                        if (HandledExceptions[i] is UoeExecutionOpenedgeException oeException)
                        {
                            if (oeException.ErrorNumber == UoeConstants.StopOnCompilationReturnErrorCode)
                            {
                                HandledExceptions[i] = new UoeExecutionCompilationStoppedException {
                                    CompilationProblems = CompiledFiles.CopyWhere(f => f.CompilationProblems != null).SelectMany(f => f.CompilationProblems).Where(e => StopOnCompilationError ? e is UoeCompilationError : e is UoeCompilationWarning).ToList(),
                                    StopOnWarning       = StopOnCompilationWarning
                                };
                            }
                        }
                    }
                } catch (Exception e) {
                    HandledExceptions.Add(new UoeExecutionException("Error while reading the compilation results.", e));
                }
            }
        }
コード例 #2
0
        private void OnProcessExecutionEnd(UoeExecution obj)
        {
            // add compiled files to this list
            Monitor.Enter(_lock);
            try {
                if (obj is UoeExecutionCompile compilation)
                {
                    CompiledFiles.TryAddRange(compilation.CompiledFiles);
                }
            } catch (Exception e) {
                HandledExceptions.Add(new UoeExecutionException("Error when checking the compilation results.", e));
            } finally {
                Monitor.Exit(_lock);
            }

            // only do the rest when reaching the last process
            if (NumberOfProcessesRunning > 0)
            {
                return;
            }

            if (!HasBeenKilled)
            {
                PublishParallelCompilationResults();
            }
        }
コード例 #3
0
        protected override void SetExecutionInfo()
        {
            _useXmlXref = CompileUseXmlXref && (!CompileInAnalysisMode || AnalysisModeSimplifiedDatabaseReferences);

            base.SetExecutionInfo();

            // for each file of the list
            var filesListcontent = new StringBuilder();

            var count = 0;

            foreach (var file in FilesToCompile)
            {
                if (!File.Exists(file.CompiledPath))
                {
                    throw new UoeExecutionParametersException($"Can not find the source file : {file.CompiledPath.PrettyQuote()}.");
                }

                var localSubTempDir = Path.Combine(_tempDir, count.ToString());
                var baseFileName    = Path.GetFileNameWithoutExtension(file.CompiledPath);

                var compiledFile = new UoeCompiledFile(file);
                if (!CompiledFiles.TryAdd(compiledFile))
                {
                    continue;
                }

                // get the output directory that will be use to generate the .r (and listing debug-list...)
                if (Path.GetExtension(file.Path ?? "").Equals(UoeConstants.ExtCls))
                {
                    // for *.cls files, as many *.r files are generated, we need to compile in a temp directory
                    // we need to know which *.r files were generated for each input file
                    // so each file gets his own sub tempDir
                    compiledFile.CompilationOutputDirectory = localSubTempDir;
                }
                else if (!string.IsNullOrEmpty(file.PreferredTargetDirectory))
                {
                    compiledFile.CompilationOutputDirectory = file.PreferredTargetDirectory;
                }
                else
                {
                    compiledFile.CompilationOutputDirectory = localSubTempDir;
                }

                Utils.CreateDirectoryIfNeeded(localSubTempDir);
                Utils.CreateDirectoryIfNeeded(compiledFile.CompilationOutputDirectory);

                compiledFile.CompilationRcodeFilePath  = Path.Combine(compiledFile.CompilationOutputDirectory, $"{baseFileName}{UoeConstants.ExtR}");
                compiledFile.CompilationErrorsFilePath = Path.Combine(localSubTempDir, $"{baseFileName}{UoeConstants.ExtCompileErrorsLog}");
                if (CompileWithListing)
                {
                    compiledFile.CompilationListingFilePath = Path.Combine(compiledFile.CompilationOutputDirectory, $"{baseFileName}{UoeConstants.ExtListing}");
                }

                if (CompileWithXref && !_useXmlXref)
                {
                    compiledFile.CompilationXrefFilePath = Path.Combine(compiledFile.CompilationOutputDirectory, $"{baseFileName}{UoeConstants.ExtXref}");
                }
                if (CompileWithXref && _useXmlXref)
                {
                    compiledFile.CompilationXmlXrefFilePath = Path.Combine(compiledFile.CompilationOutputDirectory, $"{baseFileName}{UoeConstants.ExtXrefXml}");
                }
                if (CompileWithDebugList)
                {
                    compiledFile.CompilationDebugListFilePath = Path.Combine(compiledFile.CompilationOutputDirectory, $"{baseFileName}{UoeConstants.ExtDebugList}");
                }
                if (CompileWithPreprocess)
                {
                    compiledFile.CompilationPreprocessedFilePath = Path.Combine(compiledFile.CompilationOutputDirectory, $"{baseFileName}{UoeConstants.ExtPreprocessed}");
                }

                compiledFile.IsAnalysisMode = CompileInAnalysisMode;

                if (CompileInAnalysisMode)
                {
                    compiledFile.CompilationFileIdLogFilePath = Path.Combine(localSubTempDir, $"{baseFileName}{UoeConstants.ExtFileIdLog}");
                    if (AnalysisModeSimplifiedDatabaseReferences)
                    {
                        compiledFile.CompilationRcodeTableListFilePath = Path.Combine(compiledFile.CompilationOutputDirectory, $"{baseFileName}{UoeConstants.ExtTableList}");
                    }
                    else if (string.IsNullOrEmpty(compiledFile.CompilationXrefFilePath))
                    {
                        compiledFile.CompilationXrefFilePath = Path.Combine(localSubTempDir, $"{baseFileName}{UoeConstants.ExtXref}");
                    }
                }

                // feed files list
                filesListcontent
                .Append(file.CompiledPath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationOutputDirectory.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationErrorsFilePath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationListingFilePath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationXrefFilePath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationXmlXrefFilePath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationDebugListFilePath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationPreprocessedFilePath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationFileIdLogFilePath.ProQuoter())
                .Append(" ")
                .Append(compiledFile.CompilationRcodeTableListFilePath.ProQuoter())
                .AppendLine();

                count++;
            }


            File.WriteAllText(_filesListPath, filesListcontent.ToString(), Env.IoEncoding);

            SetPreprocessedVar("CompileListFilePath", _filesListPath.ProPreProcStringify());
            SetPreprocessedVar("CompileProgressionFilePath", _progressionFilePath.ProPreProcStringify());
            SetPreprocessedVar("CompileLogPath", _compilationLog.ProPreProcStringify());
            SetPreprocessedVar("IsAnalysisMode", CompileInAnalysisMode.ToString());
            SetPreprocessedVar("GetRcodeTableList", AnalysisModeSimplifiedDatabaseReferences.ToString());
            SetPreprocessedVar("ProVerHigherOrEqualTo10.2", Env.IsProVersionHigherOrEqualTo(new Version(10, 2, 0)).ToString());
            SetPreprocessedVar("UseXmlXref", _useXmlXref.ToString());
            SetPreprocessedVar("CompileStatementExtraOptions", CompileStatementExtraOptions.ProPreProcStringify().StripQuotes());
            SetPreprocessedVar("CompilerMultiCompile", CompilerMultiCompile.ToString());
            SetPreprocessedVar("ProVerHigherOrEqualTo11.7", Env.IsProVersionHigherOrEqualTo(new Version(11, 7, 0)).ToString());
            SetPreprocessedVar("CompileOptions", CompileOptions.ProPreProcStringify());
            SetPreprocessedVar("StopOnCompilationError", StopOnCompilationError.ToString());
            SetPreprocessedVar("StopOnCompilationWarning", StopOnCompilationWarning.ToString());
            SetPreprocessedVar("StopOnCompilationReturnErrorCode", UoeConstants.StopOnCompilationReturnErrorCode.ToString());
        }