Commit graph

163 commits

Author SHA1 Message Date
reduz
de0ca3b999 Refactor module initialization
* Changed to use the same stages as extensions.
* Makes the initialization more coherent, helping solve problems due to lack of stages.
* Makes it easier to port between module and extension.
* removed the DRIVER initialization level (no longer needed).
2022-05-04 17:34:51 +02:00
Rémi Verschelde
90162851a7
Core: Move generated VERSION_HASH to a .cpp file
This lets us have its definition in `core/version.h` and avoid
rebuilding a handful of files every time the commit hash changes.
2022-02-09 09:20:17 +01:00
Rémi Verschelde
64bb522021
Merge pull request #55968 from Calinou/scons-tweak-build-messages 2022-01-17 10:44:43 +01:00
Mario Liebisch
58051c2252
VS Projects: Don't include mono_reg without its module 2022-01-15 12:47:09 +01:00
Hugo Locurcio
419c0b9b11
Tweak SCons compilation messages to be more discreet
All compilation messages are now written in blue to ensure that
compiler errors and warnings stand out more. Messages were also
slightly shortened to make them easier to fit on a single line on
narrow terminals.
2021-12-15 20:13:00 +01:00
Rémi Verschelde
5341e6010e
Allow dehardcoding documentation branch and URL in docs links
This makes it possible to change the branch of the documentation that
URLs are pointing to without having to modify all class reference
files.

In the XML class reference, the `$DOCS_URL` placeholder should be used,
and will be replaced automatically in the editor and when generating
the RST class reference.

The documentation branch string is set in `version.py`.

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2021-11-15 13:02:21 +01:00
Hristo Stamenov
7ec6392d46 Fix import for collections Mapping
Mapping and other "abstract base classes" were moved after python 3.3 from collections to collections.abc
Python 3.3 is long gone and a newer version of python won't support this code.
2021-10-25 00:20:28 +03:00
Rémi Verschelde
1136d531b1
Merge pull request #53376 from ganondev/vsproj-props-for-mono 2021-10-18 10:47:08 +02:00
Rémi Verschelde
c133480531
SCons: List .gen.cpp sources explicitly to avoid globbing errors
Whenever we change the name (or remove) generated cpp files with the `.gen.cpp`
extension, users run into build issues when switching between branches (i.e.
switching before and after the name change/removal). This is because we glob
`*.cpp` so if a now-obsolete file from a previous build is present, we'll
include it too, potentially leading to bugs or compilation failure (due to
missing headers or invalid code).

So globbing patterns in `add_source_files` will now skip files ending with
`.gen.cpp`, which should instead be passed explicitly where they're used.
2021-10-15 22:14:11 +02:00
Edward Auttonberry
4c2f0a5c94 Variants and targets are generated instead of manually defined. The specific details for each configuration are logically separated from the generators
Add support for specifying defines for each configuration

Add support for specifying extra cli args for each configuration

Add support for specifying extra includes for each configuration
2021-10-06 00:32:59 -04:00
jfons
b197fc2079 Force optimized builds for thirdparty Embree files 2021-09-28 14:35:21 +02:00
bruvzg
4c3f7d1290 Makes FontData importable resource.
Adds multi-channel SDF font texture generation and rendering support.
Adds per-font oversampling support.
Adds FontData import plugins (for dynamic fonts, BMFonts and monospaced image fonts), font texture cache pre-generation and loading.
Adds BMFont binary format and outline support.
2021-08-27 15:43:18 +03:00
Rémi Verschelde
825b245f0d
SCons: Fix potential error when pruning cache on CI
This could cause spurious errors on CI when trying to prune the cache,
as for some reason it tries to remove files/paths which do not exist.

