integration/builder: escape backslash in makefile defines
authorSebastien Bourdeauducq <sb@m-labs.hk>
Wed, 14 Oct 2015 13:45:36 +0000 (21:45 +0800)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Wed, 14 Oct 2015 13:45:36 +0000 (21:45 +0800)
misoc/integration/builder.py

index ef89eaf636c66362a9f211246bbec2dceced2363..bf8aff82b32b2da5bcd174e9096bd6b823c8275f 100644 (file)
@@ -23,6 +23,10 @@ misoc_software_packages = [
 misoc_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
 
 
+def _makefile_escape(s):
+    return s.replace("\\", "\\\\")
+
+
 class Builder:
     def __init__(self, soc, output_dir=None,
                  compile_software=True, compile_gateware=True,
@@ -63,7 +67,7 @@ class Builder:
         os.makedirs(generated_dir, exist_ok=True)
         with open(os.path.join(generated_dir, "variables.mak"), "w") as f:
             def define(k, v):
-                f.write("{}={}\n".format(k, v))
+                f.write("{}={}\n".format(k, _makefile_escape(v)))
             for k, v in cpu_interface.get_cpu_mak(cpu_type):
                 define(k, v)
             define("MISOC_DIRECTORY", misoc_directory)