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.
This commit is contained in:
2025-04-27 18:39:58 +00:00
parent 37b684fd2d
commit 8ed550f451
4 changed files with 3 additions and 5 deletions

View File

@@ -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)

View File

@@ -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()

View File

@@ -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")

View File

@@ -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)