@@ -87,6 +87,7 @@ def __init__(self, incremental: bool = False):
8787 self .incremental = incremental
8888 self .compile_commands : List [Command ] = []
8989 self .link_commands : List [Command ] = []
90+ self .build_shaders : Callable [[], None ] = lambda : None
9091 self .post_link_commands : List [Command ] = []
9192
9293 def add_command (
@@ -128,6 +129,8 @@ def sort_key(compile_cmd: Command) -> int:
128129 items .append (compile_cmd )
129130 parallel_run (items )
130131
132+ self .build_shaders ()
133+
131134 items = []
132135 for compile_cmd in self .post_link_commands :
133136 if not self .incremental or compile_cmd .is_newer_func ():
@@ -1209,25 +1212,27 @@ def build_shaders(args: Options) -> None:
12091212 if args .skip_code_generation :
12101213 print ('Skipping building of shaders due to command line option' , flush = True )
12111214 return
1212- ddir = 'shaders'
1213- os .makedirs (ddir , exist_ok = True )
1214- bdir = 'build/shaders'
1215- os .makedirs (bdir , exist_ok = True )
1216-
1217- def prun (cmds : Iterable [tuple [bool , str , list [str ]]]) -> None :
1218- needed = []
1219- for (needs_build , desc , cmd ) in cmds :
1220- if needs_build :
1221- desc = re .sub (r'\|(.+?)\|' , lambda m : emphasis (m .group (1 )), desc )
1222- needed .append (Command (desc , cmd , lambda : True ))
1223- parallel_run (needed )
1224-
1225- sys .path .insert (0 , os .path .abspath ('kitty' ))
1226- try :
1227- from kitty .shaders .slang import compile_builtin_shaders
1228- compile_builtin_shaders (bdir , ddir , prun )
1229- finally :
1230- del sys .path [0 ]
1215+ def do_build () -> None :
1216+ ddir = 'shaders'
1217+ os .makedirs (ddir , exist_ok = True )
1218+ bdir = 'build/shaders'
1219+ os .makedirs (bdir , exist_ok = True )
1220+
1221+ def prun (cmds : Iterable [tuple [bool , str , list [str ]]]) -> None :
1222+ needed = []
1223+ for (needs_build , desc , cmd ) in cmds :
1224+ if needs_build :
1225+ desc = re .sub (r'\|(.+?)\|' , lambda m : emphasis (m .group (1 )), desc )
1226+ needed .append (Command (desc , cmd , lambda : True ))
1227+ parallel_run (needed )
1228+
1229+ sys .path .insert (0 , os .path .abspath ('kitty' ))
1230+ try :
1231+ from kitty .shaders .slang import compile_builtin_shaders
1232+ compile_builtin_shaders (bdir , ddir , prun )
1233+ finally :
1234+ del sys .path [0 ]
1235+ args .compilation_database .build_shaders = do_build
12311236
12321237
12331238def build (args : Options , native_optimizations : bool = True , call_init : bool = True ) -> None :
0 commit comments