33 - Target class may inherit from a toolchain_(toolchainname) |
33 - Target class may inherit from a toolchain_(toolchainname) |
34 - The target folder's name must match to name define in the XSD for TargetType |
34 - The target folder's name must match to name define in the XSD for TargetType |
35 """ |
35 """ |
36 |
36 |
37 |
37 |
38 |
|
39 from os import listdir, path |
38 from os import listdir, path |
40 import util.paths as paths |
39 import util.paths as paths |
|
40 import importlib |
41 |
41 |
42 _base_path = paths.AbsDir(__file__) |
42 _base_path = paths.AbsDir(__file__) |
43 |
43 |
44 |
44 |
45 def _GetLocalTargetClassFactory(name): |
45 def _GetLocalTargetClassFactory(name): |
46 return lambda: getattr(__import__(name, globals(), locals()), name+"_target") |
46 return lambda: getattr(importlib.import_module(f"targets.{name}"), f"{name}_target") |
47 |
47 |
48 |
48 |
49 targets = dict([(name, {"xsd": path.join(_base_path, name, "XSD"), |
49 targets = dict([(name, {"xsd": path.join(_base_path, name, "XSD"), |
50 "class": _GetLocalTargetClassFactory(name), |
50 "class": _GetLocalTargetClassFactory(name), |
51 "code": {fname: path.join(_base_path, name, fname) |
51 "code": {fname: path.join(_base_path, name, fname) |