Skip to content

Commit

Permalink
Отображение журнала компиляции вместо отдельных выводов (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
L140-beep authored Sep 6, 2024
1 parent d483dd6 commit 989175b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/renderer/src/components/Modules/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ export class Compiler extends ClientWS {
}
this.setCompilerData({
result: data.result,
stdout: data.stdout,
stderr: data.stderr,
commands: data.commands,
binary: this.binary,
source: this.getSourceFiles(data.source),
platform: this.platform,
Expand All @@ -271,6 +270,7 @@ export class Compiler extends ClientWS {
data = JSON.parse(msg.data as string) as SourceFile;
this.setCompilerData({
result: 'OK',
commands: [],
binary: [],
//В данный момент название файла, которое приходит от компилятора
//Выглядит так: Robot_время.
Expand Down
37 changes: 16 additions & 21 deletions src/renderer/src/components/Sidebar/Compiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useSettings } from '@renderer/hooks';
import { useEditorContext } from '@renderer/store/EditorContext';
import { useSidebar } from '@renderer/store/useSidebar';
import { useTabs } from '@renderer/store/useTabs';
import { CompilerResult } from '@renderer/types/CompilerTypes';
import { CompileCommandResult, CompilerResult } from '@renderer/types/CompilerTypes';
import { Elements } from '@renderer/types/diagram';
import { languageMappers } from '@renderer/utils';

Expand Down Expand Up @@ -68,20 +68,20 @@ export const CompilerTab: React.FC<CompilerProps> = ({
await model.files.saveIntoFolder(compilerData!.source!);
};

const handleAddStdoutTab = () => {
openTab({
type: 'code',
name: 'stdout',
code: compilerData!.stdout ?? '',
language: 'txt',
const commandsResultToStr = (compilerCommands: CompileCommandResult[]): string => {
let stdout = '';
compilerCommands.forEach((element) => {
stdout += `${element.command}\nreturn_code: ${element.return_code}\nstdout: ${element.stdout}\n stderr: ${element.stderr}\n\n`;
});

return stdout;
};

const handleAddStderrTab = () => {
const handleAddStdoutTab = () => {
openTab({
type: 'code',
name: 'stderr',
code: compilerData!.stderr ?? '',
name: 'compilerLog',
code: commandsResultToStr(compilerData!.commands),
language: 'txt',
});
};
Expand Down Expand Up @@ -125,34 +125,29 @@ export const CompilerTab: React.FC<CompilerProps> = ({

const button = [
{
name: 'Показать stderr',
handler: handleAddStderrTab,
disabled: compilerData?.stderr === undefined,
},
{
name: 'Показать stdout',
name: 'Показать журнал компиляции',
handler: handleAddStdoutTab,
disabled: compilerData?.stdout === undefined,
disabled: compilerData?.commands.length === 0 || compilerData?.commands === undefined,
},
{
name: 'Сохранить результат',
handler: handleSaveBinaryIntoFolder,
disabled: compilerData?.binary === undefined || compilerData.binary.length == 0,
disabled: compilerData?.binary === undefined || compilerData.binary.length === 0,
},
{
name: 'Сохранить код',
handler: handleSaveSourceIntoFolder,
disabled: compilerData?.source == undefined || compilerData?.source.length == 0,
disabled: compilerData?.source == undefined || compilerData?.source.length === 0,
},
{
name: 'Показать код',
handler: handleShowSource,
disabled: compilerData?.source == undefined || compilerData?.source.length == 0,
disabled: compilerData?.source == undefined || compilerData?.source.length === 0,
},
{
name: 'Прошить...',
handler: handleFlashButton,
disabled: compilerData?.binary === undefined || compilerData.binary.length == 0,
disabled: compilerData?.binary === undefined || compilerData.binary.length === 0,
},
];
const processing =
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/src/types/CompilerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ export type CompilerComponent = {
type: string;
parameters: { [key: string]: string };
};

export type CompileCommandResult = {
command: string;
return_code: string;
stdout: string;
stderr: string;
};

export type CompilerResult = {
result: string;
stdout?: string;
stderr?: string;
commands: CompileCommandResult[];
binary?: Array<Binary>;
source?: Array<SourceFile>;
// платформа для которой была осуществлена компиляция
Expand Down

0 comments on commit 989175b

Please sign in to comment.