Refactors file management and enhances task tracking
Replaces duplicate file copy logic with a unified `copy_file` function to improve code reuse and maintainability. Updates step tracking across the toolchain to reflect a consistent 12-step workflow. Adds a new entry point (`xilinx_ise_all`) to streamline execution of the entire toolchain. Improves logging by integrating enhanced console utilities for better step visualization and progress tracking.
This commit is contained in:
@@ -4,7 +4,7 @@ import shutil
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from models.project import ProjectConfig
|
from models.project import ProjectConfig
|
||||||
from models.config import DIRECTORIES
|
from models.config import DIRECTORIES
|
||||||
from tools.xilinx_ise.common import run_tool
|
from tools.xilinx_ise.common import copy_file, run_tool
|
||||||
|
|
||||||
def run_bitgen(project: ProjectConfig):
|
def run_bitgen(project: ProjectConfig):
|
||||||
run_tool(
|
run_tool(
|
||||||
@@ -15,24 +15,15 @@ def run_bitgen(project: ProjectConfig):
|
|||||||
"-w",
|
"-w",
|
||||||
f"{project.name}.ncd",
|
f"{project.name}.ncd",
|
||||||
f"{project.name}.bit"
|
f"{project.name}.bit"
|
||||||
], step_number=5, total_steps=6
|
], step_number=9, total_steps=12
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def copy_bitstream_file(project: ProjectConfig):
|
def copy_bitstream_file(project: ProjectConfig):
|
||||||
"""
|
copy_file(
|
||||||
Kopiert die Bitstream-Datei (.bit) vom Build-Verzeichnis ins Output-Verzeichnis.
|
project=project,
|
||||||
|
source_filename=f"{project.name}.bit",
|
||||||
Args:
|
destination_filename=f"{project.name}.Bitstream",
|
||||||
project (ProjectConfig): Geladene Projektkonfiguration.
|
description="Bitstream File",
|
||||||
"""
|
step_number=10, total_steps=12
|
||||||
src_path = os.path.join(DIRECTORIES.build, f"{project.name}.bit")
|
)
|
||||||
dst_path = os.path.join(DIRECTORIES.copy_target, f"{project.name}.bit")
|
|
||||||
|
|
||||||
if not os.path.exists(src_path):
|
|
||||||
raise FileNotFoundError(f"Bitstream-Datei nicht gefunden: {src_path}")
|
|
||||||
|
|
||||||
os.makedirs(DIRECTORIES.copy_target, exist_ok=True)
|
|
||||||
|
|
||||||
shutil.copyfile(src_path, dst_path)
|
|
||||||
print(f"[hdlbuild] Bitstream-Datei kopiert nach {dst_path}")
|
|
@@ -1,13 +1,10 @@
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
|
||||||
import os
|
import os
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
import sys
|
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
from models.project import ProjectConfig
|
from models.project import ProjectConfig
|
||||||
from models.config import DIRECTORIES
|
from models.config import DIRECTORIES
|
||||||
from utils.console_utils import ConsoleTask
|
from utils.console_utils import ConsoleTask, ConsoleUtils
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
def run_tool(
|
def run_tool(
|
||||||
project: ProjectConfig,
|
project: ProjectConfig,
|
||||||
@@ -28,9 +25,6 @@ def run_tool(
|
|||||||
if not os.path.exists(tool_executable):
|
if not os.path.exists(tool_executable):
|
||||||
raise FileNotFoundError(f"Executable nicht gefunden: {tool_executable}")
|
raise FileNotFoundError(f"Executable nicht gefunden: {tool_executable}")
|
||||||
|
|
||||||
step_info = f"[{step_number}/{total_steps}] " if step_number and total_steps else ""
|
|
||||||
progress_line = f"{step_info}[hdlbuild] Starte {tool_executable_name.upper()}..."
|
|
||||||
|
|
||||||
cmd = [tool_executable]
|
cmd = [tool_executable]
|
||||||
|
|
||||||
if project.tool_options and project.tool_options.common:
|
if project.tool_options and project.tool_options.common:
|
||||||
@@ -43,15 +37,17 @@ def run_tool(
|
|||||||
|
|
||||||
cmd.extend(mandatory_arguments)
|
cmd.extend(mandatory_arguments)
|
||||||
|
|
||||||
task = ConsoleTask(progress_line)
|
task = ConsoleTask("hdlbuild", tool_executable_name.upper(), step_number, total_steps)
|
||||||
task.run_command(cmd, cwd=working_dir, silent=silent)
|
task.run_command(cmd, cwd=working_dir, silent=silent)
|
||||||
|
|
||||||
|
|
||||||
def copy_report_file(
|
def copy_file(
|
||||||
project: ProjectConfig,
|
project: ProjectConfig,
|
||||||
source_filename: str,
|
source_filename: str,
|
||||||
destination_filename: str,
|
destination_filename: str,
|
||||||
description: str = "Report"
|
description: str = "Report",
|
||||||
|
step_number: Optional[int] = None,
|
||||||
|
total_steps: Optional[int] = None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Kopiert eine beliebige Report-Datei vom Build- in das Report-Verzeichnis.
|
Kopiert eine beliebige Report-Datei vom Build- in das Report-Verzeichnis.
|
||||||
@@ -71,4 +67,6 @@ def copy_report_file(
|
|||||||
os.makedirs(DIRECTORIES.report, exist_ok=True)
|
os.makedirs(DIRECTORIES.report, exist_ok=True)
|
||||||
|
|
||||||
shutil.copyfile(src_path, dst_path)
|
shutil.copyfile(src_path, dst_path)
|
||||||
print(f"[hdlbuild] {description} kopiert nach {dst_path} 🗎")
|
|
||||||
|
util = ConsoleUtils("hdlbuild", step_number, total_steps)
|
||||||
|
util.print(f"{description} kopiert nach {dst_path}")
|
34
src/tools/xilinx_ise/main.py
Normal file
34
src/tools/xilinx_ise/main.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
from models.config import DIRECTORIES
|
||||||
|
from models.project import ProjectConfig
|
||||||
|
from tools.xilinx_ise.bitgen import copy_bitstream_file, run_bitgen
|
||||||
|
from tools.xilinx_ise.map import copy_map_report, run_map
|
||||||
|
from tools.xilinx_ise.ngdbuild import run_ngdbuild
|
||||||
|
from tools.xilinx_ise.par import copy_par_report, copy_pinout_report, run_par
|
||||||
|
from tools.xilinx_ise.trace import copy_trace_report, run_trace
|
||||||
|
from tools.xilinx_ise.xst import copy_synthesis_report, generate_xst_project_file, generate_xst_script_file, run_xst
|
||||||
|
|
||||||
|
|
||||||
|
def xilinx_ise_synth(project: ProjectConfig):
|
||||||
|
generate_xst_project_file(project, f"{DIRECTORIES.build}/{project.name}.prj")
|
||||||
|
generate_xst_script_file(project, f"{DIRECTORIES.build}/{project.name}.scr")
|
||||||
|
run_xst(project)
|
||||||
|
|
||||||
|
copy_synthesis_report(project)
|
||||||
|
|
||||||
|
def xilinx_ise_all(project: ProjectConfig):
|
||||||
|
xilinx_ise_synth(project)
|
||||||
|
|
||||||
|
run_ngdbuild(project)
|
||||||
|
|
||||||
|
run_map(project)
|
||||||
|
copy_map_report(project)
|
||||||
|
|
||||||
|
run_par(project)
|
||||||
|
copy_par_report(project)
|
||||||
|
copy_pinout_report(project)
|
||||||
|
|
||||||
|
run_bitgen(project)
|
||||||
|
copy_bitstream_file(project)
|
||||||
|
|
||||||
|
run_trace(project)
|
||||||
|
copy_trace_report(project)
|
@@ -4,7 +4,7 @@ import shutil
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from models.project import ProjectConfig
|
from models.project import ProjectConfig
|
||||||
from models.config import DIRECTORIES
|
from models.config import DIRECTORIES
|
||||||
from tools.xilinx_ise.common import copy_report_file, run_tool
|
from tools.xilinx_ise.common import copy_file, run_tool
|
||||||
|
|
||||||
def run_map(project: ProjectConfig):
|
def run_map(project: ProjectConfig):
|
||||||
run_tool(
|
run_tool(
|
||||||
@@ -17,13 +17,14 @@ def run_map(project: ProjectConfig):
|
|||||||
f"{project.name}.ngd",
|
f"{project.name}.ngd",
|
||||||
"-o", f"{project.name}.map.ncd",
|
"-o", f"{project.name}.map.ncd",
|
||||||
f"{project.name}.pcf"
|
f"{project.name}.pcf"
|
||||||
], step_number=3, total_steps=6
|
], step_number=4, total_steps=12
|
||||||
)
|
)
|
||||||
|
|
||||||
def copy_map_report(project: ProjectConfig):
|
def copy_map_report(project: ProjectConfig):
|
||||||
copy_report_file(
|
copy_file(
|
||||||
project=project,
|
project=project,
|
||||||
source_filename=f"{project.name}.map.mrp",
|
source_filename=f"{project.name}.map.mrp",
|
||||||
destination_filename=f"{project.name}.MapReport",
|
destination_filename=f"{project.name}.MapReport",
|
||||||
description="Map Report"
|
description="Map Report",
|
||||||
|
step_number=5, total_steps=12
|
||||||
)
|
)
|
||||||
|
@@ -15,5 +15,5 @@ def run_ngdbuild(project: ProjectConfig):
|
|||||||
"-uc", f"{DIRECTORIES.get_relative_prefix()}{project.constraints}",
|
"-uc", f"{DIRECTORIES.get_relative_prefix()}{project.constraints}",
|
||||||
f"{project.name}.ngc",
|
f"{project.name}.ngc",
|
||||||
f"{project.name}.ngd"
|
f"{project.name}.ngd"
|
||||||
], step_number=2, total_steps=6
|
], step_number=3, total_steps=12
|
||||||
)
|
)
|
||||||
|
@@ -4,7 +4,7 @@ import os
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from models.project import ProjectConfig
|
from models.project import ProjectConfig
|
||||||
from models.config import DIRECTORIES
|
from models.config import DIRECTORIES
|
||||||
from tools.xilinx_ise.common import copy_report_file, run_tool
|
from tools.xilinx_ise.common import copy_file, run_tool
|
||||||
|
|
||||||
def run_par(project: ProjectConfig):
|
def run_par(project: ProjectConfig):
|
||||||
run_tool(
|
run_tool(
|
||||||
@@ -16,21 +16,23 @@ def run_par(project: ProjectConfig):
|
|||||||
f"{project.name}.map.ncd",
|
f"{project.name}.map.ncd",
|
||||||
f"{project.name}.ncd",
|
f"{project.name}.ncd",
|
||||||
f"{project.name}.pcf"
|
f"{project.name}.pcf"
|
||||||
], step_number=4, total_steps=6
|
], step_number=6, total_steps=12
|
||||||
)
|
)
|
||||||
|
|
||||||
def copy_par_report(project: ProjectConfig):
|
def copy_par_report(project: ProjectConfig):
|
||||||
copy_report_file(
|
copy_file(
|
||||||
project=project,
|
project=project,
|
||||||
source_filename=f"{project.name}.par",
|
source_filename=f"{project.name}.par",
|
||||||
destination_filename=f"{project.name}.PlaceRouteReport",
|
destination_filename=f"{project.name}.PlaceRouteReport",
|
||||||
description="Place & Route Report"
|
description="Place & Route Report",
|
||||||
|
step_number=7, total_steps=12
|
||||||
)
|
)
|
||||||
|
|
||||||
def copy_pinout_report(project: ProjectConfig):
|
def copy_pinout_report(project: ProjectConfig):
|
||||||
copy_report_file(
|
copy_file(
|
||||||
project=project,
|
project=project,
|
||||||
source_filename=f"{project.name}_pad.txt",
|
source_filename=f"{project.name}_pad.txt",
|
||||||
destination_filename=f"{project.name}.PinoutReport",
|
destination_filename=f"{project.name}.PinoutReport",
|
||||||
description="Pinout Report"
|
description="Pinout Report",
|
||||||
|
step_number=8, total_steps=12
|
||||||
)
|
)
|
@@ -4,7 +4,7 @@ import shutil
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from models.project import ProjectConfig
|
from models.project import ProjectConfig
|
||||||
from models.config import DIRECTORIES
|
from models.config import DIRECTORIES
|
||||||
from tools.xilinx_ise.common import copy_report_file, run_tool
|
from tools.xilinx_ise.common import copy_file, run_tool
|
||||||
|
|
||||||
def run_trace(project: ProjectConfig):
|
def run_trace(project: ProjectConfig):
|
||||||
run_tool(
|
run_tool(
|
||||||
@@ -14,13 +14,14 @@ def run_trace(project: ProjectConfig):
|
|||||||
mandatory_arguments=[
|
mandatory_arguments=[
|
||||||
f"{project.name}.ncd",
|
f"{project.name}.ncd",
|
||||||
f"{project.name}.pcf",
|
f"{project.name}.pcf",
|
||||||
], step_number=6, total_steps=6
|
], step_number=11, total_steps=12
|
||||||
)
|
)
|
||||||
|
|
||||||
def copy_trace_report(project: ProjectConfig):
|
def copy_trace_report(project: ProjectConfig):
|
||||||
copy_report_file(
|
copy_file(
|
||||||
project=project,
|
project=project,
|
||||||
source_filename=f"{project.name}.twr",
|
source_filename=f"{project.name}.twr",
|
||||||
destination_filename=f"{project.name}.TimingReport",
|
destination_filename=f"{project.name}.TimingReport",
|
||||||
description="Timing Report"
|
description="Timing Report",
|
||||||
|
step_number=12, total_steps=12
|
||||||
)
|
)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from models.config import DIRECTORIES
|
from models.config import DIRECTORIES
|
||||||
from tools.xilinx_ise.common import copy_report_file, run_tool
|
from tools.xilinx_ise.common import copy_file, run_tool
|
||||||
from utils.source_resolver import expand_sources
|
from utils.source_resolver import expand_sources
|
||||||
from models.project import ProjectConfig
|
from models.project import ProjectConfig
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -50,13 +50,14 @@ def run_xst(project: ProjectConfig):
|
|||||||
project=project,
|
project=project,
|
||||||
tool_executable_name="xst",
|
tool_executable_name="xst",
|
||||||
mandatory_arguments=["-ifn", f"{project.name}.scr",
|
mandatory_arguments=["-ifn", f"{project.name}.scr",
|
||||||
], step_number=1, total_steps=6
|
], step_number=1, total_steps=12
|
||||||
)
|
)
|
||||||
|
|
||||||
def copy_synthesis_report(project: ProjectConfig):
|
def copy_synthesis_report(project: ProjectConfig):
|
||||||
copy_report_file(
|
copy_file(
|
||||||
project=project,
|
project=project,
|
||||||
source_filename=f"{project.name}.srp",
|
source_filename=f"{project.name}.srp",
|
||||||
destination_filename=f"{project.name}.SynthesisReport",
|
destination_filename=f"{project.name}.SynthesisReport",
|
||||||
description="Synthesebericht"
|
description="Synthesebericht",
|
||||||
|
step_number=2, total_steps=12
|
||||||
)
|
)
|
Reference in New Issue
Block a user