Introducing LunaBuild to the build flow (#36)
[lunaix-os.git] / lunaix-os / scripts / build-tools / lcfg / builtins.py
1 from .api import contextual, builtin
2 from .lcnodes import LCFuncNode, LCTermNode, LCModuleNode
3 from lib.utils import join_path
4 import os
5
6 @contextual()
7 def v(env, caller, term):
8     node = env.lookup_node(term.__name__)
9     env.dependency().add(node, caller)
10     
11     return env.lookup_value(node.get_name())
12
13 @contextual(caller_type=[LCModuleNode])
14 def include(env, caller, file):
15     fobj = caller.get_fo()
16     path = os.path.dirname(fobj.filename())
17
18     env.resolve_module(join_path(path, file))
19
20 @contextual("type", caller_type=[LCTermNode])
21 def term_type(env, caller, type):
22     caller.set_type(type)
23
24 @contextual("add_to_collection", caller_type=[LCFuncNode])
25 def parent(env, caller, ref):
26     sym = env.lookup_node(ref.__name__)
27
28     caller.set_parent(sym)
29
30 @contextual(caller_type=[LCTermNode])
31 def default(env, caller, val):
32     caller.set_default(val)