That points at a bug in the `cache_progress` logic but at least this
workaround should prevent CI failures.
2021-08-18 22:19:51 +02:00
Rémi Verschelde
34421683eb
SCons: Add method to detect Emscripten and use it for warnings config
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-06 12:12:37 +02:00
Rémi Verschelde
e92ba89dc7
SCons: Fix info message when defining GODOT_VERSION_STATUS 2021-08-05 12:20:45 +02:00
Rémi Verschelde
948dcb63ca
Allow overriding VERSION_STATUS with GODOT_VERSION_STATUS in env
`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-29 11:47:53 +02:00
reduz
5ad4f26659 Implement the ability to disable classes
* 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-07-13 09:25:14 -03:00
MmAaXx500
c759b7b235 Improve compiler version extraction 2021-05-31 20:31:12 +02:00
Resul Çelik
12dfdd546f SCons: Pass tests configuration to the MSVC solution
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-23 23:29:14 +01:00
Anshul7sp1
91181c2086 Fixes small typos and grammar correction 2021-03-12 19:05:16 +05:30
Rémi Verschelde
b97ef35585 SCons: Properly handle overriding default values to bool options
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-24 10:23:00 +01:00
Rémi Verschelde
75910d1e9b
SCons: Fix Godot detection in custom modules logic
`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-11 17:54:41 +01:00
Rémi Verschelde
c05d205a5c
Merge pull request #43057 from Xrayez/custom_modules_recursive
SCons: Add an option to detect C++ modules recursively
2021-02-08 16:00:03 +01:00
Marcel Admiraal
8ef5e3201c Don't handle BaseException in build scripts 2020-12-12 10:05:42 +00:00
Andrii Doroshenko (Xrayez)
a3c2c1e18a SCons: Add an option to detect C++ modules recursively
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-10-24 22:22:58 +03:00
Bartłomiej T. Listwon
317c2b194d Add all headers to VS Project 2020-09-27 18:03:51 +02:00
Bartłomiej T. Listwon
b0b5cd07ec Fix custom modules in Visual Studio 2020-09-18 19:33:03 +02:00
Rémi Verschelde
493b308215
Merge pull request #41453 from Xrayez/custom-modules-visual-studio
Build the engine with custom modules in Visual Studio
2020-09-03 11:57:15 +02:00
Marcel Admiraal
cba4a93a34 Merge python EnvironmentError, IOError and WindowsError into OSError. 2020-09-02 15:58:07 +01:00
Andrii Doroshenko (Xrayez)
6eb4b89eef Build the engine with custom modules in Visual Studio
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-22 18:22:09 +03:00
Rémi Verschelde
4f96c65e13
Style: Apply format changes from latest psf/black git 2020-08-21 01:34:56 +02:00
Andrii Doroshenko (Xrayez)
d86de6c98e SCons: Refactor running commands through builders
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-28 00:09:21 +03:00
Rémi Verschelde
f940e5e000 CI: Install master version of psf/black
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-26 19:48:25 +02:00
Tomasz Chabora
2407562366 Fix emoji branch compilation error 2020-07-23 19:42:37 +02:00
Andrii Doroshenko (Xrayez)
80249e7190 Expand env vars for custom_modules build option
The order of conversion is also changed to ensure that the resulting
path can be properly validated later on.
2020-07-10 15:58:16 +03:00
Rémi Verschelde
1aeb88205d
Merge pull request #37248 from Xrayez/env-dump
SCons: Dump construction environment to a file
2020-06-10 15:20:59 +02:00
Andrii Doroshenko (Xrayez)
42bee75e86 SCons: Dump construction environment to a file
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-10 15:05:43 +03:00
Rémi Verschelde
7c74312217 SCons: Validate dependencies for linked multimedia modules
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-06-03 11:00:10 +02:00
Rémi Verschelde
105bef19ff
Merge pull request #39125 from Xrayez/py-modules-order-4.0
SCons: use `OrderedDict` to ensure insertion order of modules
2020-05-28 20:55:56 +02:00
Andrii Doroshenko (Xrayez)
17938fd547 SCons: use OrderedDict to ensure insertion order of modules
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-28 18:17:49 +03:00
Rémi Verschelde
2aa46ee4ae
Merge pull request #37198 from Xrayez/progress-inside
SCons: Move build progress related logic out of main SConstruct
2020-05-27 14:34:04 +02:00
Andrii Doroshenko (Xrayez)
12389b3736 Do not rely on the existence of config.py while detecting modules
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-26 18:00:30 +03:00
Andrii Doroshenko (Xrayez)
a96f0e98d7 Add custom_modules build option to compile external user modules
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-05-25 15:33:32 +03:00
Rémi Verschelde
2e2ccb994b SCons: Expand CXX in check for vanilla Clang
I had missed it in df7ecfc4a7 it seems.

Fixes #37575.
2020-04-04 12:12:57 +02:00
Andrii Doroshenko (Xrayez)
d753a7630a Moved to methods.py as a show_progress method.
Some required changes are made:
- locally imported SCons-specific packages within the method;
- `global` variables converted to `nonlocal` (used in nested functions).
2020-03-30 17:35:13 +03:00
Rémi Verschelde
cd4e46ee65 SCons: Format buildsystem files with psf/black
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-30 09:05:53 +02:00
Rémi Verschelde
3d2dd79ecd SCons: Drop support for Python 2
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-25 15:25:37 +01:00
Rémi Verschelde
13a9bfbca7 Style: Harmonize header guards to style guide [Core] 2020-03-25 11:22:19 +01:00
unknown
d78a78bc81 Remove the dead function win32_spawn from methods.py. 2020-03-18 17:15:40 +05:30
Rémi Verschelde
df7ecfc4a7 SCons: Expand env variables to check compiler version
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-03-04 14:36:58 +01:00