Skip to content

Commit

Permalink
Read Quartus status from DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
qarlosalberto committed Dec 2, 2023
1 parent ae11d84 commit 861a186
Show file tree
Hide file tree
Showing 17 changed files with 872 additions and 72 deletions.
3 changes: 2 additions & 1 deletion packages/colibri/src/project_manager/export_t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export * as quartusProjectManager from './tool/quartus/quartusProjectManager';
export * as multi_project_manager from './multi_project_manager';
export * as common from './common';
export * as tool_common from './tool/common';
export * as quartus from './tool/quartus/utils';
export * as quartus from './tool/quartus/utils';
export * as utils from './utils/utils';
3 changes: 3 additions & 0 deletions packages/colibri/src/project_manager/tool/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export enum e_iconType {

export enum e_reportType {
REPORT = "Report",
REPORTDB = "Logs",
TIMINGANALYZER = "Timing Analyzer",
TECHNOLOGYMAPVIEWER = "Technology Map Viewer",
SNAPSHOPVIEWER = "Snapshop Viewer",
Expand Down Expand Up @@ -226,6 +227,7 @@ export type t_test_declaration = {

/** Artifact type */
export enum e_artifact_type {
LOG = "log",
CONSOLE_LOG = "console_log",
SUMMARY = "summary",
OTHER = "other",
Expand All @@ -244,6 +246,7 @@ export enum e_element_type {
FOLDER = "folder",
FST = "fst",
NONE = "none",
DATABASE = "database",
}

/** Test artifact */
Expand Down
45 changes: 35 additions & 10 deletions packages/colibri/src/project_manager/tool/quartus/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ export function getDefaultTaskList(): t_taskRep[] {
"success": undefined,
"elapsed_time": undefined,
"percent": undefined,
"reports": [
e_reportType.REPORTDB,
]
},
{
"name": e_taskType.QUARTUS_ANALYSISSYNTHESIS,
"label": "Run during full compilation",
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [e_reportType.REPORT,],
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT,
],
"success": undefined,
"elapsed_time": undefined,
"percent": undefined,
Expand All @@ -31,7 +37,10 @@ export function getDefaultTaskList(): t_taskRep[] {
"name": e_taskType.QUARTUS_ANALYSISELABORATION,
"label": "Run during full compilation",
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [e_reportType.REPORT,],
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT,
],
"success": undefined,
"elapsed_time": undefined,
"percent": undefined,
Expand All @@ -42,8 +51,9 @@ export function getDefaultTaskList(): t_taskRep[] {
"label": "Run during full compilation",
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT, e_reportType.TIMINGANALYZER,
e_reportType.TECHNOLOGYMAPVIEWER,
// e_reportType.TECHNOLOGYMAPVIEWER,
],
"status": e_taskState.IDLE,
"success": undefined,
Expand All @@ -56,7 +66,11 @@ export function getDefaultTaskList(): t_taskRep[] {
"name": e_taskType.QUARTUS_EARLYTIMINGANALYSIS,
"label": "Not run during full compilation",
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [e_reportType.REPORT, e_reportType.TIMINGANALYZER,],
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT,
e_reportType.TIMINGANALYZER,
],
"icon": e_iconType.TIME,
"success": undefined,
"elapsed_time": undefined,
Expand All @@ -67,7 +81,10 @@ export function getDefaultTaskList(): t_taskRep[] {
"name": e_taskType.QUARTUS_FITTER,
"label": "Run during full compilation",
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [e_reportType.REPORT,],
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT,
],
"success": undefined,
"elapsed_time": undefined,
"percent": undefined,
Expand All @@ -90,8 +107,9 @@ export function getDefaultTaskList(): t_taskRep[] {
"percent": undefined,
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT, e_reportType.TIMINGANALYZER,
e_reportType.TECHNOLOGYMAPVIEWER
// e_reportType.TECHNOLOGYMAPVIEWER
],
"status": e_taskState.IDLE
},
Expand All @@ -103,8 +121,9 @@ export function getDefaultTaskList(): t_taskRep[] {
"percent": undefined,
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT, e_reportType.TIMINGANALYZER,
e_reportType.TECHNOLOGYMAPVIEWER
// e_reportType.TECHNOLOGYMAPVIEWER
],
"status": e_taskState.IDLE,
},
Expand All @@ -116,8 +135,9 @@ export function getDefaultTaskList(): t_taskRep[] {
"percent": undefined,
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT, e_reportType.TIMINGANALYZER,
e_reportType.TECHNOLOGYMAPVIEWER
// e_reportType.TECHNOLOGYMAPVIEWER
],
"status": e_taskState.IDLE,
},
Expand All @@ -130,7 +150,10 @@ export function getDefaultTaskList(): t_taskRep[] {
"elapsed_time": undefined,
"percent": undefined,
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [e_reportType.REPORT, e_reportType.TIMINGANALYZER,],
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT, e_reportType.TIMINGANALYZER,
],
"status": e_taskState.IDLE,
},
]
Expand All @@ -142,7 +165,9 @@ export function getDefaultTaskList(): t_taskRep[] {
"elapsed_time": undefined,
"percent": undefined,
"executionType": e_taskExecutionType.COMPLEXCOMMAND,
"reports": [e_reportType.REPORT, e_reportType.TIMINGANALYZER,],
"reports": [
e_reportType.REPORTDB,
e_reportType.REPORT, e_reportType.TIMINGANALYZER,],
"icon": e_iconType.TIME,
"status": e_taskState.IDLE,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Database } from 'sqlite3';
import { TaskStateManager } from '../taskState';
import { e_taskState, e_taskType } from '../common';
import { check_if_path_exist } from '../../../utils/file_utils';
import { openDatabase, closeDatabase } from '../../utils/utils';

