diff --git a/packages/colibri/src/config/config_declaration.ts b/packages/colibri/src/config/config_declaration.ts index 8ad53b9e..84fd8869 100644 --- a/packages/colibri/src/config/config_declaration.ts +++ b/packages/colibri/src/config/config_declaration.ts @@ -86,6 +86,9 @@ export type e_config = { "questa" : e_tools_questa, "raptor" : e_tools_raptor, } + [key: string]: { + [key: string]: any; + }; }; export type e_general_general = { pypath : string, diff --git a/packages/colibri/src/config/config_manager.ts b/packages/colibri/src/config/config_manager.ts index d7cd33f9..a5768f66 100644 --- a/packages/colibri/src/config/config_manager.ts +++ b/packages/colibri/src/config/config_manager.ts @@ -18,261 +18,109 @@ // along with TerosHDL. If not, see . import { - get_default_config, e_config, e_tools_general_select_tool, e_linter_general_linter_vhdl, - e_linter_general_linter_verilog, e_linter_general_lstyle_vhdl, e_linter_general_lstyle_verilog, - e_formatter_general_formatter_vhdl, e_formatter_general_formatter_verilog, get_config_from_json + get_default_config, e_config, get_config_from_json } from './config_declaration'; -import * as cfg_aux from "./auxiliar_config"; import { WEB_CONFIG } from "./config_web"; import { read_file_sync, save_file_sync } from "../utils/file_utils"; -export class Config_manager { - private sync_file_path = ""; +export class ConfigManager { private config: e_config; - constructor(sync_file_path = "") { - this.sync_file_path = sync_file_path; - this.config = this.read_config_from_filesystem(sync_file_path); - } - - public set_config(new_config: e_config) { - this.config = new_config; - this.save_config_to_filesystem(); + constructor(config: e_config) { + this.config = config; } - public set_config_from_json(new_config: any) { - try { - const config = get_config_from_json(new_config); - this.config = config; - this.save_config_to_filesystem(); - // eslint-disable-next-line no-empty - } catch (error) { } + public set_config(config_dict: Record) { + this.config = get_config_from_json(config_dict); } public get_config(): e_config { return this.config; } - public get_html(): string { - return WEB_CONFIG; + public toString(): string { + return JSON.stringify(this.config, null, 4); } +} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Output manager - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public read_config_from_filesystem(file_path: string) { - if (file_path === "") { - return get_default_config(); - } - try { - const file_content = read_file_sync(file_path); - const config_saved = JSON.parse(file_content); - const config = get_config_from_json(config_saved); - return config; - } catch (error) { - return get_default_config(); - } +export class GlobalConfigManager extends ConfigManager { + private static instance: GlobalConfigManager; + + public static newInstance(sync_file_path: string) { + GlobalConfigManager.instance = new GlobalConfigManager(sync_file_path, get_default_config()); + return GlobalConfigManager.getInstance(); } - public save_config_to_filesystem() { - if (this.sync_file_path === "") { - return; - } - try { - const config_string = JSON.stringify(this.config, null, 4); - save_file_sync(this.sync_file_path, config_string); + public static getInstance(): GlobalConfigManager { + if (!GlobalConfigManager.instance) { + throw Error("You need to create the GlobalConfigManager instance first using newInstance method."); } - // eslint-disable-next-line no-empty - catch (error) { } + return GlobalConfigManager.instance; } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Linter - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public get_vhdl_linter_name() { - return this.config.linter.general.linter_vhdl; + public static get_html(): string { + return WEB_CONFIG; } - public get_verilog_linter_name() { - return this.config.linter.general.linter_verilog; - } + private sync_file_path = ""; - public get_vhdl_style_linter_name() { - return this.config.linter.general.lstyle_vhdl; + private constructor(sync_file_path: string, config: e_config) { + super(config); + this.sync_file_path = sync_file_path; } - public get_verilog_style_linter_name() { - return this.config.linter.general.lstyle_verilog; + public load() { + const file_content = read_file_sync(this.sync_file_path); + const config_saved = JSON.parse(file_content); + this.set_config(config_saved); } - public get_linter_config_vhdl(): string { - const linter_name = this.config.linter.general.linter_vhdl; - if (linter_name === e_linter_general_linter_vhdl.ghdl) { - return this.config.linter.ghdl.arguments; - } - else if (linter_name === e_linter_general_linter_vhdl.modelsim) { - return this.config.linter.modelsim.vhdl_arguments; - } - else if (linter_name === e_linter_general_linter_vhdl.vivado) { - return this.config.linter.vivado.vhdl_arguments; - } - else { - return ""; - } + public save() { + const config_string = JSON.stringify(this.get_config(), null, 4); + save_file_sync(this.sync_file_path, config_string); } - public get_linter_config_verilog(): string { - const linter_name = this.config.linter.general.linter_verilog; - if (linter_name === e_linter_general_linter_verilog.icarus) { - return this.config.linter.icarus.arguments; - } - else if (linter_name === e_linter_general_linter_verilog.modelsim) { - return this.config.linter.modelsim.verilog_arguments; - } - else if (linter_name === e_linter_general_linter_verilog.verilator) { - return this.config.linter.verilator.arguments; - } - else if (linter_name === e_linter_general_linter_verilog.vivado) { - return this.config.linter.vivado.verilog_arguments; - } - else { - return ""; - } - } +} - public get_style_linter_config_vhdl(): string { - const linter_name = this.config.linter.general.lstyle_vhdl; - if (linter_name === e_linter_general_lstyle_vhdl.vsg) { - return this.config.linter.vsg.arguments; - } - else { - return ""; - } - } +export function create_copy_with_undefined_values>(obj: T): T { + const result: Record = {}; - public get_style_linter_config_verilog(): string { - const linter_name = this.config.linter.general.lstyle_verilog; - if (linter_name === e_linter_general_lstyle_verilog.verible) { - return this.config.linter.verible.arguments; - } - else { - return ""; + for (const key in obj) { + const value = obj[key]; + if (value !== null && typeof value === 'object' && !Array.isArray(value)) { + result[key] = create_copy_with_undefined_values(value); + } else { + result[key] = undefined as any; } } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Formatter - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public get_formatter_name_vhdl() { - return this.config.formatter.general.formatter_vhdl; - } + return result as T; +} - public get_formatter_name_verilog() { - return this.config.formatter.general.formatter_verilog; - } +export function merge_configs>(main_config: T, default_config: T): T { - public get_formatter_config_vhdl() { - const formatter_name = this.get_formatter_name_vhdl(); - if (formatter_name === e_formatter_general_formatter_vhdl.standalone) { - return this.config.formatter.standalone; - } - else if (formatter_name === e_formatter_general_formatter_vhdl.vsg) { - return this.config.formatter.svg; - } - else { - return this.config.formatter.standalone; - } - } + const result: Record = {}; - public get_formatter_config_verilog() { - const formatter_name = this.get_formatter_name_verilog(); - if (formatter_name === e_formatter_general_formatter_verilog.istyle) { - return this.config.formatter.istyle; - } - else if (formatter_name === e_formatter_general_formatter_verilog.s3sv) { - return this.config.formatter.s3sv; - } - else if (formatter_name === e_formatter_general_formatter_verilog.verible) { - const config = { - format_args : this.config.formatter.verible.format_args, - path: this.config.tools.verible.installation_path - }; - return config; - } - else { - return this.config.formatter.istyle; - } - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Exec - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public get_exec_config(): cfg_aux.t_exec_config { - const exec_config: cfg_aux.t_exec_config = { - execution_mode: this.config.tools.general.execution_mode, - python_path: this.config.general.general.pypath, - developer_mode: this.config.general.general.developer_mode, - waveform_viewer: this.config.tools.general.waveform_viewer - }; - return exec_config; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Template - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public get_template_config(): cfg_aux.t_template_options { - const options: cfg_aux.t_template_options = { - header_file_path: this.config.templates.general.header_file_path, - indent_char: this.config.templates.general.indent, - clock_generation_style: this.config.templates.general.clock_generation_style, - instance_style: this.config.templates.general.instance_style - }; - return options; - } + const keys = Array.from(new Set([...Object.keys(main_config), ...Object.keys(default_config)])); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Documenter - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public get_documenter_config(): cfg_aux.t_documenter_options { - const options: cfg_aux.t_documenter_options = { - generic_visibility: this.config.documentation.general.generics, - port_visibility: this.config.documentation.general.ports, - signal_visibility: this.config.documentation.general.signals, - constant_visibility: this.config.documentation.general.constants, - type_visibility: this.config.documentation.general.types, - function_visibility: this.config.documentation.general.functions, - instantiation_visibility: this.config.documentation.general.instantiations, - process_visibility: this.config.documentation.general.process, - language: this.config.documentation.general.language, - vhdl_symbol: this.config.documentation.general.symbol_vhdl, - verilog_symbol: this.config.documentation.general.symbol_verilog, - enable_fsm: this.config.documentation.general.fsm - }; - return options; - } + keys.forEach((key) => { + const value1 = main_config[key]; + const value2 = default_config[key]; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Tools - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public get_tool_options(): cfg_aux.t_tool_options { - const tool_name = this.config.tools.general.select_tool; - const tool_config = (this.config.tools)[tool_name]; - const tool_options: cfg_aux.t_tool_options = { - name: this.config.tools.general.select_tool, - installation_path: tool_config['installation_path'], - config: tool_config - }; - return tool_options; - } + if (value1 !== undefined && value2 !== undefined + && typeof value1 === typeof value2 + && typeof value1 === 'object' && !Array.isArray(value1)) { + // Both are object, so merge them + result[key] = merge_configs(value1, value2); + } else if (value1 !== undefined) { + // Keep main one + result[key] = value1; + } else { + // Use default one + result[key] = value2; + } + }); - public get_tool_name(): e_tools_general_select_tool { - return this.config.tools.general.select_tool; - } -} + return result as T; -export function merge_configs(general_config: e_config | undefined, secondary_config: e_config) { - if (general_config === undefined) { - return secondary_config; - } - return general_config; } \ No newline at end of file diff --git a/packages/colibri/src/config/helpers/config_declaration.nj b/packages/colibri/src/config/helpers/config_declaration.nj index b911b699..f35952cf 100644 --- a/packages/colibri/src/config/helpers/config_declaration.nj +++ b/packages/colibri/src/config/helpers/config_declaration.nj @@ -25,6 +25,9 @@ export type e_config = { {%- endfor %} } {%- endfor %} + [key: string]: { + [key: string]: any; + }; }; {%- for tp0 in type_declaration -%} diff --git a/packages/colibri/src/project_manager/multi_project_manager.ts b/packages/colibri/src/project_manager/multi_project_manager.ts index 9b0e8f21..30bc888c 100644 --- a/packages/colibri/src/project_manager/multi_project_manager.ts +++ b/packages/colibri/src/project_manager/multi_project_manager.ts @@ -17,10 +17,8 @@ // You should have received a copy of the GNU General Public License // along with TerosHDL. If not, see . -import { e_project_type, t_action_result } from "./common"; -import { Config_manager } from "../config/config_manager"; +import { e_project_type } from "./common"; import { Project_manager } from "./project_manager"; -import { e_config } from "../config/config_declaration"; import * as file_utils from "../utils/file_utils"; import { QuartusProjectManager } from "./tool/quartus/quartusProjectManager"; @@ -43,11 +41,9 @@ class ProjectOperationError extends Error { export class Multi_project_manager { private project_manager_list: Project_manager[] = []; private selected_project: Project_manager | undefined = undefined; - private global_config: Config_manager; private sync_file_path = ""; - constructor(global_config_sync_path: string, sync_file_path = "") { - this.global_config = new Config_manager(global_config_sync_path); + constructor(sync_file_path = "") { this.sync_file_path = sync_file_path; } @@ -111,15 +107,9 @@ export class Multi_project_manager { for (const prj_info of prj_saved.project_list) { try { if (prj_info.project_type === e_project_type.QUARTUS) { - this.add_project( - await QuartusProjectManager.fromJson(this.get_config_global_config(), prj_info, - emitterProject) - ); + this.add_project(await QuartusProjectManager.fromJson(prj_info, emitterProject)); } else { - this.add_project( - await Project_manager.fromJson(this.get_config_global_config(), - prj_info, emitterProject) - ); + this.add_project(await Project_manager.fromJson(prj_info, emitterProject)); } } catch (error) { failed = true; @@ -253,49 +243,4 @@ export class Multi_project_manager { } } - //////////////////////////////////////////////////////////////////////////// - // Config - //////////////////////////////////////////////////////////////////////////// - public get_config_manager() { - // // Selected project config - // const selected_prj = this.get_select_project(); - // let prj_config = undefined; - // if (selected_prj.successful === true) { - // prj_config = selected_prj.result.get_config_manager(); - // } - // Glogal config - const global_config = this.global_config.get_config(); - // Merge configs - const config_manager = new Config_manager(); - // config_manager.set_config(merge_configs(global_config, prj_config)); - - config_manager.set_config(global_config); - - - return config_manager; - } - - public set_global_config(config: e_config) { - this.global_config.set_config(config); - return this.get_sucessful_result(undefined); - } - - public set_global_config_from_json(config: any) { - this.global_config.set_config_from_json(config); - return this.get_sucessful_result(undefined); - } - - public get_config_global_config() { - return this.global_config.get_config(); - } - - private get_sucessful_result(result_i: any): t_action_result { - const result: t_action_result = { - result: result_i, - successful: true, - msg: "" - }; - return result; - } - } diff --git a/packages/colibri/src/project_manager/prj_loaders/vunit_loader.ts b/packages/colibri/src/project_manager/prj_loaders/vunit_loader.ts index 70cf4aba..1bf709e3 100644 --- a/packages/colibri/src/project_manager/prj_loaders/vunit_loader.ts +++ b/packages/colibri/src/project_manager/prj_loaders/vunit_loader.ts @@ -17,7 +17,6 @@ // along with TerosHDL. If not, see . import { e_config } from "../../config/config_declaration"; -import { Config_manager } from "../../config/config_manager"; import { python } from "../../process/export_t"; import { t_file } from "../common"; import { Vunit } from "../tool/vunit/vunit"; @@ -28,16 +27,13 @@ import { t_loader_file_list_result } from "../tool/common"; export async function get_files_from_vunit(config: e_config, vunit_path: string, is_manual: boolean ): Promise { - const n_config_manager = new Config_manager(); - n_config_manager.set_config(config); - const vunit = new Vunit(); const simulator_name = config.tools.vunit.simulator_name; const simulator_install_path = vunit.get_simulator_installation_path(config); const simulator_conf = vunit.get_simulator_config(simulator_name, simulator_install_path); - const py_path = n_config_manager.get_config().general.general.pypath; + const py_path = config.general.general.pypath; const json_path = process_utils.create_temp_file(""); const args = `--export-json ${json_path}`; const result = await python.exec_python_script(py_path, vunit_path, args, simulator_conf); diff --git a/packages/colibri/src/project_manager/project_definition.ts b/packages/colibri/src/project_manager/project_definition.ts index 2d4d1ec8..afac6c6e 100644 --- a/packages/colibri/src/project_manager/project_definition.ts +++ b/packages/colibri/src/project_manager/project_definition.ts @@ -21,9 +21,9 @@ import { File_manager } from "./list_manager/file"; import { Hook_manager } from "./list_manager/hook"; import { Parameter_manager } from "./list_manager/parameter"; import { Toplevel_path_manager } from "./list_manager/toplevel_path"; -import { Config_manager } from "../config/config_manager"; import { Watcher_manager } from "./list_manager/watcher"; import { e_project_type } from "./common"; +import { e_config } from "../config/config_declaration"; export type t_project_definition = { name: string, @@ -34,5 +34,5 @@ export type t_project_definition = { parameter_manager: Parameter_manager, toplevel_path_manager: Toplevel_path_manager, watcher_manager: Watcher_manager - config_manager: Config_manager + config: e_config } \ No newline at end of file diff --git a/packages/colibri/src/project_manager/project_manager.ts b/packages/colibri/src/project_manager/project_manager.ts index 33e034e7..b3e6712f 100644 --- a/packages/colibri/src/project_manager/project_manager.ts +++ b/packages/colibri/src/project_manager/project_manager.ts @@ -38,8 +38,8 @@ import { import { t_project_definition } from "./project_definition"; import * as file_utils from "../utils/file_utils"; import * as hdl_utils from "../utils/hdl_utils"; -import { Config_manager, merge_configs } from "../config/config_manager"; -import { e_config } from "../config/config_declaration"; +import { ConfigManager, GlobalConfigManager, create_copy_with_undefined_values, merge_configs } from "../config/config_manager"; +import { e_config, get_default_config } from "../config/config_declaration"; import * as utils from "./utils/utils"; import * as python from "../process/python"; import * as events from "events"; @@ -55,7 +55,7 @@ import { ChildProcess } from "child_process"; import { p_result } from "../process/common"; import { TaskStateManager } from "./tool/taskState"; -export class Project_manager { +export class Project_manager extends ConfigManager { /** Name of the project */ private name: string; /** Path of the project */ @@ -71,8 +71,6 @@ export class Project_manager { private parameters = new manager_parameter.Parameter_manager(); /** Toplevel path(s) for the project. */ private toplevel_path = new manager_toplevel_path.Toplevel_path_manager(); - /** Config manager. */ - private config_manager = new Config_manager(); private tools_manager = new Tool_manager(undefined); private emitterProject: events.EventEmitter; /** Linter */ @@ -80,6 +78,7 @@ export class Project_manager { public taskStateManager: TaskStateManager = new TaskStateManager([]); constructor(name: string, emitterProject: events.EventEmitter) { + super(create_copy_with_undefined_values(get_default_config())); this.name = name; this.emitterProject = emitterProject; // eslint-disable-next-line @typescript-eslint/no-this-alias @@ -95,10 +94,10 @@ export class Project_manager { selfm.add_file_from_csv(watcher.path, false); } else if (watcher.watcher_type === e_watcher_type.VUNIT) { - await selfm.add_file_from_vunit(selfm.config_manager.get_config(), watcher.path, false); + await selfm.add_file_from_vunit(watcher.path, false); } else if (watcher.watcher_type === e_watcher_type.VIVADO) { - await selfm.add_file_from_vivado(selfm.config_manager.get_config(), watcher.path, false); + await selfm.add_file_from_vivado(watcher.path, false); } if (selfm.emitterProject !== undefined) { selfm.emitterProject.emit('loaded'); @@ -154,8 +153,8 @@ export class Project_manager { //////////////////////////////////////////////////////////////////////////// // Project //////////////////////////////////////////////////////////////////////////// - static async fromJson(_config: e_config, jsonContent: any, emitterProject: events.EventEmitter) - : Promise { + static async fromJson(jsonContent: any, emitterProject: events.EventEmitter): + Promise { const prj = new Project_manager(jsonContent.name, emitterProject); // Files jsonContent.files.forEach((file: any) => { @@ -278,15 +277,11 @@ export class Project_manager { //////////////////////////////////////////////////////////////////////////// // File //////////////////////////////////////////////////////////////////////////// - async add_file_from_quartus(general_config: e_config | undefined, vivado_path: string, is_manual: boolean) + async add_file_from_quartus(vivado_path: string, is_manual: boolean) : Promise { - const n_config = merge_configs(general_config, this.config_manager.get_config()); - const n_config_manager = new Config_manager(); - n_config_manager.set_config(n_config); - try { - const fileList = await getFilesFromProject(n_config, vivado_path, is_manual); + const fileList = await getFilesFromProject(this.get_config(), vivado_path, is_manual); this.add_file_from_array(fileList); } catch (error) { @@ -294,14 +289,10 @@ export class Project_manager { } } - async add_file_from_vivado(general_config: e_config | undefined, vivado_path: string, is_manual: boolean) + async add_file_from_vivado(vivado_path: string, is_manual: boolean) : Promise { - const n_config = merge_configs(general_config, this.config_manager.get_config()); - const n_config_manager = new Config_manager(); - n_config_manager.set_config(n_config); - - const result = await get_files_from_vivado(n_config, vivado_path, is_manual); + const result = await get_files_from_vivado(this.get_config(), vivado_path, is_manual); this.add_file_from_array(result.file_list); const action_result: t_action_result = { result: result.file_list, @@ -311,14 +302,10 @@ export class Project_manager { return action_result; } - async add_file_from_vunit(general_config: e_config | undefined, vunit_path: string, is_manual: boolean + async add_file_from_vunit(vunit_path: string, is_manual: boolean ): Promise { - const n_config = merge_configs(general_config, this.config_manager.get_config()); - const n_config_manager = new Config_manager(); - n_config_manager.set_config(n_config); - - const result = await get_files_from_vunit(n_config, vunit_path, is_manual); + const result = await get_files_from_vunit(this.get_config(), vunit_path, is_manual); this.add_file_from_array(result.file_list); const action_result: t_action_result = { @@ -408,21 +395,14 @@ export class Project_manager { //////////////////////////////////////////////////////////////////////////// // Config //////////////////////////////////////////////////////////////////////////// - public set_config(new_config: e_config) { - this.config_manager.set_config(new_config); - } public get_config(): e_config { - return this.config_manager.get_config(); + return merge_configs(super.get_config(), GlobalConfigManager.getInstance().get_config()); } //////////////////////////////////////////////////////////////////////////// // Utils //////////////////////////////////////////////////////////////////////////// - public get_project_definition(config_manager: Config_manager | undefined = undefined): t_project_definition { - let current_config_manager = config_manager; - if (current_config_manager === undefined) { - current_config_manager = this.config_manager; - } + public get_project_definition(): t_project_definition { const prj_definition: t_project_definition = { name: this.name, project_disk_path: this.projectDiskPath, @@ -432,7 +412,7 @@ export class Project_manager { parameter_manager: this.parameters, toplevel_path_manager: this.toplevel_path, watcher_manager: this.watchers, - config_manager: current_config_manager + config: this.get_config() }; return prj_definition; } @@ -475,41 +455,26 @@ export class Project_manager { //////////////////////////////////////////////////////////////////////////// // Tool //////////////////////////////////////////////////////////////////////////// - public async run(general_config: e_config | undefined, test_list: t_test_declaration[], + public async run(test_list: t_test_declaration[], callback: (result: t_test_result[]) => void, callback_stream: (stream_c: any) => void): Promise { - const n_config = merge_configs(general_config, this.config_manager.get_config()); - const n_config_manager = new Config_manager(); - n_config_manager.set_config(n_config); - const python_result = await python.get_python_path( - { "path": n_config_manager.get_config().general.general.pypath }); + { "path": this.get_config().general.general.pypath }); await this.files.order(python_result.python_path); - const prj_def = this.get_project_definition(n_config_manager); + const prj_def = this.get_project_definition(); return this.tools_manager.run(prj_def, test_list, callback, callback_stream); } - public clean(general_config: e_config | undefined, - clean_mode: e_clean_step, - callback_stream: (stream_c: any) => void): any { - - const n_config = merge_configs(general_config, this.config_manager.get_config()); - const n_config_manager = new Config_manager(); - n_config_manager.set_config(n_config); - - return this.tools_manager.clean(this.get_project_definition(n_config_manager), clean_mode, callback_stream); + public clean(clean_mode: e_clean_step, callback_stream: (stream_c: any) => void): any { + return this.tools_manager.clean(this.get_project_definition(), clean_mode, callback_stream); } - public async get_test_list(general_config: e_config | undefined = undefined): Promise { - - const n_config = merge_configs(general_config, this.config_manager.get_config()); - const n_config_manager = new Config_manager(); - n_config_manager.set_config(n_config); + public async get_test_list(): Promise { - return await this.tools_manager.get_test_list(this.get_project_definition(n_config_manager)); + return await this.tools_manager.get_test_list(this.get_project_definition()); } public getBuildSteps(): t_taskRep[] { diff --git a/packages/colibri/src/project_manager/tool/cocotb/cocotb.ts b/packages/colibri/src/project_manager/tool/cocotb/cocotb.ts index 82726775..971b756e 100644 --- a/packages/colibri/src/project_manager/tool/cocotb/cocotb.ts +++ b/packages/colibri/src/project_manager/tool/cocotb/cocotb.ts @@ -133,8 +133,12 @@ export class Cocotb extends Generic_tool_handler { working_directory: string, callback: (result: t_test_result[]) => void, callback_stream: (stream_c: any) => void) { - const execution_config = prj.config_manager.get_exec_config(); - const config = prj.config_manager.get_config(); + const execution_config = { + execution_mode: prj.config.tools.general.execution_mode, + python_path: prj.config.general.general.pypath, + developer_mode: prj.config.general.general.developer_mode, + waveform_viewer: prj.config.tools.general.waveform_viewer + }; // Get toplevel entity from toplevel path const toplevel_path = prj.toplevel_path_manager.get()[0]; @@ -159,7 +163,7 @@ export class Cocotb extends Generic_tool_handler { name: tst.name, edam: edam_json, config_summary_path: path_f, - config: config, + config: prj.config, artifact: [], build_path: working_directory, successful: tst.successful, @@ -288,7 +292,7 @@ export class Cocotb extends Generic_tool_handler { const export_s = process_utils.get_sentence_os(e_sentence.EXPORT); const more_s = process_utils.get_sentence_os(e_sentence.MORE); - const tool_option = prj.config_manager.get_config().tools.cocotb; + const tool_option = prj.config.tools.cocotb; // eslint-disable-next-line max-len const compile_args = tool_option.compile_args === '' ? '' : `${export_s} COMPILE_ARGS=${tool_option.compile_args}${more_s} `; @@ -305,7 +309,7 @@ export class Cocotb extends Generic_tool_handler { } private get_simulator(prj: t_project_definition): string { - const tool_option = prj.config_manager.get_config().tools.cocotb; + const tool_option = prj.config.tools.cocotb; const simulator_name = tool_option.simulator_name; const export_s = process_utils.get_sentence_os(e_sentence.EXPORT); const more_s = process_utils.get_sentence_os(e_sentence.MORE); diff --git a/packages/colibri/src/project_manager/tool/edalize/edalize.ts b/packages/colibri/src/project_manager/tool/edalize/edalize.ts index ac532e7e..7e5e4c05 100644 --- a/packages/colibri/src/project_manager/tool/edalize/edalize.ts +++ b/packages/colibri/src/project_manager/tool/edalize/edalize.ts @@ -74,7 +74,7 @@ export class Edalize extends Generic_tool_handler { test_list.forEach(test => { top_level_list.push(test.name); }); - const config = prj.config_manager.get_config(); + const config = prj.config; // Save EDAM project in JSON file let edam_json = get_edam_json(prj, top_level_list); diff --git a/packages/colibri/src/project_manager/tool/osvvm/osvvm.ts b/packages/colibri/src/project_manager/tool/osvvm/osvvm.ts index a062fcf1..3ae51785 100644 --- a/packages/colibri/src/project_manager/tool/osvvm/osvvm.ts +++ b/packages/colibri/src/project_manager/tool/osvvm/osvvm.ts @@ -87,7 +87,7 @@ export class Osvvm extends Generic_tool_handler { const edam_json = get_edam_json(prj, top_level_list); // Get config - const config = prj.config_manager.get_config(); + const config = prj.config; const simulator_name = config.tools.osvvm.simulator_name; const osvvm_installation_path = config.tools.osvvm.installation_path; @@ -324,8 +324,8 @@ exit } get_simulator_installation_path(prj: t_project_definition): string { - const config = prj.config_manager.get_config(); - const simulator_name = prj.config_manager.get_config().tools.osvvm.simulator_name; + const config = prj.config; + const simulator_name = prj.config.tools.osvvm.simulator_name; let installation_path = ""; try { diff --git a/packages/colibri/src/project_manager/tool/quartus/quartusProjectManager.ts b/packages/colibri/src/project_manager/tool/quartus/quartusProjectManager.ts index e1d555f0..8e2882e9 100644 --- a/packages/colibri/src/project_manager/tool/quartus/quartusProjectManager.ts +++ b/packages/colibri/src/project_manager/tool/quartus/quartusProjectManager.ts @@ -22,6 +22,7 @@ import { get_directory } from "../../../utils/file_utils"; import { getDefaultTaskList } from "./common"; import { TaskStateManager } from "../taskState"; import { setStatus } from "./quartusDB"; +import { GlobalConfigManager } from "../../../config/config_manager"; export class QuartusProjectManager extends Project_manager { @@ -84,11 +85,11 @@ export class QuartusProjectManager extends Project_manager { return e_project_type.QUARTUS; } - static async fromJson(config: e_config, jsonContent: any, emitterProject: events.EventEmitter) - : Promise { + static async fromJson(jsonContent: any, emitterProject: events.EventEmitter): + Promise { try { const projectPath = jsonContent.project_disk_path; - return await this.fromExistingQuartusProject(config, projectPath, emitterProject); + return await this.fromExistingQuartusProject(GlobalConfigManager.getInstance().get_config(), projectPath, emitterProject); } catch (error) { throw new QuartusExecutionError("Error in Quartus execution"); diff --git a/packages/colibri/src/project_manager/tool/raptor/prj_creator.ts b/packages/colibri/src/project_manager/tool/raptor/prj_creator.ts index 3535b5bf..68572a97 100644 --- a/packages/colibri/src/project_manager/tool/raptor/prj_creator.ts +++ b/packages/colibri/src/project_manager/tool/raptor/prj_creator.ts @@ -26,7 +26,7 @@ import { LANGUAGE } from "../../../common/general"; export function get_tcl_script(prj: t_project_definition, is_clean_mode: boolean, clean_step: e_clean_step | undefined): string { const file_list = prj.file_manager.get(); - const config = prj.config_manager.get_config().tools.raptor; + const config = prj.config.tools.raptor; //////////////////////////////////////////////////////////////////////////// // Design project diff --git a/packages/colibri/src/project_manager/tool/raptor/raptor.ts b/packages/colibri/src/project_manager/tool/raptor/raptor.ts index d7b8c7ef..b961d72d 100644 --- a/packages/colibri/src/project_manager/tool/raptor/raptor.ts +++ b/packages/colibri/src/project_manager/tool/raptor/raptor.ts @@ -69,7 +69,7 @@ export class Raptor extends Generic_tool_handler { // const edam_json = get_edam_json(prj, top_level_list); // Get config - const config = prj.config_manager.get_config(); + const config = prj.config; let installation_path = config.tools.raptor.installation_path; if (installation_path === ""){ @@ -119,7 +119,7 @@ export class Raptor extends Generic_tool_handler { } // Get config - const config = prj.config_manager.get_config(); + const config = prj.config; let installation_path = config.tools.raptor.installation_path; if (installation_path === ""){ diff --git a/packages/colibri/src/project_manager/tool/tools_manager.ts b/packages/colibri/src/project_manager/tool/tools_manager.ts index cd0a5eae..17e40ce4 100644 --- a/packages/colibri/src/project_manager/tool/tools_manager.ts +++ b/packages/colibri/src/project_manager/tool/tools_manager.ts @@ -56,7 +56,7 @@ export class Tool_manager { } public async get_test_list(prj: t_project_definition): Promise { - const tool_name = prj.config_manager.get_tool_name(); + const tool_name = prj.config.tools.general.select_tool; const tool_handler = this.get_tool_handler(tool_name); return await tool_handler.get_test_list(prj); } @@ -65,13 +65,13 @@ export class Tool_manager { callback: (result: t_test_result[]) => void, callback_stream: (stream_c: any) => void) { - const tool_name = prj.config_manager.get_config().tools.general.select_tool; + const tool_name = prj.config.tools.general.select_tool; const tool_handler = this.get_tool_handler(tool_name); return tool_handler.run(prj, test_list, this.working_directory, callback, callback_stream); } public clean(prj: t_project_definition, clean_mode: e_clean_step, callback_stream: (stream_c: any) => void) { - const tool_name = prj.config_manager.get_config().tools.general.select_tool; + const tool_name = prj.config.tools.general.select_tool; const tool_handler = this.get_tool_handler(tool_name); return tool_handler.clean(prj, this.working_directory, clean_mode, callback_stream); } diff --git a/packages/colibri/src/project_manager/tool/vunit/vunit.ts b/packages/colibri/src/project_manager/tool/vunit/vunit.ts index 7533c78f..227e01cf 100644 --- a/packages/colibri/src/project_manager/tool/vunit/vunit.ts +++ b/packages/colibri/src/project_manager/tool/vunit/vunit.ts @@ -50,7 +50,7 @@ export class Vunit extends Generic_tool_handler { private create_runpy(prj: t_project_definition): string { const template_path = paht_lib.join(__dirname, 'run.nj'); - const vunit_config = prj.config_manager.get_config().tools.vunit; + const vunit_config = prj.config.tools.vunit; const template = nunjucks.render(template_path, { file_list: prj.file_manager.get(), @@ -63,7 +63,7 @@ export class Vunit extends Generic_tool_handler { public async get_test_list(prj: t_project_definition): Promise { let toplevel_path_list = prj.toplevel_path_manager.get(); - const config = prj.config_manager.get_config(); + const config = prj.config; // Create runpy if (config.tools.vunit.runpy_mode === t_config.e_tools_vunit_runpy_mode.creation) { toplevel_path_list = [this.create_runpy(prj)]; @@ -166,7 +166,7 @@ export class Vunit extends Generic_tool_handler { name: tst.name, edam: edam_json, config_summary_path: path_f, - config: prj.config_manager.get_config(), + config: prj.config, artifact: log_artifact, build_path: working_directory, successful: tst.successful, @@ -202,7 +202,7 @@ export class Vunit extends Generic_tool_handler { output_path: string, callback: (result: p_result) => void, callback_stream: (stream_c: any) => void) { // Config - const config = prj.config_manager.get_config(); + const config = prj.config; const python_path = config.general.general.pypath; // GUI execution @@ -220,7 +220,7 @@ export class Vunit extends Generic_tool_handler { // Simulator config const simulator_name = config.tools.vunit.simulator_name; - const simulator_install_path = this.get_simulator_installation_path(prj.config_manager.get_config()); + const simulator_install_path = this.get_simulator_installation_path(prj.config); const simulator_config = this.get_simulator_config(simulator_name, simulator_install_path); let python_script = prj.toplevel_path_manager.get()[0]; diff --git a/packages/colibri/src/project_manager/utils/utils.ts b/packages/colibri/src/project_manager/utils/utils.ts index 65d2a2cd..212792c1 100644 --- a/packages/colibri/src/project_manager/utils/utils.ts +++ b/packages/colibri/src/project_manager/utils/utils.ts @@ -26,8 +26,14 @@ import { Database } from 'sqlite3'; export function get_edam_json(prj: t_project_definition, top_level_list: undefined | string[], refrence_path?: string) { - const tool_name = prj.config_manager.get_tool_name(); - const tool_options = prj.config_manager.get_tool_options(); + const tool_name = prj.config.tools.general.select_tool; + const tool_config = (prj.config.tools)[tool_name]; + const tool_options = { + name: tool_name, + installation_path: tool_config['installation_path'], + config: tool_config + }; + const tmp_edam_0 = `{ "${tool_name}" : ${JSON.stringify(tool_options)} }`; const tmp_edam_1 = JSON.parse(tmp_edam_0); diff --git a/packages/colibri/tests/multi_project_manager/multi_project_manager.spec.ts b/packages/colibri/tests/multi_project_manager/multi_project_manager.spec.ts index fbe7d0bf..4c7243c5 100644 --- a/packages/colibri/tests/multi_project_manager/multi_project_manager.spec.ts +++ b/packages/colibri/tests/multi_project_manager/multi_project_manager.spec.ts @@ -17,6 +17,7 @@ // along with colibri2. If not, see . import { EventEmitter } from 'stream'; +import { GlobalConfigManager } from '../../src/config/config_manager'; import { e_project_type } from '../../src/project_manager/common'; import { Multi_project_manager } from '../../src/project_manager/multi_project_manager'; import { Project_manager } from '../../src/project_manager/project_manager'; @@ -42,7 +43,7 @@ jest.mock('../../src/utils/file_utils', () => ({ jest.mock('../../src/project_manager/project_manager', () => { const originalModule = jest.requireActual('../../src/project_manager/project_manager'); - originalModule.Project_manager.fromJson = jest.fn(async (_config, jsonContent, emitter) => { + originalModule.Project_manager.fromJson = jest.fn(async (jsonContent, emitter) => { return new originalModule.Project_manager(jsonContent.name, emitter); }); @@ -52,7 +53,7 @@ jest.mock('../../src/project_manager/project_manager', () => { jest.mock('../../src/project_manager/tool/quartus/quartusProjectManager', () => { const originalModule = jest.requireActual('../../src/project_manager/tool/quartus/quartusProjectManager'); - originalModule.QuartusProjectManager.fromJson = jest.fn(async (_config, jsonContent, emitter) => { + originalModule.QuartusProjectManager.fromJson = jest.fn(async (jsonContent, emitter) => { return new originalModule.QuartusProjectManager(jsonContent.name, "", "", emitter); }); @@ -63,7 +64,7 @@ describe('MultiProjectManager', () => { let multiProjectManager: Multi_project_manager; beforeEach(() => { - multiProjectManager = new Multi_project_manager("", sync_file_path); + multiProjectManager = new Multi_project_manager(sync_file_path); }); function create_project_with_name_and_add(prj_name: string): Project_manager { @@ -485,6 +486,7 @@ describe('MultiProjectManager', () => { describe('save', () => { beforeEach(() => { + GlobalConfigManager.newInstance(""); jest.clearAllMocks(); }); diff --git a/packages/colibri/tests/project_manager/project_manager.spec.ts b/packages/colibri/tests/project_manager/project_manager.spec.ts index e2421816..6d3bd510 100644 --- a/packages/colibri/tests/project_manager/project_manager.spec.ts +++ b/packages/colibri/tests/project_manager/project_manager.spec.ts @@ -24,6 +24,7 @@ import {Project_manager} from '../../src/project_manager/project_manager'; import {get_default_config} from '../../src/config/config_declaration'; import { LANGUAGE, VHDL_LANG_VERSION } from "../../src/common/general"; import EventEmitter = require("events"); +import { GlobalConfigManager } from "../../src/config/config_manager"; const DEFAULT_NAME = "def_name"; @@ -279,7 +280,8 @@ describe('project_manager', () => { project_manager.add_file(file_0); project_manager.add_file(file_1); - + + GlobalConfigManager.newInstance(""); const project_definition = project_manager.get_project_definition(); expect(project_definition.name).toBe(DEFAULT_NAME); expect(project_definition.file_manager.get()[0].name).toBe(file_0.name); @@ -327,11 +329,13 @@ describe('project_manager', () => { }); test('set_config, get_config', () => { - const default_config = get_default_config(); - default_config.tools.ghdl.installation_path = "ghdl_path"; + GlobalConfigManager.newInstance(""); + + const new_config = get_default_config(); + new_config.tools.ghdl.installation_path = "ghdl_path"; - project_manager.set_config(default_config); - expect(project_manager.get_config()).toBe(default_config); + project_manager.set_config(new_config); + expect(project_manager.get_config()).toStrictEqual(new_config); }); }); \ No newline at end of file diff --git a/packages/teroshdl/src/features/comander/run.ts b/packages/teroshdl/src/features/comander/run.ts index 604986c2..dc6011cb 100644 --- a/packages/teroshdl/src/features/comander/run.ts +++ b/packages/teroshdl/src/features/comander/run.ts @@ -26,6 +26,7 @@ import { OS } from "teroshdl2/out/process/common"; import { get_os } from "teroshdl2/out/process/utils"; import * as path_lib from 'path'; import { Logger } from '../../logger'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; export class Comander { @@ -64,14 +65,14 @@ export class Comander { } let gtkwave_path = ""; - let base_path = this.manager.get_config_manager().get_config().tools.general.gtkwave_installation_path; + let base_path = GlobalConfigManager.getInstance().get_config().tools.general.gtkwave_installation_path; if (base_path !== "") { gtkwave_path = path_lib.join(base_path, gtkwave_binary); } else { gtkwave_path = gtkwave_binary; } - const extra_arguments = this.manager.get_config_manager().get_config().tools.general.gtkwave_extra_arguments; + const extra_arguments = GlobalConfigManager.getInstance().get_config().tools.general.gtkwave_extra_arguments; let command = `${gtkwave_path} ${file_path} ${extra_arguments}`; shelljs.exec(command, { async: true }); diff --git a/packages/teroshdl/src/features/config.ts b/packages/teroshdl/src/features/config.ts index 8d68ee8e..267e6ec6 100644 --- a/packages/teroshdl/src/features/config.ts +++ b/packages/teroshdl/src/features/config.ts @@ -22,6 +22,7 @@ import * as teroshdl2 from 'teroshdl2'; import { t_Multi_project_manager } from '../type_declaration'; import * as utils from '../utils/utils'; import * as nunjucks from 'nunjucks'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; export class Config_manager { @@ -125,8 +126,7 @@ export class Config_manager { vscode.window.showSaveDialog({title: "Export TerosHDL configuration"}).then(fileInfos => { if (fileInfos?.path !== undefined) { const path_norm = utils.normalize_path(fileInfos?.path); - const config = this.manager.get_config_global_config(); - const config_string = JSON.stringify(config, null, 4); + const config_string = GlobalConfigManager.getInstance().toString(); teroshdl2.utils.file.save_file_sync(path_norm, config_string); } }); @@ -148,16 +148,16 @@ export class Config_manager { async update_web_config(){ await this.panel?.webview.postMessage({ command: "set_config", - config: this.manager.get_config_global_config() + config: GlobalConfigManager.getInstance().get_config() }); } set_config(config: any){ - this.manager.set_global_config_from_json(config); + GlobalConfigManager.getInstance().set_config(config); } set_config_and_close(config: any){ - this.manager.set_global_config_from_json(config); + GlobalConfigManager.getInstance().set_config(config); this.close_panel(); } diff --git a/packages/teroshdl/src/features/dependency.ts b/packages/teroshdl/src/features/dependency.ts index bf68776a..b75e12ec 100644 --- a/packages/teroshdl/src/features/dependency.ts +++ b/packages/teroshdl/src/features/dependency.ts @@ -23,6 +23,7 @@ import * as fs from 'fs'; import { t_Multi_project_manager } from '../type_declaration'; import * as nunjucks from 'nunjucks'; import { Logger } from '../logger'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; const base_path = "dependencies_viewer"; @@ -136,7 +137,7 @@ export class Dependency_manager { } try { const selected_project = this.manager.get_selected_project(); - const python_path = this.manager.get_config_manager().get_config().general.general.pypath; + const python_path = GlobalConfigManager.getInstance().get_config().general.general.pypath; const result = await selected_project.get_dependency_graph(python_path); if (result.successful === false) { this.logger.error("Error while getting dependency graph.", true); diff --git a/packages/teroshdl/src/features/documenter.ts b/packages/teroshdl/src/features/documenter.ts index 0b85afe8..553dca7a 100644 --- a/packages/teroshdl/src/features/documenter.ts +++ b/packages/teroshdl/src/features/documenter.ts @@ -26,6 +26,7 @@ import * as fs from 'fs'; import { t_Multi_project_manager } from '../type_declaration'; import { Base_webview } from './base_webview'; import { Logger } from '../logger'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; export class Documenter_manager extends Base_webview { @@ -135,8 +136,21 @@ export class Documenter_manager extends Base_webview { } private get_config(): teroshdl2.config.auxiliar_config.t_documenter_options { - const config = this.manager.get_config_manager().get_documenter_config(); - return config; + const config = GlobalConfigManager.getInstance().get_config(); + return { + generic_visibility: config.documentation.general.generics, + port_visibility: config.documentation.general.ports, + signal_visibility: config.documentation.general.signals, + constant_visibility: config.documentation.general.constants, + type_visibility: config.documentation.general.types, + function_visibility: config.documentation.general.functions, + instantiation_visibility: config.documentation.general.instantiations, + process_visibility: config.documentation.general.process, + language: config.documentation.general.language, + vhdl_symbol: config.documentation.general.symbol_vhdl, + verilog_symbol: config.documentation.general.symbol_verilog, + enable_fsm: config.documentation.general.fsm + }; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/packages/teroshdl/src/features/formatter.ts b/packages/teroshdl/src/features/formatter.ts index 7bb416ab..a69073c7 100644 --- a/packages/teroshdl/src/features/formatter.ts +++ b/packages/teroshdl/src/features/formatter.ts @@ -22,6 +22,8 @@ import * as teroshdl2 from 'teroshdl2'; import { t_Multi_project_manager } from '../type_declaration'; import * as utils from '../utils/utils'; import { Logger } from '../logger'; +import { e_formatter_general_formatter_verilog, e_formatter_general_formatter_vhdl } from 'teroshdl2/out/config/config_declaration'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; let formatter_vhdl: Formatter | undefined = undefined; let formatter_verilog: Formatter | undefined = undefined; @@ -44,35 +46,51 @@ class Formatter { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Configuration //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private get_config_manager() { - const config = this.manager.get_config_manager(); - return config; - } - private get_formatter_name() { - const config_manager = this.get_config_manager(); if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL) { - return config_manager.get_formatter_name_vhdl(); + return GlobalConfigManager.getInstance().get_config().formatter.general.formatter_vhdl; } else { - return config_manager.get_formatter_name_verilog(); + return GlobalConfigManager.getInstance().get_config().formatter.general.formatter_verilog; } } private get_formatter_config() { - const config_manager = this.get_config_manager(); if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL) { - return config_manager.get_formatter_config_vhdl(); - } + const formatter_name = GlobalConfigManager.getInstance().get_config().formatter.general.formatter_vhdl; + if (formatter_name === e_formatter_general_formatter_vhdl.standalone) { + return GlobalConfigManager.getInstance().get_config().formatter.standalone; + } + else if (formatter_name === e_formatter_general_formatter_vhdl.vsg) { + return GlobalConfigManager.getInstance().get_config().formatter.svg; + } + else { + return GlobalConfigManager.getInstance().get_config().formatter.standalone; + } + } else { - return config_manager.get_formatter_config_verilog(); + const formatter_name = GlobalConfigManager.getInstance().get_config().formatter.general.formatter_verilog; + if (formatter_name === e_formatter_general_formatter_verilog.istyle) { + return GlobalConfigManager.getInstance().get_config().formatter.istyle; + } + else if (formatter_name === e_formatter_general_formatter_verilog.s3sv) { + return GlobalConfigManager.getInstance().get_config().formatter.s3sv; + } + else if (formatter_name === e_formatter_general_formatter_verilog.verible) { + const config = { + format_args : GlobalConfigManager.getInstance().get_config().formatter.verible.format_args, + path: GlobalConfigManager.getInstance().get_config().tools.verible.installation_path + }; + return config; + } + else { + return GlobalConfigManager.getInstance().get_config().formatter.istyle; + } } } private get_pytyon_path() { - const config_manager = this.get_config_manager(); - const python_path = config_manager.get_exec_config().python_path; - return python_path; + return GlobalConfigManager.getInstance().get_config().general.general.pypath; } public async format(code) { diff --git a/packages/teroshdl/src/features/language_provider/language_provider.ts b/packages/teroshdl/src/features/language_provider/language_provider.ts index efc98751..019d9246 100644 --- a/packages/teroshdl/src/features/language_provider/language_provider.ts +++ b/packages/teroshdl/src/features/language_provider/language_provider.ts @@ -27,6 +27,7 @@ import { Logger } from "./ctags/Logger"; import * as vscode from 'vscode'; import { t_Multi_project_manager } from '../../type_declaration'; import * as rusthdl_lib from './lsp/rust_hdl'; +import { GlobalConfigManager } from "teroshdl2/out/config/config_manager"; export type e_provider = { 'completion': any, @@ -106,7 +107,7 @@ export class LanguageProviderManager { let is_alive = false; let rusthdl; - const enable_vhdl_provider = this.get_config().general.general.go_to_definition_vhdl; + const enable_vhdl_provider = GlobalConfigManager.getInstance().get_config().general.general.go_to_definition_vhdl; if (enable_vhdl_provider === true) { rusthdl = new rusthdl_lib.Rusthdl_lsp(this.context, this.manager); is_alive = await rusthdl.run_rusthdl(); @@ -139,7 +140,7 @@ export class LanguageProviderManager { this.context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(verilogSelector, this.provider_list.doc)); - const enable_verilog_provider = this.get_config().general.general.go_to_definition_verilog; + const enable_verilog_provider = GlobalConfigManager.getInstance().get_config().general.general.go_to_definition_verilog; if (enable_verilog_provider === true) { this.context.subscriptions.push(vscode.languages.registerHoverProvider(verilogSelector, this.provider_list.hover)); @@ -148,7 +149,4 @@ export class LanguageProviderManager { } } - private get_config(){ - return this.manager.get_config_manager().get_config(); - } } diff --git a/packages/teroshdl/src/features/language_provider/lsp/rust_hdl.ts b/packages/teroshdl/src/features/language_provider/lsp/rust_hdl.ts index f03095a4..96e4c8ca 100644 --- a/packages/teroshdl/src/features/language_provider/lsp/rust_hdl.ts +++ b/packages/teroshdl/src/features/language_provider/lsp/rust_hdl.ts @@ -20,6 +20,7 @@ import { LanguageClientOptions, ServerOptions, } from 'vscode-languageclient/node'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; const isWindows = process.platform === 'win32'; @@ -146,7 +147,7 @@ export class Rusthdl_lsp { } getServerOptionsEmbedded(context: ExtensionContext) { - const linter_name = this.manager.get_config_manager().get_config().linter.general.linter_vhdl; + const linter_name = GlobalConfigManager.getInstance().get_config().linter.general.linter_vhdl; let args: string[] = []; if (linter_name !== teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.none) { args = ['--no-lint']; diff --git a/packages/teroshdl/src/features/linter.ts b/packages/teroshdl/src/features/linter.ts index b58a673c..71177d6b 100644 --- a/packages/teroshdl/src/features/linter.ts +++ b/packages/teroshdl/src/features/linter.ts @@ -21,6 +21,7 @@ import * as vscode from 'vscode'; import * as teroshdl2 from 'teroshdl2'; import { t_Multi_project_manager } from '../type_declaration'; import * as utils from '../utils/utils'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; enum LINTER_MODE { STYLE = "style", @@ -48,25 +49,20 @@ class Linter { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Configuration //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private get_config(): teroshdl2.config.config_declaration.e_config { - const config = this.manager.get_config_manager().get_config(); - return config; - } - private get_linter_name() { if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL && this.mode === LINTER_MODE.ERRORS) { - return this.get_config().linter.general.linter_vhdl; + return GlobalConfigManager.getInstance().get_config().linter.general.linter_vhdl; } else if ((this.lang === teroshdl2.common.general.LANGUAGE.VERILOG || this.lang === teroshdl2.common.general.LANGUAGE.SYSTEMVERILOG) && this.mode === LINTER_MODE.ERRORS) { - return this.get_config().linter.general.linter_verilog; + return GlobalConfigManager.getInstance().get_config().linter.general.linter_verilog; } else if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL && this.mode === LINTER_MODE.STYLE) { - return this.get_config().linter.general.lstyle_vhdl; + return GlobalConfigManager.getInstance().get_config().linter.general.lstyle_vhdl; } else { - return this.get_config().linter.general.lstyle_verilog; + return GlobalConfigManager.getInstance().get_config().linter.general.lstyle_verilog; } } @@ -76,43 +72,43 @@ class Linter { const linter_name = this.get_linter_name(); if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.ghdl){ - path = this.get_config().tools.ghdl.installation_path; - argument = this.get_config().linter.ghdl.arguments; + path = GlobalConfigManager.getInstance().get_config().tools.ghdl.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.ghdl.arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.modelsim && lang === teroshdl2.common.general.LANGUAGE.VHDL){ - path = this.get_config().tools.modelsim.installation_path; - argument = this.get_config().linter.modelsim.vhdl_arguments; + path = GlobalConfigManager.getInstance().get_config().tools.modelsim.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.modelsim.vhdl_arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.vivado && lang === teroshdl2.common.general.LANGUAGE.VHDL){ - path = this.get_config().tools.vivado.installation_path; - argument = this.get_config().linter.vivado.vhdl_arguments; + path = GlobalConfigManager.getInstance().get_config().tools.vivado.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.vivado.vhdl_arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.icarus){ - path = this.get_config().tools.icarus.installation_path; - argument = this.get_config().linter.icarus.arguments; + path = GlobalConfigManager.getInstance().get_config().tools.icarus.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.icarus.arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.modelsim && lang !== teroshdl2.common.general.LANGUAGE.VHDL){ - path = this.get_config().tools.modelsim.installation_path; - argument = this.get_config().linter.modelsim.verilog_arguments; + path = GlobalConfigManager.getInstance().get_config().tools.modelsim.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.modelsim.verilog_arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.verilator){ - path = this.get_config().tools.verilator.installation_path; - argument = this.get_config().linter.verilator.arguments; + path = GlobalConfigManager.getInstance().get_config().tools.verilator.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.verilator.arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.vivado && lang !== teroshdl2.common.general.LANGUAGE.VHDL){ - path = this.get_config().tools.vivado.installation_path; - argument = this.get_config().linter.vivado.verilog_arguments; + path = GlobalConfigManager.getInstance().get_config().tools.vivado.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.vivado.verilog_arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_lstyle_vhdl.vsg){ - argument = this.get_config().linter.vsg.arguments; + argument = GlobalConfigManager.getInstance().get_config().linter.vsg.arguments; } else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_lstyle_verilog.verible){ - path = this.get_config().tools.verible.installation_path; - argument = this.get_config().linter.verible.arguments; + path = GlobalConfigManager.getInstance().get_config().tools.verible.installation_path; + argument = GlobalConfigManager.getInstance().get_config().linter.verible.arguments; } const options: teroshdl2.linter.common.l_options = { diff --git a/packages/teroshdl/src/features/schematic.ts b/packages/teroshdl/src/features/schematic.ts index c342ca10..d0292db1 100644 --- a/packages/teroshdl/src/features/schematic.ts +++ b/packages/teroshdl/src/features/schematic.ts @@ -29,6 +29,7 @@ import * as yosys from './yosys'; import * as shell from 'shelljs'; import * as nunjucks from 'nunjucks'; import { Logger } from '../logger'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; const activation_command = 'teroshdl.netlist.viewer'; const id = "netlist"; @@ -271,7 +272,7 @@ export class Schematic_manager extends Base_webview { 'empty': false }; - const config = this.manager.get_config_manager().get_config(); + const config = GlobalConfigManager.getInstance().get_config(); const backend = config.schematic.general.backend; const custom_argumens = config.schematic.general.args; diff --git a/packages/teroshdl/src/features/state_machine.ts b/packages/teroshdl/src/features/state_machine.ts index 18c8a9c2..ed61519e 100644 --- a/packages/teroshdl/src/features/state_machine.ts +++ b/packages/teroshdl/src/features/state_machine.ts @@ -26,6 +26,7 @@ import * as utils from '../utils/utils'; import * as nunjucks from 'nunjucks'; import { Base_webview } from './base_webview'; import { Logger } from '../logger'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; export class State_machine_manager extends Base_webview { @@ -154,8 +155,21 @@ export class State_machine_manager extends Base_webview { // Utils //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private get_config(): teroshdl2.config.auxiliar_config.t_documenter_options { - const config = this.manager.get_config_manager().get_documenter_config(); - return config; + const config = GlobalConfigManager.getInstance().get_config(); + return { + generic_visibility: config.documentation.general.generics, + port_visibility: config.documentation.general.ports, + signal_visibility: config.documentation.general.signals, + constant_visibility: config.documentation.general.constants, + type_visibility: config.documentation.general.types, + function_visibility: config.documentation.general.functions, + instantiation_visibility: config.documentation.general.instantiations, + process_visibility: config.documentation.general.process, + language: config.documentation.general.language, + vhdl_symbol: config.documentation.general.symbol_vhdl, + verilog_symbol: config.documentation.general.symbol_verilog, + enable_fsm: config.documentation.general.fsm + }; } normalize_string(str) { diff --git a/packages/teroshdl/src/features/stutter_mode.ts b/packages/teroshdl/src/features/stutter_mode.ts index 191b95ef..cf8783b3 100644 --- a/packages/teroshdl/src/features/stutter_mode.ts +++ b/packages/teroshdl/src/features/stutter_mode.ts @@ -32,6 +32,7 @@ import { import { t_Multi_project_manager } from '../type_declaration'; import * as vscode from 'vscode'; import * as teroshdl2 from 'teroshdl2'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; const TRIGGER_CHARACTERS = [';', '.', "'", ',', '[', ']', '-', '\n']; @@ -63,11 +64,11 @@ export class Stutter_mode_manager { position: Position, ch: string ): ProviderResult { - const stutter_delimiters = element.manager.get_config_manager().get_config().editor.general.stutter_delimiters; - const stutter_bracket_shortcuts = element.manager.get_config_manager().get_config().editor.general.stutter_bracket_shortcuts; - const stutter_comment_shortcuts = element.manager.get_config_manager().get_config().editor.general.stutter_comment_shortcuts; - const stutter_block_width = element.manager.get_config_manager().get_config().editor.general.stutter_block_width; - const stutter_max_width = element.manager.get_config_manager().get_config().editor.general.stutter_max_width; + const stutter_delimiters = GlobalConfigManager.getInstance().get_config().editor.general.stutter_delimiters; + const stutter_bracket_shortcuts = GlobalConfigManager.getInstance().get_config().editor.general.stutter_bracket_shortcuts; + const stutter_comment_shortcuts = GlobalConfigManager.getInstance().get_config().editor.general.stutter_comment_shortcuts; + const stutter_block_width = GlobalConfigManager.getInstance().get_config().editor.general.stutter_block_width; + const stutter_max_width = GlobalConfigManager.getInstance().get_config().editor.general.stutter_max_width; let inComment = document.lineAt(position).text.match(/^.*--.*$/); let linePrefix = document.lineAt(position).text.substr(0, position.character); @@ -262,7 +263,7 @@ export class Stutter_mode_manager { position: Position, ch: string ): ProviderResult { - const stutter_comment_shortcuts = element.manager.get_config_manager().get_config().editor.general.stutter_comment_shortcuts; + const stutter_comment_shortcuts = GlobalConfigManager.getInstance().get_config().editor.general.stutter_comment_shortcuts; let linePrefix = document.lineAt(position).text.substr(0, position.character); switch (ch) { diff --git a/packages/teroshdl/src/features/templates.ts b/packages/teroshdl/src/features/templates.ts index 601ff1b1..ea8820bd 100644 --- a/packages/teroshdl/src/features/templates.ts +++ b/packages/teroshdl/src/features/templates.ts @@ -22,6 +22,7 @@ import * as utils from '../utils/utils'; import * as teroshdl2 from 'teroshdl2'; import { t_Multi_project_manager } from '../type_declaration'; import { Logger } from '../logger'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; export class Template_manager { private manager: t_Multi_project_manager; @@ -86,7 +87,7 @@ export class Template_manager { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Utils //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private get_indent(general_indent:string, lang: teroshdl2.common.general.LANGUAGE): string{ + private get_indent(general_indent: string, lang: teroshdl2.common.general.LANGUAGE): string { const indent = general_indent; let tab_size = undefined; let insert_spaces = undefined; @@ -127,7 +128,7 @@ export class Template_manager { return general_indent; } - if (tab_size === undefined || insert_spaces === undefined){ + if (tab_size === undefined || insert_spaces === undefined) { return general_indent; } @@ -147,7 +148,12 @@ export class Template_manager { } private get_config(): teroshdl2.config.auxiliar_config.t_template_options { - const config = this.manager.get_config_manager().get_template_config(); - return config; + const config = GlobalConfigManager.getInstance().get_config(); + return { + header_file_path: config.templates.general.header_file_path, + indent_char: config.templates.general.indent, + clock_generation_style: config.templates.general.clock_generation_style, + instance_style: config.templates.general.instance_style + }; } } \ No newline at end of file diff --git a/packages/teroshdl/src/features/tree_views/dependency/element.ts b/packages/teroshdl/src/features/tree_views/dependency/element.ts index 2f1febe9..f9081b9c 100644 --- a/packages/teroshdl/src/features/tree_views/dependency/element.ts +++ b/packages/teroshdl/src/features/tree_views/dependency/element.ts @@ -139,7 +139,7 @@ export class ProjectProvider extends BaseTreeDataProvider { async get_hdl_tree() { try { const selected_project = this.project_manager.get_selected_project(); - const python_path = this.project_manager.get_config_global_config().general.general.pypath; + const python_path = selected_project.get_config().general.general.pypath; const result = await selected_project.get_dependency_tree(python_path); if (result.successful === true) { this.hdl_tree = result.result; diff --git a/packages/teroshdl/src/features/tree_views/output/manager.ts b/packages/teroshdl/src/features/tree_views/output/manager.ts index 11750769..63832609 100644 --- a/packages/teroshdl/src/features/tree_views/output/manager.ts +++ b/packages/teroshdl/src/features/tree_views/output/manager.ts @@ -25,6 +25,7 @@ import { e_clean_step } from 'teroshdl2/out/project_manager/tool/common'; import * as teroshdl2 from 'teroshdl2'; import { Run_output_manager } from "../run_output"; import { Logger } from "../../../logger"; +import { GlobalConfigManager } from "teroshdl2/out/config/config_manager"; export class Output_manager { private tree: element.ProjectProvider; @@ -55,7 +56,7 @@ export class Output_manager { } async clean() { - const tool_name = this.project_manager.get_config_global_config().tools.general.select_tool; + const tool_name = GlobalConfigManager.getInstance().get_config().tools.general.select_tool; if (tool_name !== teroshdl2.config.config_declaration.e_tools_general_select_tool.raptor) { return; } @@ -73,7 +74,7 @@ export class Output_manager { const prj = this.project_manager.get_selected_project(); const selfm = this; const step = this.get_step_enum(picker_value); - prj.clean(this.project_manager.get_config_global_config(), + prj.clean( step, (function (stream_c: any) { stream_c.stdout.on('data', function (data: any) { diff --git a/packages/teroshdl/src/features/tree_views/project/manager.ts b/packages/teroshdl/src/features/tree_views/project/manager.ts index 011bafc8..ad808f74 100644 --- a/packages/teroshdl/src/features/tree_views/project/manager.ts +++ b/packages/teroshdl/src/features/tree_views/project/manager.ts @@ -28,6 +28,7 @@ import { Logger } from "../../../logger"; import { t_message_level, showMessage } from "../../../utils/utils"; import { read_file_sync } from "teroshdl2/out/utils/file_utils"; import * as yaml from "js-yaml"; +import { GlobalConfigManager } from "teroshdl2/out/config/config_manager"; export class Project_manager { private tree: element.ProjectProvider; @@ -130,7 +131,7 @@ export class Project_manager { project_name, this.emitterProject ); this.project_manager.add_project(prj); - await utils.add_sources_from_vunit(prj, this.project_manager.get_config_global_config(), true); + await utils.add_sources_from_vunit(prj, true); } catch (error) { } } @@ -182,7 +183,7 @@ export class Project_manager { } // Device family const family_list = await teroshdl2.project_manager.quartus - .getFamilyAndParts(this.project_manager.get_config_global_config()); + .getFamilyAndParts(GlobalConfigManager.getInstance().get_config()); const family_list_string = family_list.map(x => x.family); let picker_family = await vscode.window.showQuickPick(family_list_string, { placeHolder: "Device family", @@ -204,7 +205,7 @@ export class Project_manager { // Create project const quartusProject = await teroshdl2.project_manager.quartusProjectManager.QuartusProjectManager.fromNewQuartusProject( - this.project_manager.get_config_global_config(), project_name, picker_family, picker_part, + GlobalConfigManager.getInstance().get_config(), project_name, picker_family, picker_part, working_directory[0], this.emitterProject); // Add project to manager @@ -222,7 +223,7 @@ export class Project_manager { // Create project const quartusProject = await teroshdl2.project_manager.quartusProjectManager.QuartusProjectManager.fromExistingQuartusProject( - this.project_manager.get_config_global_config(), prj_path, this.emitterProject + GlobalConfigManager.getInstance().get_config(), prj_path, this.emitterProject ); // Add project to manager @@ -238,7 +239,6 @@ export class Project_manager { async create_project_from_json(prj_path: string) { try { const prj = await teroshdl2.project_manager.project_manager.Project_manager.fromJson( - this.project_manager.get_config_global_config(), JSON.parse(read_file_sync(prj_path)), this.emitterProject); this.project_manager.add_project(prj); this.refresh(); @@ -249,7 +249,6 @@ export class Project_manager { async create_project_from_yaml(prj_path: string) { try { const prj = await teroshdl2.project_manager.project_manager.Project_manager.fromJson( - this.project_manager.get_config_global_config(), yaml.load(read_file_sync(prj_path)), this.emitterProject); this.project_manager.add_project(prj); this.refresh(); @@ -301,7 +300,7 @@ export class Project_manager { async check_dependencies() { const options: teroshdl2.process.python.python_options = { - path: this.project_manager.get_config_global_config().general.general.pypath + path: GlobalConfigManager.getInstance().get_config().general.general.pypath }; const intro_info = "-------> "; @@ -349,7 +348,7 @@ export class Project_manager { } // Check make - const make_binary_dir = this.project_manager.get_config_global_config().general.general.makepath; + const make_binary_dir = GlobalConfigManager.getInstance().get_config().general.general.makepath; let make_binary_path = ("make"); if (make_binary_dir !== "") { make_binary_path = path_lib.join(make_binary_dir, make_binary_path); diff --git a/packages/teroshdl/src/features/tree_views/runs/element.ts b/packages/teroshdl/src/features/tree_views/runs/element.ts index 002b3357..53c6f6df 100644 --- a/packages/teroshdl/src/features/tree_views/runs/element.ts +++ b/packages/teroshdl/src/features/tree_views/runs/element.ts @@ -126,9 +126,7 @@ export class ProjectProvider extends BaseTreeDataProvider { async refresh(): Promise { try { const selected_project = this.project_manager.get_selected_project(); - const config = this.project_manager.get_config_global_config(); - - const runs_list = await selected_project.get_test_list(config); + const runs_list = await selected_project.get_test_list(); const runs_view: Run[] = []; runs_list.forEach(run => { runs_view.push(new Run(run.suite_name, run.name, run.filename, run.location)); diff --git a/packages/teroshdl/src/features/tree_views/runs/manager.ts b/packages/teroshdl/src/features/tree_views/runs/manager.ts index 3a7ce39a..c68aade1 100644 --- a/packages/teroshdl/src/features/tree_views/runs/manager.ts +++ b/packages/teroshdl/src/features/tree_views/runs/manager.ts @@ -91,7 +91,7 @@ export class Runs_manager { let test_list: teroshdl2.project_manager.tool_common.t_test_declaration[] = []; if (item === undefined) { - test_list = await prj.get_test_list(this.project_manager.get_config_global_config()); + test_list = await prj.get_test_list(); } else { const test: teroshdl2.project_manager.tool_common.t_test_declaration = { @@ -106,7 +106,7 @@ export class Runs_manager { this.logger.show(); const selfm = this; const p = new Promise(resolve => { - prj.run(this.project_manager.get_config_global_config(), test_list, + prj.run(test_list, (function (result: teroshdl2.project_manager.tool_common.t_test_result[]) { selfm.refresh(result); // Status bar to 100 diff --git a/packages/teroshdl/src/features/tree_views/source/manager.ts b/packages/teroshdl/src/features/tree_views/source/manager.ts index 6c73f014..b04433d6 100644 --- a/packages/teroshdl/src/features/tree_views/source/manager.ts +++ b/packages/teroshdl/src/features/tree_views/source/manager.ts @@ -97,7 +97,7 @@ export class Source_manager { } // Add from VUnit else if (picker_value === element_types[2]) { - await utils.add_sources_from_vunit(prj, this.project_manager.get_config_global_config(), true); + await utils.add_sources_from_vunit(prj, true); } // Add from directory and subirectories else if (picker_value === element_types[3]) { @@ -109,7 +109,7 @@ export class Source_manager { } // Add from Quartus else if (picker_value === element_types[5]) { - await utils.add_sources_from_quartus(prj, this.project_manager.get_config_global_config(), true); + await utils.add_sources_from_quartus(prj, true); } } // Add library diff --git a/packages/teroshdl/src/features/tree_views/utils.ts b/packages/teroshdl/src/features/tree_views/utils.ts index d1b77301..1dfed32f 100644 --- a/packages/teroshdl/src/features/tree_views/utils.ts +++ b/packages/teroshdl/src/features/tree_views/utils.ts @@ -143,26 +143,26 @@ export async function add_sources_from_directory_and_subdirectories(prj: teroshd }; } -export async function add_sources_from_vunit(prj: teroshdl2.project_manager.project_manager.Project_manager, config: teroshdl2.config.config_declaration.e_config, is_manual: boolean) { +export async function add_sources_from_vunit(prj: teroshdl2.project_manager.project_manager.Project_manager, is_manual: boolean) { const path_list = await utils.get_from_open_dialog("Select run.py", false, true, true, "Select VUnit run.py files", { 'Python files (*.py)': ['py'] }); path_list.forEach(async path => { - await prj.add_file_from_vunit(config, path, is_manual); + await prj.add_file_from_vunit(path, is_manual); }); } -export async function add_sources_from_vivado(prj: teroshdl2.project_manager.project_manager.Project_manager, config: teroshdl2.config.config_declaration.e_config, is_manual: boolean) { +export async function add_sources_from_vivado(prj: teroshdl2.project_manager.project_manager.Project_manager, is_manual: boolean) { const path_list = await utils.get_from_open_dialog("Select Vivado project", false, true, true, "Select Vivado project", { 'Vivado project (*.xpr)': ['xpr'] }); path_list.forEach(async path => { - await prj.add_file_from_vivado(config, path, is_manual); + await prj.add_file_from_vivado(path, is_manual); }); } -export async function add_sources_from_quartus(prj: teroshdl2.project_manager.project_manager.Project_manager, config: teroshdl2.config.config_declaration.e_config, is_manual: boolean) { +export async function add_sources_from_quartus(prj: teroshdl2.project_manager.project_manager.Project_manager, is_manual: boolean) { const path_list = await utils.get_from_open_dialog("Select Quartus project", false, true, false, "Select Quartus project", { 'Quartus project (*.qsf)': ['qsf'] }); for (const path of path_list) { - await prj.add_file_from_quartus(config, path, is_manual); + await prj.add_file_from_quartus(path, is_manual); } } \ No newline at end of file diff --git a/packages/teroshdl/src/teroshdl.ts b/packages/teroshdl/src/teroshdl.ts index a6e738ec..7179bf84 100644 --- a/packages/teroshdl/src/teroshdl.ts +++ b/packages/teroshdl/src/teroshdl.ts @@ -40,6 +40,7 @@ import { Comander } from "./features/comander/run"; import { Logger } from "./logger"; import { Dependency_manager } from './features/dependency'; import { LogView } from './views/logs'; +import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager'; const CONFIG_FILENAME = '.teroshdl2_config.json'; const PRJ_FILENAME = '.teroshdl2_prj.json'; @@ -63,7 +64,8 @@ export class Teroshdl { const file_prj_path = path_lib.join(homedir, PRJ_FILENAME); this.manager = new teroshdl2.project_manager.multi_project_manager.Multi_project_manager( - file_config_path, file_prj_path); + file_prj_path); + GlobalConfigManager.newInstance(file_config_path); this.context = context; this.global_logger = global_logger; } @@ -114,6 +116,7 @@ export class Teroshdl { private async init_multi_project_manager() { try { + GlobalConfigManager.getInstance().load(); await this.manager.load(this.emitterProject); } catch (error) { this.global_logger.warn("There have been errors loading project list from disk.");