From 8ed550f45158b55edd5c3680b82691fac20d6993 Mon Sep 17 00:00:00 2001 From: Max P Date: Sun, 27 Apr 2025 18:39:58 +0000 Subject: [PATCH] Defers project loading to execution phase Removes project loading from command initialization and shifts it to the execution phase for better resource management and initialization performance. Improves flexibility by ensuring the project is only loaded when needed. --- src/hdlbuild/commands/build.py | 2 +- src/hdlbuild/commands/dep.py | 2 +- src/hdlbuild/commands/init.py | 2 -- src/hdlbuild/commands/test.py | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hdlbuild/commands/build.py b/src/hdlbuild/commands/build.py index a626e81..373c471 100644 --- a/src/hdlbuild/commands/build.py +++ b/src/hdlbuild/commands/build.py @@ -6,7 +6,6 @@ from hdlbuild.utils.project_loader import load_project_config class BuildCommand: def __init__(self): self.console_utils = ConsoleUtils("hdlbuild") - self.project = load_project_config() def register(self, subparsers): parser = subparsers.add_parser("build", help="Start the build process") @@ -20,6 +19,7 @@ class BuildCommand: def execute(self, args): """Starts the build process.""" + self.project = load_project_config() if args.target == "synth": self.console_utils.print("Starting synth process...") ensure_directories_exist(True) diff --git a/src/hdlbuild/commands/dep.py b/src/hdlbuild/commands/dep.py index ea2d9c4..c0930d3 100644 --- a/src/hdlbuild/commands/dep.py +++ b/src/hdlbuild/commands/dep.py @@ -5,7 +5,6 @@ from hdlbuild.utils.project_loader import load_project_config class DepCommand: def __init__(self): self.console_utils = ConsoleUtils("hdlbuild") - self.project = load_project_config() def register(self, subparsers): parser = subparsers.add_parser("dep", help="Start the dependencies process") @@ -13,5 +12,6 @@ class DepCommand: def execute(self, args): """Starts the dependencies process.""" + self.project = load_project_config() self.console_utils.print("Starting dependencies process...") DependencyResolver(self.project).resolve_all() \ No newline at end of file diff --git a/src/hdlbuild/commands/init.py b/src/hdlbuild/commands/init.py index 6f602b1..e3c021a 100644 --- a/src/hdlbuild/commands/init.py +++ b/src/hdlbuild/commands/init.py @@ -2,12 +2,10 @@ from pathlib import Path import shutil from hdlbuild.dependencies.resolver import DependencyResolver from hdlbuild.utils.console_utils import ConsoleUtils -from hdlbuild.utils.project_loader import load_project_config class InitCommand: def __init__(self): self.console_utils = ConsoleUtils("hdlbuild") - self.project = load_project_config() def register(self, subparsers): parser = subparsers.add_parser("init", help="Initialize a new HDLBuild project") diff --git a/src/hdlbuild/commands/test.py b/src/hdlbuild/commands/test.py index 367dfd3..a198617 100644 --- a/src/hdlbuild/commands/test.py +++ b/src/hdlbuild/commands/test.py @@ -5,7 +5,6 @@ from hdlbuild.utils.project_loader import load_project_config class TestCommand: def __init__(self): self.console_utils = ConsoleUtils("hdlbuild") - self.project = load_project_config() def register(self, subparsers): parser = subparsers.add_parser("test", help="Start the Tests process") @@ -18,6 +17,7 @@ class TestCommand: def execute(self, args): """Starts the test process.""" + self.project = load_project_config() self.console_utils.print("Starting test process...") build_testbench(self.project, args.target) run_testbench(self.project, args.target) \ No newline at end of file