const taskNameInBBDD: Record<string, e_taskType> = {
"Full Compilation": e_taskType.QUARTUS_COMPILEDESIGN,
Expand All @@ -17,44 +18,9 @@ const taskNameInBBDD: Record<string, e_taskType> = {
"Place": e_taskType.QUARTUS_PLACE,
"Route": e_taskType.QUARTUS_ROUTE,
"Fitter (Finalize)": e_taskType.QUARTUS_FITTERFINALIZE,
"none3": e_taskType.QUARTUS_TIMING,
"Timing Analysis (Finalize)": e_taskType.QUARTUS_TIMING,
};

/**
* Open the database and return the object
* @param bbddPath Path to the database
* @returns Promise with the database object
*/
function openDatabase(bbddPath: string) {
return new Promise((resolve, reject) => {
const db = new Database(bbddPath, (err) => {
if (err) {
reject(err);
} else {
resolve(db);
}
});
});
}

/**
* Close the database
* @param db Database object
*/
async function closeDatabase(db: Database) {
try {
await new Promise<void>((resolve, reject) => {
db.close((err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} catch (error) { /* empty */ }
}

/**
* Clean all the tasks
* @param taskManager Task manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { runTask } from "./taskRunner";
import { get_directory } from "../../../utils/file_utils";
import { getDefaultTaskList } from "./common";
import { TaskStateManager } from "../taskState";
import { setStatus } from "./quartusBBDD";
import { setStatus } from "./quartusDB";

export class QuartusProjectManager extends Project_manager {

Expand Down Expand Up @@ -287,9 +287,9 @@ export class QuartusProjectManager extends Project_manager {
[e_taskType.QUARTUS_EARLYTIMINGANALYSIS]: "",
[e_taskType.QUARTUS_FITTERIMPLEMENT]: "",
};
const reportKeys = Object.keys(reportSufix);
let reportKeys = Object.keys(reportSufix);
if (reportType === e_reportType.REPORT && reportKeys.includes(taskType)) {
const reportName = `${this.get_name()}.${reportSufix[taskType]}.rpt`;
const reportName = `${this.currentRevision}.${reportSufix[taskType]}.rpt`;
const reportPath = path_lib.join(get_directory(this.projectDiskPath), reportName);

const artifact: t_test_artifact = {
Expand All @@ -302,6 +302,23 @@ export class QuartusProjectManager extends Project_manager {
};
return artifact;
}

reportSufix[e_taskType.QUARTUS_IPGENERATION] = "ipg";
reportKeys = Object.keys(reportSufix);
if (reportType === e_reportType.REPORTDB && reportKeys.includes(taskType)) {
const reportName = `${this.currentRevision}.${reportSufix[taskType]}.qmsgdb`;
const reportPath = path_lib.join(get_directory(this.quartusDatabaseStatusPath), reportName);

const artifact: t_test_artifact = {
name: "Report",
path: reportPath,
command: "",
artifact_type: e_artifact_type.LOG,
element_type: e_element_type.DATABASE,
content: undefined
};
return artifact;
}
return {} as t_test_artifact;
}

Expand Down
36 changes: 36 additions & 0 deletions packages/colibri/src/project_manager/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { t_project_definition } from "../project_definition";
import { convert_to_yaml } from "./json2yaml";
import * as file_utils from "../../utils/file_utils";
import * as general from "../../common/general";
import { Database } from 'sqlite3';

export function get_edam_json(prj: t_project_definition, top_level_list: undefined | string[],
refrence_path?: string) {
Expand Down Expand Up @@ -78,4 +79,39 @@ export function get_file_type(filepath: string): string {
file_type += `-${default_version}`;
}
return file_type;
}

/**
* Open the database and return the object
* @param bbddPath Path to the database
* @returns Promise with the database object
*/
export function openDatabase(bbddPath: string) {
return new Promise((resolve, reject) => {
const db = new Database(bbddPath, (err) => {
if (err) {
reject(err);
} else {
resolve(db);
}
});
});
}

/**
* Close the database
* @param db Database object
*/
export async function closeDatabase(db: Database) {
try {
await new Promise<void>((resolve, reject) => {
db.close((err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} catch (error) { /* empty */ }
}
7 changes: 7 additions & 0 deletions packages/teroshdl/auto_package/command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@
where: ["view/title"]
when: "view == teroshdl-view-tasks"

- name: view.tasks.logs
title: "Open Log"
icon: database
where: ["view/item/context"]
when: "viewItem =~ /logs/"
group: "inline"

- name: view.tasks.report
title: "Open Report"
icon: output
Expand Down
4 changes: 3 additions & 1 deletion packages/teroshdl/auto_package/templates/dependencie.nj
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
"xml2js": "0.4.23",
"nunjucks": "^3.2.0",
"@types/nunjucks": "^3.1.4",
"tree-kill": "1.2.2"
"tree-kill": "1.2.2",
"sqlite3": "^5.0.2",
"@types/sqlite3": "^3.1.11"
}
4 changes: 2 additions & 2 deletions packages/teroshdl/auto_package/templates/devDependencie.nj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"@types/glob": "^7.1.1",
"@types/node": "^13.11.0",
"@types/vscode": "^1.45.0",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^6.8.0",
"glob": "^7.1.6",
"js-yaml": "^3.13.1",
Expand Down
14 changes: 14 additions & 0 deletions packages/teroshdl/auto_package/templates/package.nj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
"title": "TerosHDL",
"icon": "resources/images/teros_logo.svg"
}
],
"panel": [
{
"id": "teroshdl-messages-view",
"title": "TerosHDL: log report",
"icon": "fancy.icon"
}
]
},
"views": {
Expand Down Expand Up @@ -46,6 +53,13 @@
"id": "teroshdl-view-actions",
"name": "Actions"
}
],
"teroshdl-messages-view": [
{
"type": "webview",
"id": "teroshdl-report-logs",
"name": "Report Logs"
}
]
},
"viewsWelcome": [
Expand Down
Loading

0 comments on commit 861a186

Please sign in to comment.