|
10 | 10 |
|
11 | 11 |
|
12 | 12 | from binding_generator import scons_generate_bindings, scons_emit_files
|
| 13 | +from doc_source_generator import scons_generate_doc_source |
13 | 14 |
|
14 | 15 |
|
15 | 16 | def add_sources(sources, dir, extension):
|
@@ -336,51 +337,6 @@ def options(opts, env):
|
336 | 337 | tool.options(opts)
|
337 | 338 |
|
338 | 339 |
|
339 |
| -def make_doc_source(target, source, env): |
340 |
| - import zlib |
341 |
| - |
342 |
| - dst = str(target[0]) |
343 |
| - g = open(dst, "w", encoding="utf-8") |
344 |
| - buf = "" |
345 |
| - docbegin = "" |
346 |
| - docend = "" |
347 |
| - for src in source: |
348 |
| - src_path = str(src) |
349 |
| - if not src_path.endswith(".xml"): |
350 |
| - continue |
351 |
| - with open(src_path, "r", encoding="utf-8") as f: |
352 |
| - content = f.read() |
353 |
| - buf += content |
354 |
| - |
355 |
| - buf = (docbegin + buf + docend).encode("utf-8") |
356 |
| - decomp_size = len(buf) |
357 |
| - |
358 |
| - # Use maximum zlib compression level to further reduce file size |
359 |
| - # (at the cost of initial build times). |
360 |
| - buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION) |
361 |
| - |
362 |
| - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") |
363 |
| - g.write("\n") |
364 |
| - g.write("#include <godot_cpp/godot.hpp>\n") |
365 |
| - g.write("\n") |
366 |
| - |
367 |
| - g.write('static const char *_doc_data_hash = "' + str(hash(buf)) + '";\n') |
368 |
| - g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n") |
369 |
| - g.write("static const int _doc_data_compressed_size = " + str(len(buf)) + ";\n") |
370 |
| - g.write("static const unsigned char _doc_data_compressed[] = {\n") |
371 |
| - for i in range(len(buf)): |
372 |
| - g.write("\t" + str(buf[i]) + ",\n") |
373 |
| - g.write("};\n") |
374 |
| - g.write("\n") |
375 |
| - |
376 |
| - g.write( |
377 |
| - "static godot::internal::DocDataRegistration _doc_data_registration(_doc_data_hash, _doc_data_uncompressed_size, _doc_data_compressed_size, _doc_data_compressed);\n" |
378 |
| - ) |
379 |
| - g.write("\n") |
380 |
| - |
381 |
| - g.close() |
382 |
| - |
383 |
| - |
384 | 340 | def generate(env):
|
385 | 341 | # Default num_jobs to local cpu count if not user specified.
|
386 | 342 | # SCons has a peculiarity where user-specified options won't be overridden
|
@@ -513,7 +469,7 @@ def generate(env):
|
513 | 469 | env.Append(
|
514 | 470 | BUILDERS={
|
515 | 471 | "GodotCPPBindings": Builder(action=Action(scons_generate_bindings, "$GENCOMSTR"), emitter=scons_emit_files),
|
516 |
| - "GodotCPPDocData": Builder(action=make_doc_source), |
| 472 | + "GodotCPPDocData": Builder(action=scons_generate_doc_source), |
517 | 473 | }
|
518 | 474 | )
|
519 | 475 | env.AddMethod(_godot_cpp, "GodotCPP")
|
|
0 commit comments