@@ -209,6 +209,38 @@ def options(opts, env):
209209 target_tool .options (opts )
210210
211211
212+ def make_doc_header (target , source , env ):
213+ dst = str (target [0 ])
214+ g = open (dst , "w" , encoding = "utf-8" )
215+ buf = ""
216+ docbegin = ""
217+ docend = ""
218+ for src in source :
219+ src_path = str (src )
220+ if not src_path .endswith (".xml" ):
221+ continue
222+ with open (src_path , "r" , encoding = "utf-8" ) as f :
223+ content = f .read ()
224+ buf += content
225+
226+ buf = (docbegin + buf + docend ).encode ("utf-8" )
227+ decomp_size = len (buf )
228+
229+ g .write ("/* THIS FILE IS GENERATED DO NOT EDIT */\n " )
230+ g .write ("#ifndef _GODOT_CPP_DOC_DATA_RAW_H\n " )
231+ g .write ("#define _GODOT_CPP_DOC_DATA_RAW_H\n " )
232+ g .write ('static const char *_doc_data_hash = "' + str (hash (buf )) + '";\n ' )
233+ g .write ("static const int _doc_data_uncompressed_size = " + str (decomp_size ) + ";\n " )
234+ g .write ("static const unsigned char _doc_data_uncompressed[] = {\n " )
235+ for i in range (len (buf )):
236+ g .write ("\t " + str (buf [i ]) + ",\n " )
237+ g .write ("};\n " )
238+
239+ g .write ("#endif" )
240+
241+ g .close ()
242+
243+
212244def generate (env ):
213245 # Default num_jobs to local cpu count if not user specified.
214246 # SCons has a peculiarity where user-specified options won't be overridden
@@ -317,6 +349,7 @@ def generate(env):
317349
318350 # Builders
319351 env .Append (BUILDERS = {"GodotCPPBindings" : Builder (action = scons_generate_bindings , emitter = scons_emit_files )})
352+ env .Append (BUILDERS = {"GodotCPPDocHeader" : Builder (action = make_doc_header )})
320353 env .AddMethod (_godot_cpp , "GodotCPP" )
321354
322355
0 commit comments