migrate stock user space build to new build system
[lunaix-os.git] / lunaix-os / scripts / build-tools / lcfg2 / builder.py
index 83a49c2ef64e40d257cfce75c4c6955502600180..832807afbe12f62381ea0f8ede2288d879dfa834 100644 (file)
@@ -1,4 +1,6 @@
 import ast
+import textwrap
+import os
 
 from lib.utils  import ConfigAST, ConfigASTVisitor
 from .common     import NodeProperty, ConfigNodeError, ValueTypeConstrain
@@ -69,7 +71,7 @@ class NodeBuilder(ConfigASTVisitor):
                 astns.append(sub)
 
             NodeProperty.Token[cfgn] = node
-            NodeProperty.HelpText[cfgn] = help_text
+            NodeProperty.HelpText[cfgn] = textwrap.dedent(help_text)
             
             if cfgn_type is TermNode:
                 NodeProperty.Type[cfgn] = ValueTypeConstrain(cfgn, node.returns)
@@ -98,6 +100,10 @@ class NodeBuilder(ConfigASTVisitor):
 
     @staticmethod
     def build(env, rootfile):
+        if not os.path.exists(rootfile):
+            print(f"warning: config file '{rootfile}' not detected, skipped")
+            return
+
         build = NodeBuilder(env)
         ast = ConfigAST(rootfile)
         
@@ -105,5 +111,8 @@ class NodeBuilder(ConfigASTVisitor):
         ast.visit(TreeSanitiser())
         ast.visit(build)
 
+        for node in env.nodes():
+            node.apply_node_body()
+
         env.set_exec_context(build.__noncfg_astns)
         env.relocate_children()
\ No newline at end of file