Browse Source

Use a temporary file to store the bootstrap code in

Yentl Van Tendeloo 8 years ago
parent
commit
d37fd8aff1
2 changed files with 925 additions and 923 deletions
  1. 917 917
      bootstrap/bootstrap.m
  2. 8 6
      bootstrap/bootstrap.py

File diff suppressed because it is too large
+ 917 - 917
bootstrap/bootstrap.m


+ 8 - 6
bootstrap/bootstrap.py

@@ -1,6 +1,7 @@
 ### Configuration for creating the bootstrap model using conformance_bottom.
 import glob
 import hashlib
+import tempfile
 
 def bootstrap():
     root = ["__hierarchy"]
@@ -104,7 +105,7 @@ def bootstrap():
     initial_user = "user_manager"
     initial_user_code = \
     '''
-    include "primitives.alc"
+    include "bootstrap/primitives.alc"
     include "user_manager.alh"
 
     Void function __main():
@@ -117,7 +118,7 @@ def bootstrap():
 
     code_new_users = \
     '''
-    include "primitives.alc"
+    include "bootstrap/primitives.alc"
     include "user_interface.alh"
 
     Void function __main():
@@ -228,14 +229,15 @@ def bootstrap():
                     from hutn_compiler.compiler import main as compile_code
 
                     if not is_file:
-                        with open("bootstrap/bootstrap.al", "w") as f:
-                            f.write(code)
-                        filename = "bootstrap/bootstrap.al"
+                        f = tempfile.NamedTemporaryFile()
+                        f.write(code)
+                        f.flush()
+                        filename = f.name
                     else:
                         filename = code
                     code = compile_code(filename, "interface/HUTN/grammars/actionlanguage.g", "BS", ["--debug", "--prepend:%s" % prepend, "--main" if main else "--not-main"], symbols=symbols)
                     if not is_file:
-                        os.remove("bootstrap/bootstrap.al")
+                        f.close()
                     return code.replace("auto_initial_IP", target)
 
                 # Create all library code