diff --git a/aidge_core/aidge_export_aidge/export.py b/aidge_core/aidge_export_aidge/export.py index 46bb12570a698b4d420b0c783a2bd843aa03ae50..b561b835f629e8ac9003d624456d904e30fd94bf 100644 --- a/aidge_core/aidge_export_aidge/export.py +++ b/aidge_core/aidge_export_aidge/export.py @@ -6,27 +6,63 @@ from .utils import supported_operators, OPERATORS_REGISTRY from . import ROOT_EXPORT +from aidge_core import ExportNode, generate_file + + def export(export_folder: str, - graphview: aidge_core.GraphView, - scheduler: aidge_core.Scheduler): + scheduler: aidge_core.Scheduler, + enable_python_binding: bool = True, + ): export_folder_path = Path(export_folder) + export_name = export_folder_path.name + + ### Creating export folder ### # Create export directory os.makedirs(export_folder, exist_ok=True) - # Cpy static files - shutil.copytree(ROOT_EXPORT / "static/", export_folder_path, dirs_exist_ok=True) + ### Cpy static files ### + shutil.copytree(ROOT_EXPORT / "static/include", + export_folder_path / "include", dirs_exist_ok=True) + shutil.copytree(ROOT_EXPORT / "static/cmake", + export_folder_path / "cmake", dirs_exist_ok=True) + shutil.copyfile(ROOT_EXPORT / "static/CMakeLists.txt", + export_folder_path / "CMakeLists.txt") + shutil.copyfile(ROOT_EXPORT / "static/version.txt", + export_folder_path / "version.txt") + shutil.copyfile(ROOT_EXPORT / "static/README.md", + export_folder_path / "README.md") + shutil.copyfile(ROOT_EXPORT / "static/main.cpp", + export_folder_path / "main.cpp") + shutil.copyfile(ROOT_EXPORT / "static/export-config.cmake.in", + export_folder_path / f"{export_name}-config.cmake.in") + # Create project_name file + with open(export_folder_path / "project_name.txt", "w") as f: + f.write(export_name) + + # Add files related to python binding if + if enable_python_binding: + os.makedirs(export_folder_path / "python_binding", exist_ok=True) + generate_file( + export_folder_path / "python_binding/pybind.cpp", + ROOT_EXPORT / "templates/pybind.jinja", + name=export_name, + ) + # TODO: Add a main.py file ? + + ### Generating an export for each nodes and dnn file ### ordered_nodes = scheduler.get_static_scheduling() - list_configs = [] # List of headers to include in dnn.cpp to access attribute and parameters - list_actions = [] # List of string to construct graph + list_configs = [] # List of headers to include in dnn.cpp to access attribute and parameters + list_actions = [] # List of string to construct graph set_operator = set() for node in ordered_nodes: if node.type() in supported_operators(): set_operator.add(node.type()) op = OPERATORS_REGISTRY[node.type()](node) + # TODO: list_configs and list_actions don't need to be passed by argument # Export the configuration list_configs = op.export(export_folder_path, list_configs) @@ -43,4 +79,3 @@ def export(export_folder: str, operators=set_operator, actions=list_actions, ) -