From c4c31120899cfcc3992e9a3a01dd5895d59c3e0d Mon Sep 17 00:00:00 2001
From: Olof Kindgren <olof.kindgren@gmail.com>
Date: Sun, 31 Dec 2023 00:12:18 +0100
Subject: [PATCH] Clean up Edalizer API

---
 fusesoc/edalizer.py | 12 ++++++------
 fusesoc/fusesoc.py  |  8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fusesoc/edalizer.py b/fusesoc/edalizer.py
index 6026df87..35da6c69 100644
--- a/fusesoc/edalizer.py
+++ b/fusesoc/edalizer.py
@@ -49,7 +49,7 @@ def __init__(
         system_name=None,
         resolve_env_vars=False,
     ):
-        logger.debug("Building EDA API")
+        logger.debug("Building EDAM structure")
 
         self.toplevel = toplevel
         self.flags = flags
@@ -102,7 +102,7 @@ def run(self):
         # to the list of available cores.
         self.run_generators()
 
-        # Create EDA API file contents
+        # Create EDAM file contents
         self.create_edam()
 
         return self.edam
@@ -199,7 +199,7 @@ def create_edam(self):
         for core in self.cores:
             snippet = {}
 
-            logger.debug("Collecting EDA API parameters from {}".format(str(core.name)))
+            logger.debug("Collecting EDAM parameters from {}".format(str(core.name)))
             _flags = self._core_flags(core)
 
             # Extract direct dependencies
@@ -474,16 +474,16 @@ def _parse_flow_options(self, backend_class, backendargs, edam):
 
         return flow_options
 
-    def parse_args(self, backend_class, backendargs, edam):
+    def parse_args(self, backend_class, backendargs):
         # First we need to see which flow options are set,
         # in order to know which tool options that are relevant
         # for this configuration of the flow
         if hasattr(backend_class, "get_flow_options"):
             self.activated_flow_options = self._parse_flow_options(
-                backend_class, backendargs, edam
+                backend_class, backendargs, self.edam
             )
 
-        parser = self._build_parser(backend_class, edam)
+        parser = self._build_parser(backend_class, self.edam)
         parsed_args = parser.parse_args(backendargs)
 
         args_dict = {}
diff --git a/fusesoc/fusesoc.py b/fusesoc/fusesoc.py
index 73ba2e3e..a5a2bb90 100644
--- a/fusesoc/fusesoc.py
+++ b/fusesoc/fusesoc.py
@@ -151,9 +151,9 @@ def get_backend(self, core, flags, backendargs=[]):
         )
 
         try:
-            edam = edalizer.run()
-            edalizer.parse_args(backend_class, backendargs, edam)
+            edalizer.run()
             edalizer.export()
+            edalizer.parse_args(backend_class, backendargs)
         except SyntaxError as e:
             raise RuntimeError(e.msg)
         except RuntimeError as e:
@@ -164,9 +164,9 @@ def get_backend(self, core, flags, backendargs=[]):
         else:
             old_edam = None
 
-        if edam != old_edam:
+        if edalizer.edam != old_edam:
             edalizer.to_yaml(edam_file)
 
         return edam_file, backend_class(
-            edam=edam, work_root=work_root, verbose=self.config.verbose
+            edam=edalizer.edam, work_root=work_root, verbose=self.config.verbose
         )