From a5cf92664db9633b9fb1307a801d99de70d09aba Mon Sep 17 00:00:00 2001 From: Riteo Date: Wed, 13 Mar 2024 17:54:14 +0100 Subject: SCons: unify code generations routine and minimize timestamp changes Previously, all of the code generation routines would just needlessly write the same files over and over, even when not needed. This became a problem with the advent of the experimental ninja backend for SCons, which can be trivially enabled with a few lines of code and relies on timestamp changes, making it thus impractical. --- platform_methods.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'platform_methods.py') diff --git a/platform_methods.py b/platform_methods.py index 37fc8a83ed..92aefcc648 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -5,6 +5,7 @@ import platform import uuid import functools import subprocess +import methods # NOTE: The multiprocessing module is not compatible with SCons due to conflict on cPickle @@ -67,8 +68,8 @@ def generate_export_icons(platform_path, platform_name): # NOTE: It is safe to generate this file here, since this is still executed serially. wf = export_path + "/" + name + "_svg.gen.h" - with open(wf, "w", encoding="utf-8", newline="\n") as svgw: - svgw.write(svg_str) + + methods.write_file_if_needed(wf, svg_str) def get_build_version(short): -- cgit v1.2.3 From 55558fb17574ddcbf0dcbba3f90a1aa880907f28 Mon Sep 17 00:00:00 2001 From: Riteo Date: Tue, 12 Mar 2024 22:51:19 +0100 Subject: SCons: Add an option to enable the experimental ninja build backend With this option turned on, if properly set up, SCons generates a `build.ninja` file and quits. To actually build the engine, the user can then call `ninja` with whatever options they might prefer (not everything is yet transferred properly to this new generated file). Ideally, the scons file should never be called again, as ninja automatically detects any SCons build script change and invokes the required commands to regenerate itself. This approach speeds up incremental builds considerably, as it limits SCons to code generation and uses ninja's extremely fast timestamp-based file change detector. --- platform_methods.py | 1 - 1 file changed, 1 deletion(-) (limited to 'platform_methods.py') diff --git a/platform_methods.py b/platform_methods.py index 92aefcc648..56115db4a4 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -66,7 +66,6 @@ def generate_export_icons(platform_path, platform_name): svg_str += '";\n' - # NOTE: It is safe to generate this file here, since this is still executed serially. wf = export_path + "/" + name + "_svg.gen.h" methods.write_file_if_needed(wf, svg_str) -- cgit v1.2.3