Refactors Xilinx ISE tool execution and report handling
Replaces repetitive tool execution logic with a reusable `run_tool` function to streamline code and reduce duplication. Introduces a shared `copy_report_file` utility for consistent report copying and error handling. Simplifies individual tool scripts (XST, NGDBuild, MAP, PAR, BitGen) by delegating core logic to common utilities. Improves maintainability and consistency across the codebase.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from typing import Optional
|
||||
from models.config import DIRECTORIES
|
||||
from tools.xilinx_ise.common import copy_report_file, run_tool
|
||||
from utils.source_resolver import expand_sources
|
||||
from models.project import ProjectConfig
|
||||
import subprocess
|
||||
@@ -44,58 +45,17 @@ def generate_xst_script_file(project: ProjectConfig, output_path: str):
|
||||
|
||||
|
||||
|
||||
def run_xst(project: ProjectConfig, working_dir: Optional[str] = None):
|
||||
"""
|
||||
Führt Xilinx XST Synthese aus, basierend auf dem gegebenen Projekt.
|
||||
|
||||
Args:
|
||||
project (ProjectConfig): Geladene Projektkonfiguration.
|
||||
working_dir (str, optional): Pfad, wo .prj/.scr liegen und gebaut werden soll.
|
||||
Wenn None, wird das aktuelle Arbeitsverzeichnis verwendet.
|
||||
"""
|
||||
if working_dir is None:
|
||||
working_dir = DIRECTORIES.build
|
||||
|
||||
xilinx_bin_dir = os.path.join(project.xilinx_path, "bin", "lin64") # oder "nt64" für Windows
|
||||
xst_executable = os.path.join(xilinx_bin_dir, "xst")
|
||||
|
||||
if not os.path.exists(xst_executable):
|
||||
raise FileNotFoundError(f"XST-Executable nicht gefunden unter: {xst_executable}")
|
||||
|
||||
print(f"[hdlbuild] Starte XST Synthese über {xst_executable}")
|
||||
print(f"[hdlbuild] Arbeitsverzeichnis: {working_dir}")
|
||||
|
||||
cmd = [xst_executable]
|
||||
|
||||
# Füge die "common" Optionen ein, wenn sie existieren
|
||||
if project.tool_options and project.tool_options.common:
|
||||
cmd.extend(project.tool_options.common)
|
||||
|
||||
# Jetzt die XST-spezifischen Aufrufe
|
||||
cmd.extend([
|
||||
"-ifn", f"{project.name}.scr"
|
||||
])
|
||||
|
||||
print(f"[hdlbuild] XST-Befehl: {' '.join(cmd)}")
|
||||
|
||||
subprocess.run(cmd, cwd=working_dir, check=True)
|
||||
def run_xst(project: ProjectConfig):
|
||||
run_tool(
|
||||
project=project,
|
||||
tool_executable_name="xst",
|
||||
mandatory_arguments=["-ifn", f"{project.name}.scr"]
|
||||
)
|
||||
|
||||
def copy_synthesis_report(project: ProjectConfig):
|
||||
"""
|
||||
Kopiert den Synthesebericht (.srp) vom Build-Verzeichnis ins Report-Verzeichnis
|
||||
und benennt ihn sinnvoll um.
|
||||
|
||||
Args:
|
||||
project (ProjectConfig): Geladene Projektkonfiguration.
|
||||
"""
|
||||
src_path = os.path.join(DIRECTORIES.build, f"{project.name}.srp")
|
||||
dst_path = os.path.join(DIRECTORIES.report, f"{project.name}.SynthesisReport")
|
||||
|
||||
if not os.path.exists(src_path):
|
||||
raise FileNotFoundError(f"Synthesebericht nicht gefunden: {src_path}")
|
||||
|
||||
# Stelle sicher, dass das Zielverzeichnis existiert
|
||||
os.makedirs(DIRECTORIES.report, exist_ok=True)
|
||||
|
||||
shutil.copyfile(src_path, dst_path)
|
||||
print(f"[hdlbuild] Synthesebericht kopiert nach {dst_path}")
|
||||
copy_report_file(
|
||||
project=project,
|
||||
source_filename=f"{project.name}.srp",
|
||||
destination_filename=f"{project.name}.SynthesisReport",
|
||||
description="Synthesebericht"
|
||||
)
|
Reference in New Issue
Block a user