SCons: Generate all scripts natively, implement wrapper function
Retires methods.write_file_if_needed, as every single script is now generated through SCons methods directly! This means that these scripts will now show up on the Progressor & are automatically cleaned/rebuilt as needed. Any converted function that's tailored to a specific directory is now in the appropriate SCSub, to properly link up with their expected libraries.
In the process of converting these functions to SCons natively, I implemented methods.generated_wrapper to make the generated files much prettier. This wrapper is a contextlib.contextmanager, meaning it utilizes the with keyword to handle most boilerplate logic (automatically writes to provided path & adds documentation header + header guards) while only needing to be passed the SCons target. I'm very likely to continue porting over generated functions to this new wrapper (especially considering the high probability of other non-SCons generated scripts that didn't use methods.write_file_if_needed); however, I wanted to specifically focus on the methods.write_file_if_needed functions as that made for a healthy initial sample size.
Examples:
version_generated.gen.h | Before
/* THIS FILE IS GENERATED DO NOT EDIT */
#ifndef VERSION_GENERATED_GEN_H
#define VERSION_GENERATED_GEN_H
#define VERSION_SHORT_NAME "{short_name}"
#define VERSION_NAME "{name}"
#define VERSION_MAJOR {major}
#define VERSION_MINOR {minor}
#define VERSION_PATCH {patch}
#define VERSION_STATUS "{status}"
#define VERSION_BUILD "{build}"
#define VERSION_MODULE_CONFIG "{module_config}"
#define VERSION_WEBSITE "{website}"
#define VERSION_DOCS_BRANCH "{docs_branch}"
#define VERSION_DOCS_URL "https://docs.godotengine.org/en/" VERSION_DOCS_BRANCH
#endif // VERSION_GENERATED_GEN_H
version_generated.gen.h | After
/**************************************************************************/
/* version_generated.gen.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
/* THIS FILE IS GENERATED. EDITS WILL BE LOST. */
#ifndef VERSION_GENERATED_GEN_H
#define VERSION_GENERATED_GEN_H
#define VERSION_SHORT_NAME "godot"
#define VERSION_NAME "Godot Engine"
#define VERSION_MAJOR 4
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_STATUS "dev"
#define VERSION_BUILD "custom_build"
#define VERSION_MODULE_CONFIG ""
#define VERSION_WEBSITE "https://godotengine.org"
#define VERSION_DOCS_BRANCH "latest"
#define VERSION_DOCS_URL "https://docs.godotengine.org/en/" VERSION_DOCS_BRANCH
#endif // VERSION_GENERATED_GEN_H
windows/export/logo_svg.gen.h | Before
/* AUTOGENERATED FILE, DO NOT EDIT */
static const char *_windows_logo_svg = "\x3c\x73\x76\x67\x20\x68\x65\x69\x67\x68\x74\x3d\x22\x33\x32\x22\x20\x77\x69\x64\x74\x68\x3d\x22\x33\x32\x22\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x3e\x3c\x70\x61\x74\x68\x20\x64\x3d\x22\x6d\x31\x20\x35\x2e\x31\x33\x32\x20\x31\x32\x2e\x32\x39\x35\x2d\x31\x2e\x36\x39\x34\x76\x31\x31\x2e\x38\x37\x39\x48\x31\x7a\x6d\x30\x20\x32\x31\x2e\x37\x33\x36\x20\x31\x32\x2e\x32\x39\x35\x20\x31\x2e\x36\x39\x35\x56\x31\x36\x2e\x38\x33\x48\x31\x7a\x6d\x31\x33\x2e\x36\x34\x37\x20\x31\x2e\x38\x37\x35\x4c\x33\x31\x20\x33\x31\x56\x31\x36\x2e\x38\x33\x48\x31\x34\x2e\x36\x34\x37\x7a\x6d\x30\x2d\x32\x35\x2e\x34\x38\x36\x76\x31\x32\x2e\x30\x36\x48\x33\x31\x56\x31\x7a\x22\x20\x66\x69\x6c\x6c\x3d\x22\x23\x30\x30\x61\x62\x65\x64\x22\x2f\x3e\x3c\x2f\x73\x76\x67\x3e\xa";
windows/export/logo_svg.gen.h | After
/**************************************************************************/
/* logo_svg.gen.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
/* THIS FILE IS GENERATED. EDITS WILL BE LOST. */
#ifndef WINDOWS_LOGO_SVG_GEN_H
#define WINDOWS_LOGO_SVG_GEN_H
static const char *_windows_logo_svg = "\x3c\x73\x76\x67\x20\x68\x65\x69\x67\x68\x74\x3d\x22\x33\x32\x22\x20\x77\x69\x64\x74\x68\x3d\x22\x33\x32\x22\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x3e\x3c\x70\x61\x74\x68\x20\x64\x3d\x22\x6d\x31\x20\x35\x2e\x31\x33\x32\x20\x31\x32\x2e\x32\x39\x35\x2d\x31\x2e\x36\x39\x34\x76\x31\x31\x2e\x38\x37\x39\x48\x31\x7a\x6d\x30\x20\x32\x31\x2e\x37\x33\x36\x20\x31\x32\x2e\x32\x39\x35\x20\x31\x2e\x36\x39\x35\x56\x31\x36\x2e\x38\x33\x48\x31\x7a\x6d\x31\x33\x2e\x36\x34\x37\x20\x31\x2e\x38\x37\x35\x4c\x33\x31\x20\x33\x31\x56\x31\x36\x2e\x38\x33\x48\x31\x34\x2e\x36\x34\x37\x7a\x6d\x30\x2d\x32\x35\x2e\x34\x38\x36\x76\x31\x32\x2e\x30\x36\x48\x33\x31\x56\x31\x7a\x22\x20\x66\x69\x6c\x6c\x3d\x22\x23\x30\x30\x61\x62\x65\x64\x22\x2f\x3e\x3c\x2f\x73\x76\x67\x3e\xa";
#endif // WINDOWS_LOGO_SVG_GEN_H
I have no clue why the Windows test fails; it's passing without issue for me locally
@Repiteo I never touched the test suite before, but I'd take a look at modules/modules_tests.gen.h, since it's the only thing that really changed in that regard AFAICT.
From what I can tell, it looks like the gdscript test suite is responsible for loading the project settings and it, being a module, perhaps now gets loaded differently.
To remove any doubt I'd copy the current file, blast it out, let it regenerate and make a diff. That's probably why it works for you.
Finally got it to fail on my end, and it was through replicating the exact build flags used by GHA. Now I have a starting point to start looking back at where the disparity could've happened, though it'll still take quite a bit of digging.
Thanks!