add support for external platforms and targets
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 24 Nov 2013 15:55:33 +0000 (16:55 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sun, 24 Nov 2013 15:55:33 +0000 (16:55 +0100)
make.py
targets/__init__.py [new file with mode: 0644]

diff --git a/make.py b/make.py
index 4ef7ef3ab65247aac6c3bfbcb0d4e59049c429df..1103173a6e7e935864fa8c8a3ee92c523287844b 100755 (executable)
--- a/make.py
+++ b/make.py
@@ -14,7 +14,9 @@ def _get_args():
        parser.add_argument("-p", "--platform", default="mixxeo", help="platform to build for")
        parser.add_argument("-t", "--target", default="mlabs_video", help="SoC type to build")
        parser.add_argument("-s", "--sub-target", default="", help="variant of the SoC type to build")
-       parser.add_argument("-o", "--option", default=[], nargs=2, action="append")
+       parser.add_argument("-o", "--option", default=[], nargs=2, action="append", help="set target-specific option")
+       parser.add_argument("-Xp", "--external-platform", default="", help="use external platform file in the specified path")
+       parser.add_argument("-Xt", "--external-target", default="", help="use external target file in the specified path")
        
        parser.add_argument("-B", "--no-bitstream", default=False, action="store_true", help="do not build bitstream file")
        parser.add_argument("-H", "--no-header", default=False, action="store_true", help="do not build C header files with CSR/IRQ/SDRAM_PHY definitions")
@@ -25,11 +27,20 @@ def _get_args():
 
        return parser.parse_args()
 
+def _misoc_import(default, external, name):
+       if external:
+               loader = importlib.find_loader(name, [external])
+               if loader is None:
+                       raise ImportError("Module not found: "+name)
+               return loader.load_module()
+       else:
+               return importlib.import_module(default + "." + name)
+
 def main():
        args = _get_args()
 
-       platform_module = importlib.import_module("mibuild.platforms." + args.platform)
-       target_module = importlib.import_module("targets." + args.target)
+       platform_module = _misoc_import("mibuild.platforms", args.external_platform, args.platform)
+       target_module = _misoc_import("targets", args.external_target, args.target)
        platform = platform_module.Platform()
        if args.sub_target:
                top_class = getattr(target_module, args.sub_target)
diff --git a/targets/__init__.py b/targets/__init__.py
new file mode 100644 (file)
index 0000000..e69de29