@@ -45,7 +45,6 @@ def check_version_info() -> None:
4545 exit (f'kitty requires Python { minver } . Current Python version: { "." .join (map (str , sys .version_info [:3 ]))} ' )
4646
4747
48- check_version_info ()
4948verbose = False
5049build_dir = 'build'
5150constants = os .path .join ('kitty' , 'constants.py' )
@@ -87,7 +86,6 @@ def __init__(self, incremental: bool = False):
8786 self .incremental = incremental
8887 self .compile_commands : List [Command ] = []
8988 self .link_commands : List [Command ] = []
90- self .build_shaders : Callable [[], None ] = lambda : None
9189 self .post_link_commands : List [Command ] = []
9290
9391 def add_command (
@@ -129,8 +127,6 @@ def sort_key(compile_cmd: Command) -> int:
129127 items .append (compile_cmd )
130128 parallel_run (items )
131129
132- self .build_shaders ()
133-
134130 items = []
135131 for compile_cmd in self .post_link_commands :
136132 if not self .incremental or compile_cmd .is_newer_func ():
@@ -1208,31 +1204,19 @@ def wrapped_kittens() -> str:
12081204 raise Exception ('Failed to read wrapped kittens from kitty wrapper script' )
12091205
12101206
1211- def build_shaders (args : Options ) -> None :
1207+ def build_shaders (args : Options , kitty_exe : str ) -> None :
12121208 if args .skip_code_generation :
12131209 print ('Skipping building of shaders due to command line option' , flush = True )
12141210 return
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
1211+ env = os .environ .copy ()
1212+ env ['ASAN_OPTIONS' ] = 'detect_leaks=0'
1213+ cp = subprocess .run ([
1214+ kitty_exe , '+launch' , os .path .join (src_base , 'kitty/shaders/slang.py' ), 'build/shaders' , 'shaders' ,
1215+ ], env = env )
1216+ if cp .returncode != 0 :
1217+ if os .environ .get ('CI' ) == 'true' and cp .returncode < 0 and shutil .which ('coredumpctl' ):
1218+ subprocess .run (['sh' , '-c' , 'echo bt | coredumpctl debug' ])
1219+ raise SystemExit (f'Generating shaders failed with exit code: { cp .returncode } ' )
12361220
12371221
12381222def build (args : Options , native_optimizations : bool = True , call_init : bool = True ) -> None :
@@ -1250,7 +1234,6 @@ def build(args: Options, native_optimizations: bool = True, call_init: bool = Tr
12501234 compile_glfw (args .compilation_database , args .build_dsym )
12511235 compile_kittens (args )
12521236 add_builtin_fonts (args )
1253- build_shaders (args )
12541237
12551238
12561239def safe_makedirs (path : str ) -> None :
@@ -1312,6 +1295,7 @@ def build_static_kittens(
13121295 raise SystemExit (f'The version of go on this system ({ current_go_version } ) is too old. go >= { required_go_version } is needed' )
13131296 if not for_platform :
13141297 update_go_generated_files (args , os .path .join (launcher_dir , appname ))
1298+ build_shaders (args , os .path .join (launcher_dir , appname ))
13151299 if args .skip_building_kitten :
13161300 print ('Skipping building of the kitten binary because of a command line option. Build is incomplete' , file = sys .stderr )
13171301 return ''
@@ -2363,6 +2347,7 @@ def do_build(args: Options) -> None:
23632347
23642348
23652349def main () -> None :
2350+ check_version_info ()
23662351 global verbose , build_dir
23672352 if len (sys .argv ) > 1 and sys .argv [1 ] == 'build-dep' :
23682353 return build_dep ()
0 commit comments