summaryrefslogtreecommitdiff
path: root/methods.py
AgeCommit message (Collapse)Author
2021-08-06SCons: Add method to detect Emscripten and use it for warnings configRémi Verschelde
Emscripten is LLVM-based so we want to follow the same logic. But we can't just put it as a match in `methods.using_clang()` as that would mess with the compiler version detection logic used to restrict old GCC and Clang releases.
2021-08-05SCons: Fix info message when defining `GODOT_VERSION_STATUS`Rémi Verschelde
2021-07-29Allow overriding `VERSION_STATUS` with `GODOT_VERSION_STATUS` in envRémi Verschelde
`VERSION_STATUS` is part of what constitutes the reference version for a given Godot build, and is part of the version check for compatible export templates. For dev snapshots (alpha, beta, RCs), we usually set the `VERSION_STATUS` to a specific build number (e.g. `beta2`), but this change doesn't end up committed to the Git repository as we don't want to keep changing `version.py` for testing builds. So this new environment override will be what can be used in official builds and by users making custom builds for specific snapshots.
2021-07-13Implement the ability to disable classesreduz
* This PR adds the ability to disable classes when building. * For now it's only possible to do this via command like: `scons disable_classes=RayCast2D,Area3D` * Eventually, a proper UI will be implemented to create a build config file to do this at large scale, as well as detect what is used in the project.
2021-05-31Improve compiler version extractionMmAaXx500
2021-03-23SCons: Pass tests configuration to the MSVC solutionResul Çelik
Test sources and build parameter were not supplied to the visual studio project. This resulted in a build that was not able to be test using the --test command. Adding build parameter ensures we can test, and supplying the sources ensures we have all files to write new tests and edit existing ones.
2021-03-12Fixes small typos and grammar correctionAnshul7sp1
2021-02-24SCons: Properly handle overriding default values to bool optionsRémi Verschelde
The `dev=yes` and `production=yes` options work as aliases to set a number of options, while still aiming to allow overriding specific options if the user wishes so. (E.g. `production=yes use_lto=no` should work to enable production defaults *but* disable LTO.) That wasn't working as `ARGUMENTS.get()` returns a string and not a boolean as expected by `BoolVariable`, and this wasn't flagged as a bug... So added a helper method using SCons' `BoolVariable._text2bool` to do the conversion manually.
2021-02-11SCons: Fix Godot detection in custom modules logicRémi Verschelde
`exec()` was not a good idea as it assumes a certain type of `version.py` file similar to Godot's own file, which is not always a reliable assumption (see https://github.com/godotengine/godot/pull/43057#issuecomment-777632900). Also restores Python 2 support for the 3.2 branch.
2021-02-08Merge pull request #43057 from Xrayez/custom_modules_recursiveRémi Verschelde
SCons: Add an option to detect C++ modules recursively
2020-12-12Don't handle BaseException in build scriptsMarcel Admiraal
2020-10-24SCons: Add an option to detect C++ modules recursivelyAndrii Doroshenko (Xrayez)
This adds `custom_modules_recursive` which allows to detect and collect all nested C++ modules which may reside in any directory specified by `custom_modules` option. The detection logic is made to be more strict because `SCSub` may be used for organizing hierarchical builds within a module itself, so the existence of `register_types.h` and `config.py` is checked as well (these are all required for a C++ module to be compiled by Godot). For performance reasons, built-in modules are not checked recursively, and there's no benefit of doing so in the first place. It's now possible to specify a directory path pointing to a *single* module, as it may contain nested modules which are detected recursively.
2020-09-27Add all headers to VS ProjectBartłomiej T. Listwon
2020-09-18Fix custom modules in Visual StudioBartłomiej T. Listwon
2020-09-03Merge pull request #41453 from Xrayez/custom-modules-visual-studioRémi Verschelde
Build the engine with custom modules in Visual Studio
2020-09-02Merge python EnvironmentError, IOError and WindowsError into OSError.Marcel Admiraal
2020-08-22Build the engine with custom modules in Visual StudioAndrii Doroshenko (Xrayez)
First, compile the engine normally with: ``` scons custom_modules="path/to/your/modules" vsproj=yes ``` Then run the Visual Studio project. You can now rebuild the engine if you need to make changes to custom modules directly within IDE.
2020-08-21Style: Apply format changes from latest psf/black gitRémi Verschelde
2020-07-28SCons: Refactor running commands through buildersAndrii Doroshenko (Xrayez)
A new `env.Run` method is added which allows to control the verbosity of builders output automatically depending on whether the "verbose" option is set. It also allows to optionally run any SCons commands in a subprocess using the existing `run_in_subprocess` method, unifying the interface. `Action` objects wrap all builder functions to include a short build message associated with any action. Notably, this removes quite verbose output generated by `make_doc_header` and `make_editor_icons_action` builders.
2020-07-26CI: Install master version of psf/blackRémi Verschelde
Until https://github.com/psf/black/pull/1328 makes it in a stable release, we have to use the latest from Git. Apply new style fixes done by latest black.
2020-07-23Fix emoji branch compilation errorTomasz Chabora
2020-07-10Expand env vars for `custom_modules` build optionAndrii Doroshenko (Xrayez)
The order of conversion is also changed to ensure that the resulting path can be properly validated later on.
2020-06-10Merge pull request #37248 from Xrayez/env-dumpRémi Verschelde
SCons: Dump construction environment to a file
2020-06-10SCons: Dump construction environment to a fileAndrii Doroshenko (Xrayez)
A new `methods.dump(env)` is added to dump the construction environment used by SCons to build Godot to a `.scons_env.json`. The file can be used for debugging purposes and any external tool.
2020-06-03SCons: Validate dependencies for linked multimedia modulesRémi Verschelde
This is still a bit hacky and eventually we should rework the way we handle optional dependencies (especially with regard to builtin/system libs), but it's a simple first step. Fixes #39219.
2020-05-28Merge pull request #39125 from Xrayez/py-modules-order-4.0Rémi Verschelde
SCons: use `OrderedDict` to ensure insertion order of modules
2020-05-28SCons: use `OrderedDict` to ensure insertion order of modulesAndrii Doroshenko (Xrayez)
The insertion order for dictionaries is only a language feature for Python 3.6/3.7+ implementations, and not prior to that. This ensures that the engine won't be rebuilt if the order of detected modules changes in any way, as the `OrderedDict` should guarantee inerstion order.
2020-05-27Merge pull request #37198 from Xrayez/progress-insideRémi Verschelde
SCons: Move build progress related logic out of main SConstruct
2020-05-26Do not rely on the existence of `config.py` while detecting modulesAndrii Doroshenko (Xrayez)
The existence of `SCsub` is checked instead. This file is required for all modules, and prevents the build system to leave modules without `config.py` undetected, leading to silently ignoring the module during compilation.
2020-05-25Add `custom_modules` build option to compile external user modulesAndrii Doroshenko (Xrayez)
This patch adds ability to include external, user-defined C++ modules to be compiled as part of Godot via `custom_modules` build option which can be passed to `scons`. ``` scons platform=x11 tools=yes custom_modules="../project/modules" ``` Features: - detects all available modules under `custom_modules` directory the same way as it does for built-in modules (not recursive); - works with both relative and absolute paths on the filesystem; - multiple search paths can be specified as a comma-separated list. Module custom documentation and editor icons collection and generation process is adapted to work with absolute paths needed by such modules. Also fixed doctool bug mixing absolute and relative paths respectively. Implementation details: - `env.module_list` is a dictionary now, which holds both module name as key and either a relative or absolute path to a module as a value. - `methods.detect_modules` is run twice: once for built-in modules, and second for external modules, all combined later. - `methods.detect_modules` was not doing what it says on the tin. It is split into `detect_modules` which collects a list of available modules and `write_modules` which generates `register_types` sources for each. - whether a module is built-in or external is distinguished by relative or absolute paths respectively. `custom_modules` scons converter ensures that the path is absolute even if relative path is supplied, including expanding user paths and symbolic links. - treats the parent directory as if it was Godot's base directory, so that there's no need to change include paths in cases where custom modules are included as dependencies in other modules.
2020-04-04SCons: Expand CXX in check for vanilla ClangRémi Verschelde
I had missed it in df7ecfc4a7f8403144be2aa49bb47f9ead25926b it seems. Fixes #37575.
2020-03-30Moved to methods.py as a `show_progress` method.Andrii Doroshenko (Xrayez)
Some required changes are made: - locally imported SCons-specific packages within the method; - `global` variables converted to `nonlocal` (used in nested functions).
2020-03-30SCons: Format buildsystem files with psf/blackRémi Verschelde
Configured for a max line length of 120 characters. psf/black is very opinionated and purposely doesn't leave much room for configuration. The output is mostly OK so that should be fine for us, but some things worth noting: - Manually wrapped strings will be reflowed, so by using a line length of 120 for the sake of preserving readability for our long command calls, it also means that some manually wrapped strings are back on the same line and should be manually merged again. - Code generators using string concatenation extensively look awful, since black puts each operand on a single line. We need to refactor these generators to use more pythonic string formatting, for which many options are available (`%`, `format` or f-strings). - CI checks and a pre-commit hook will be added to ensure that future buildsystem changes are well-formatted.
2020-03-25SCons: Drop support for Python 2Rémi Verschelde
We now require SCons 3.0+ (first version with Python 3 support), and we set min required Python 3 version to 3.5 (3.4 and earlier are EOL).
2020-03-25Style: Harmonize header guards to style guide [Core]Rémi Verschelde
2020-03-18Remove the dead function win32_spawn from methods.py.unknown
2020-03-04SCons: Expand env variables to check compiler versionRémi Verschelde
Scons' `Environment.subst()` does that, and was already used in the other place where we query an env variable (`env["LINK"]` in x11 code). Fixes `3.2` iOS build after cherry-pick of #36559 (previously it only ran for GCC code, not iOS's Clang), and the same issue would likely affect `master` if iOS builds were enabled right now.
2020-02-26SCons: Fix get_compiler_version() to return intsRémi Verschelde
Otherwise comparisons would fail for compiler versions above 10. Also simplified code somewhat to avoid using subprocess too much needlessly.
2020-02-26SCons: Re-allow upcoming GCC 8.4, fixes C++17 copy elisionRémi Verschelde
Follow-up to #36484. The patches for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521 have now landed in the `releases/gcc-8` branch and will be in GCC 8.4.
2020-02-24Scons: fixed build for vanilla clang in mac os xNickolai Korshunov
2020-02-23SCons: Add GCC/Clang minimum version checkRémi Verschelde
Prevent using GCC 8 as it does not properly support C++17's guaranteed copy elision which we now need. (Upstream bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521) Follow-up to #36457 and #36436.
2020-02-11Moved the shader source compilation code outside RenderingDevice and VulkanJuan Linietsky
2020-02-07SCons: Split libmodules.a in folder-based libsRémi Verschelde
This removes the need for the hacky split_libmodules logic on Windows, since all libs are now of manageable size.
2020-02-07SCons: Generate header with info on which modules are enabledRémi Verschelde
We already had `MODULE_*_ENABLED` defines but only in the modules environment, and a few custom `*_ENABLED` defines in the main env when we needed the information in core. Now this is defined in a single header which can be included in the files that need this information.
2020-01-06PCK: Set VERSION_PATCH in header, factor out header magicJoost Heitbrink
Unify pack file version and magic to avoid hardcoded literals. `version.py` now always includes `patch` even for the first release in a new stable branch (e.g. 3.2). The public name stays without the patch number, but `Engine.get_version_info()` already included `patch == 0`, and we can remove some extra handling of undefined `VERSION_PATCH` this way. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2020-01-03Remove unused importsunknown
2019-12-11SCons: Add 'split_libmodules' option to workaround linker issueRémi Verschelde
The new 'split_libmodules=yes' option is useful to work around linker command line size limitations when linking a huge number of objects. We're currently over 64k chars when linking libmodules.a on Windows with MinGW, which triggers issues as seen in #30892. Even on Linux, we can also reach linker command line size limitations by adding more custom modules. We force this option to True for MinGW on Windows, which fixes #30892. Additional changes to lib splitting: - Fix linking of the split module libs with interdependent symbols, hacking our way into LINKCOM and SHLINKCOM to set the `--start-group` and `--end-group` flags. - Fix Python 3 compatibility in `methods.split_lib()`. - Drop seemingly obsolete condition for 'msys' on 'posix'. - Drop the unnecessary 'split_drivers' as the drivers lib is no longer too big since we moved all thirdparty builds to modules. Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2019-07-26fix getting correct mingw-w64 versionsantouits
When checking mingw-w64 version, at least on debian, the regex being used returned 86 because the name of the binary in debian starts with x86_64-w64 so we use the dumpversion option that gcc has. This fixes not compiling because gcc versions < 7 don't have some checks like shadow-local
2019-07-22SCons: Fix uses of [].append instead of env.add_source_files()Rémi Verschelde
Also added support for SCons project-absolute paths (starting with #) and warning about duplicates in add_source_files(), and fixed default_controller_mappings.gen.cpp being included twice after first build due to *.cpp globbing. Part of #30270.
2019-07-03SCons: Use CPPDEFINES instead of CPPFLAGS for pre-processor definesRémi Verschelde
It's the recommended way to set those, and is more portable (automatically prepends -D for GCC/Clang and /D for MSVC). We still use CPPFLAGS for some pre-processor flags which are not defines.