@@ -197,13 +197,16 @@ def generate_virtuals(target):
197197 f .write (txt )
198198
199199
200- def  get_file_list (api_filepath , output_dir , headers = False , sources = False ,  profile_filepath = "" ):
200+ def  get_file_list (api_filepath , output_dir , headers = False , sources = False ):
201201 api  =  {}
202-  files  =  []
203202 with  open (api_filepath , encoding = "utf-8" ) as  api_file :
204203 api  =  json .load (api_file )
205204
206-  build_profile  =  parse_build_profile (profile_filepath , api )
205+  return  _get_file_list (api , output_dir , headers , sources )
206+ 
207+ 
208+ def  _get_file_list (api , output_dir , headers = False , sources = False ):
209+  files  =  []
207210
208211 core_gen_folder  =  Path (output_dir ) /  "gen"  /  "include"  /  "godot_cpp"  /  "core" 
209212 include_gen_folder  =  Path (output_dir ) /  "gen"  /  "include"  /  "godot_cpp" 
@@ -235,7 +238,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False, profil
235238 source_filename  =  source_gen_folder  /  "classes"  /  (camel_to_snake (engine_class ["name" ]) +  ".cpp" )
236239 if  headers :
237240 files .append (str (header_filename .as_posix ()))
238-  if  sources   and   is_class_included ( engine_class [ "name" ],  build_profile ) :
241+  if  sources :
239242 files .append (str (source_filename .as_posix ()))
240243
241244 for  native_struct  in  api ["native_structures" ]:
@@ -267,128 +270,19 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False, profil
267270 return  files 
268271
269272
270- def  print_file_list (api_filepath , output_dir , headers = False , sources = False , profile_filepath = "" ):
271-  print (* get_file_list (api_filepath , output_dir , headers , sources , profile_filepath ), sep = ";" , end = None )
272- 
273- 
274- def  parse_build_profile (profile_filepath , api ):
275-  if  profile_filepath  ==  "" :
276-  return  {}
277-  print ("Using feature build profile: "  +  profile_filepath )
278- 
279-  with  open (profile_filepath , encoding = "utf-8" ) as  profile_file :
280-  profile  =  json .load (profile_file )
281- 
282-  api_dict  =  {}
283-  parents  =  {}
284-  children  =  {}
285-  for  engine_class  in  api ["classes" ]:
286-  api_dict [engine_class ["name" ]] =  engine_class 
287-  parent  =  engine_class .get ("inherits" , "" )
288-  child  =  engine_class ["name" ]
289-  parents [child ] =  parent 
290-  if  parent  ==  "" :
291-  continue 
292-  children [parent ] =  children .get (parent , [])
293-  children [parent ].append (child )
294- 
295-  # Parse methods dependencies 
296-  deps  =  {}
297-  reverse_deps  =  {}
298-  for  name , engine_class  in  api_dict .items ():
299-  ref_cls  =  set ()
300-  for  method  in  engine_class .get ("methods" , []):
301-  rtype  =  method .get ("return_value" , {}).get ("type" , "" )
302-  args  =  [a ["type" ] for  a  in  method .get ("arguments" , [])]
303-  if  rtype  in  api_dict :
304-  ref_cls .add (rtype )
305-  elif  is_enum (rtype ) and  get_enum_class (rtype ) in  api_dict :
306-  ref_cls .add (get_enum_class (rtype ))
307-  for  arg  in  args :
308-  if  arg  in  api_dict :
309-  ref_cls .add (arg )
310-  elif  is_enum (arg ) and  get_enum_class (arg ) in  api_dict :
311-  ref_cls .add (get_enum_class (arg ))
312-  deps [engine_class ["name" ]] =  set (filter (lambda  x : x  !=  name , ref_cls ))
313-  for  acls  in  ref_cls :
314-  if  acls  ==  name :
315-  continue 
316-  reverse_deps [acls ] =  reverse_deps .get (acls , set ())
317-  reverse_deps [acls ].add (name )
318- 
319-  included  =  []
320-  front  =  list (profile .get ("enabled_classes" , []))
321-  if  front :
322-  # These must always be included 
323-  front .append ("WorkerThreadPool" )
324-  front .append ("ClassDB" )
325-  front .append ("ClassDBSingleton" )
326-  while  front :
327-  cls  =  front .pop ()
328-  if  cls  in  included :
329-  continue 
330-  included .append (cls )
331-  parent  =  parents .get (cls , "" )
332-  if  parent :
333-  front .append (parent )
334-  for  rcls  in  deps .get (cls , set ()):
335-  if  rcls  in  included  or  rcls  in  front :
336-  continue 
337-  front .append (rcls )
338- 
339-  excluded  =  []
340-  front  =  list (profile .get ("disabled_classes" , []))
341-  while  front :
342-  cls  =  front .pop ()
343-  if  cls  in  excluded :
344-  continue 
345-  excluded .append (cls )
346-  front  +=  children .get (cls , [])
347-  for  rcls  in  reverse_deps .get (cls , set ()):
348-  if  rcls  in  excluded  or  rcls  in  front :
349-  continue 
350-  front .append (rcls )
351- 
352-  if  included  and  excluded :
353-  print (
354-  "WARNING: Cannot specify both 'enabled_classes' and 'disabled_classes' in build profile. 'disabled_classes' will be ignored." 
355-  )
356- 
357-  return  {
358-  "enabled_classes" : included ,
359-  "disabled_classes" : excluded ,
360-  }
361- 
362- 
363- def  scons_emit_files (target , source , env ):
364-  profile_filepath  =  env .get ("build_profile" , "" )
365-  if  profile_filepath  and  not  Path (profile_filepath ).is_absolute ():
366-  profile_filepath  =  str ((Path (env .Dir ("#" ).abspath ) /  profile_filepath ).as_posix ())
367- 
368-  files  =  [env .File (f ) for  f  in  get_file_list (str (source [0 ]), target [0 ].abspath , True , True , profile_filepath )]
369-  env .Clean (target , files )
370-  env ["godot_cpp_gen_dir" ] =  target [0 ].abspath 
371-  return  files , source 
372- 
373- 
374- def  scons_generate_bindings (target , source , env ):
375-  generate_bindings (
376-  str (source [0 ]),
377-  env ["generate_template_get_node" ],
378-  "32"  if  "32"  in  env ["arch" ] else  "64" ,
379-  env ["precision" ],
380-  env ["godot_cpp_gen_dir" ],
381-  )
382-  return  None 
273+ def  print_file_list (api_filepath , output_dir , headers = False , sources = False ):
274+  print (* get_file_list (api_filepath , output_dir , headers , sources ), sep = ";" , end = None )
383275
384276
385277def  generate_bindings (api_filepath , use_template_get_node , bits = "64" , precision = "single" , output_dir = "." ):
386-  api  =  None 
387- 
388-  target_dir  =  Path (output_dir ) /  "gen" 
389- 
278+  api  =  {}
390279 with  open (api_filepath , encoding = "utf-8" ) as  api_file :
391280 api  =  json .load (api_file )
281+  _generate_bindings (api , use_template_get_node , bits , precision , output_dir )
282+ 
283+ 
284+ def  _generate_bindings (api , use_template_get_node , bits = "64" , precision = "single" , output_dir = "." ):
285+  target_dir  =  Path (output_dir ) /  "gen" 
392286
393287 shutil .rmtree (target_dir , ignore_errors = True )
394288 target_dir .mkdir (parents = True )
@@ -2766,20 +2660,6 @@ def is_refcounted(type_name):
27662660 return  type_name  in  engine_classes  and  engine_classes [type_name ]
27672661
27682662
2769- def  is_class_included (class_name , build_profile ):
2770-  """ 
2771-  Check if an engine class should be included. 
2772-  This removes classes according to a build profile of enabled or disabled classes. 
2773-  """ 
2774-  included  =  build_profile .get ("enabled_classes" , [])
2775-  excluded  =  build_profile .get ("disabled_classes" , [])
2776-  if  included :
2777-  return  class_name  in  included 
2778-  if  excluded :
2779-  return  class_name  not  in excluded 
2780-  return  True 
2781- 
2782- 
27832663def  is_included (type_name , current_type ):
27842664 """ 
27852665 Check if a builtin type should be included. 
0 commit comments