Commit graph

292 commits

Author SHA1 Message Date
Aaron Franke
6c4928fe69
[3.x] Allow disabling the RegEx module in the editor 2021-09-21 08:49:17 -05:00
Omar Polo
abe5760a2d
automatically detect BSDs as platform=linuxbsd
(cherry picked from commit 78cd0ffdba)
2021-08-12 16:42:16 +02:00
Rémi Verschelde
e7f7d5f330
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.

(cherry picked from commit 34421683eb)
2021-08-12 16:37:38 +02:00
Rémi Verschelde
4c79dcc3e7
SCons: Disable Clang -Wordered-compare-function-pointers warning
It's raised for us on many comparators implemented to be able to store a struct
in `Set` or `Map` (who rely on `operator<` internally). In the cases I reviewed
we don't actually care about the ordering and we use the struct's function
pointers as that's the only distinctive data available.

(cherry picked from commit 802810c371)
2021-08-12 16:37:38 +02:00
Rémi Verschelde
3c8faed9e9
SCons: Avoid using Python f-string to preserve Python 3.5 compat
Fixes #50629.

(cherry picked from commit d1b39f0a14)
2021-07-20 13:05:13 +02:00
Rémi Verschelde
875045adde
Use modules_enabled.gen.h to improve inter dependency checks
- Fix build with gdscript module disabled. Fixes #31011.
- Remove unused `gdscript` compile option.
- Fix build with regex module disabled.
- Fix ImageLoaderSVG to forward declare thirdparty structs.

(cherry picked from commit f3726ee994)
2021-07-14 23:36:38 +02:00
Hendrik Brucker
55dbf24b98
Add elapsed time print statement to build system
(cherry picked from commit d070159094)
2021-07-13 10:20:02 +02:00
Yuri Sizov
dbd4b45ca2 Correct pre-deprication warning message regarding linuxbsd/x11 platform 2021-04-22 21:54:35 +03:00
Rémi Verschelde
b266cc2315
embree: Allow building against system library on Linux 2021-04-22 17:06:28 +02:00
Rafał Mikrut
6b6324441f
Allow to not optimize release build
(cherry picked from commit 0b298d201e)
2021-03-20 23:05:13 +01:00
Andrii Doroshenko (Xrayez)
a33b0c5319
Provide additional include paths for custom modules
Allows to use a module as a library, where an include path may start
with module's name itself.

(cherry picked from commit f712d68ceb)
2021-03-14 12:03:22 +01:00
Rémi Verschelde
0431241935 SCons: Use default env["ENV"] and prepend PATH to it
This fixes a regression from #46774 where `env["ENV"]` would miss some
important env variables on Windows, such as `SystemRoot`, `PATHEXT`, etc.

So we go back to the previous setup (letting SCons initialize `env["ENV"]`
as it sees fit for the host OS) but use `PrependENVPath` instead of
`AppendENVPath` to preserve the intended fix from #46774.

Fixes #46790 for 3.2.
2021-03-09 09:39:43 +01:00
Rémi Verschelde
6b48fce2b5 SCons: Fix parsing PATH when constructing base environment
We constructed the SCons environment without taking any (shell) environment
variables into account, and then appended a few, but too late. This would
cause variables like `env[CXX]` not to be properly expanded to respect a
non-standard `PATH`.

With this fix, setting:
```
PATH=$GODOT_SDK/bin:$PATH
```
will now properly use `$GODOT_SDK/bin/gcc` if available over `/usr/bin/gcc`.

(cherry picked from commit 5d217a9441)
2021-03-07 22:51:33 +01:00
Mateo Kuruk Miccino
bdf335d369 SCons: Fix profile type. It is a string
(cherry picked from commit 42f6d7a401)
2021-02-26 11:30:19 +01:00
Rémi Verschelde
92d59d0879 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:20:46 +01:00
Rémi Verschelde
1a740e87be
SCons: Make freetype module a mandatory editor dependency
Fixes #28650.

(cherry picked from commit 6b13f33fb0)
2021-02-18 15:00:23 +01:00
Andrii Doroshenko (Xrayez)
65a2f0dfd4
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.

(cherry picked from commit a3c2c1e18a)
2021-02-08 22:36:37 +01:00
Rémi Verschelde
f3c030aa47 SCons: Add production=yes option to use production defaults
This is meant for users making custom builds to match the options used on
optimized, official builds.

This enables, on the platforms which support them:
- `use_static_cpp=yes` (portable binaries for Linux and Windows)
- `use_lto=yes` (link time optimizations - note: requires a lot of RAM!)
- `debug_symbols=no` (no debug symbols, smaller binaries)

Also abort when using MSVC with `production=yes`, as:
- It cannot optimize the GDScript VM like GCC or Clang do, leading to
  significant performance drops.
- Its LTO support is unreliable, at least used to trigger crashes last
  we tried it extensively.

All options can still be overridden if specified, and the `dev=yes` option
was changed to also support overrides.

(cherry picked from commit db26871210)
2021-02-05 09:26:09 +01:00
Hugo Locurcio
c344bf88c6
Fix incorrect version requirement in the SCons compilation DB comment
(cherry picked from commit 9479bfe5f5)
2021-02-02 13:30:54 +01:00
Rémi Verschelde
ee77567cac
SCons: Fix build with p alias or platform auto-detection
Fixes a pre-existing bug that #44433 exposed.

It's pretty hacky, but we use `platform` in `env` both as an optional command
line option (instead it can be autodetected, or passed via the `p` alias, and
on Linux it might be overridden if you pass one of the convenience alias
values), and as the reference value for what platform we're building on.

Thus we override `env_base["platform"]` with the autodetected or validated
platform, but any call to `opts.Update(env_base)` overrides it with the
original command line option... causing e.g. #44448.

The proper fix would be to refactor all this so that we don't reuse
`env["platform"]` for platform detection (it could instead be e.g.
`env.platform` as a member variable which holds the validated value),
but for now I'm tapering over the immediate breakage.

Fixes #44448 and other breakages induced by #44433.

(cherry picked from commit 8f660393fe)
2020-12-29 16:02:00 +01:00
Rémi Verschelde
60959b085d
SCons: Add only selected platform's opts to env
Otherwise we can get situations where platform-specific opts with the same name
can override each other depending on the order at which platforms are parsed,
as was the case with `use_static_cpp` in Linux/Windows.

Fixes #44304.

This also has the added benefit that the `scons --help` output will now only
include the options which are relevant for the selected (or detected) platform.

(cherry picked from commit 0f84d8dc49)
2020-12-29 16:02:00 +01:00
Marcel Admiraal
e21adf2bc6 Don't handle BaseException in build scripts 2020-12-12 10:10:23 +00:00
Rémi Verschelde
f33ca5444a
SCons: Refactor and cleanup warnings definition
(cherry picked from commits 97f116d36b
and 56f3aba7b2)
2020-10-19 16:09:59 +02:00
Bartłomiej T. Listwon
858bdbacfd
Add all headers to VS Project
(cherry picked from commit 317c2b194d)
2020-09-29 13:57:56 +02:00
Hugo Locurcio
9790168b48
Alias the "linuxbsd" platform to "x11" for forward compatibility
This makes it possible to follow documentation designed for the
`master` branch while building the `3.2` branch.
2020-08-29 18:09:48 +02:00
Gordon MacPherson
5db6095bde update to use scons compile db tool
(cherry picked from commit 974a4cde9d)
2020-08-14 00:32:05 +02:00
Aaron Franke
8cd317b551 Disable "misleading indentation" warning on GCC
(cherry picked from commit 611fd8cb72)
2020-07-13 15:13:48 +02:00
Andrii Doroshenko (Xrayez)
23ef1e0f70 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.

(cherry picked from commit 42bee75e86)
2020-06-10 15:30:52 +02:00
Andrii Doroshenko (Xrayez)
bc21cd8592 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).

(cherry picked from commit d753a7630a)
2020-06-10 15:30:52 +02:00
Rémi Verschelde
7bf9787921 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.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Andrii Doroshenko (Xrayez)
9753181956 SCons: Allow to read custom_modules option via a file
The `custom_modules` option was only read via the command line
by fetching `ARGUMENTS` dictionary directly.

Instead, the option's value can now be read via any existing
configuration files (`custom.py`) as well as command line, while also
updating the environment.

(cherry picked from commit 6304d16915)
2020-06-04 12:09:40 +02:00
Andrii Doroshenko (Xrayez)
0138ba59ac 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 17:13:50 +03:00
Andrii Doroshenko (Xrayez)
133997654c 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.

(cherry picked from commit a96f0e98d7)
2020-05-25 17:08:38 +03:00
Rémi Verschelde
dcb68e0106 SCons: Improve registration of compilation_db tool, check version
There's a builtin `toolpath` option we can use for that, so no need to hack
around a custom `scons_site` path.

The script requires SCons 3.1.1 or later, so we enable it conditionally.

Follow-up to #32848.

(cherry picked from commit 22c718ab17)
2020-05-18 16:40:33 +02:00
RevoluPowered
9aa4648579 Added compilation database support for clang and gcc
This tool is originally from mongodb.

- Updated CPPSUFFIXES to use scons suffixes
- objective-c files will also be loaded into the compilation database where the compiler / tooling is available to compile the files.

Known limitations:

- This will not work with msvc as your compiler.

(cherry picked from commit 5a6f275b74)
2020-05-18 16:40:33 +02:00
Rémi Verschelde
98d0bf7d7a assimp: Clean and document buildsystem, prepare for unbundling
- Improve the SCsub to allow unbundling and remove unnecessary code.
- Move files around to match upstream source.
- Re-sync with upstream commit 308db73d0b3c2d1870cd3e465eaa283692a4cf23
  to ensure we don't have local modifications.
- Doesn't actually build against current version 5.0.1 due to the lack
  of the new ArmaturePopulate API that Gordon authored. We'll have to
  wait for a public release with that API (5.1?) to enable unbundling.

(cherry picked from commit 9d8a9ea826)
2020-03-06 23:53:23 +01:00
Rémi Verschelde
75164169c4 SCons: Fix get_compiler_version() to return ints
Otherwise comparisons would fail for compiler versions above 10.
Also simplified code somewhat to avoid using subprocess too much
needlessly.

(cherry picked from commits c7dc5142b5
and df7ecfc4a7)
2020-03-04 14:40:12 +01:00
Rémi Verschelde
c34b351b24 SCons: Explicitly define our C (C11) and C++ (C++14) standards
On GCC and Clang, we use C11 and C++14 with GNU extensions (`std=gnu11`
and `std=gnu++14`). Those are the defaults for current GCC and Clang,
and also match the feature sets we want to use in Godot.

On MSVC, we require C++14 support explicitly with `/std:c++14`, and
make it strict with the use of `/permissive-` (so features of C++17 or
later can't be used).

Moves the definition before querying environment flags and platform
config so that it can be overridden when necessary.

(cherry picked from commit 342f127362)
2020-03-04 14:12:19 +01:00
Fabian Mathews
7f62bed238 Added support to allow to compile Godot from the same directory while using different versions of python
(cherry picked from commit beee8b3776)
2020-01-01 11:52:11 +01:00
Rémi Verschelde
c320a82213 SCons: Add 'split_libmodules' option to workaround linker issue
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-12-11 15:40:28 +01:00
Rémi Verschelde
02913f53d3 pcre2: Use scons option to disable JIT on some platforms
Third-party platforms (e.g. console ports) need to be able to
disable JIT support in the regex module too, so it can't be
hardcoded in the module SCsub. This is cleaner this way anyway.

Fixes #19316.
2019-11-20 08:54:52 +01:00
Marcel Admiraal
a8836ba28d Remove dependency on the editor directory being in the build's include path.
- Add or remove the necessary subdirectorires to the includes to remove
dependency on the editor directory being in the build's include path.
- Ensure includes in modified files conform to style guideline.
- Remove editor from the build include path.
2019-10-10 08:57:00 +02:00
PouleyKetchoupp
a1a0fb1467 Prevent editor compilation with regex module disabled, which is not supported 2019-08-11 19:07:59 +02:00
Rémi Verschelde
5dae2ea777 SCons: Enable C++11 on the whole codebase
**Important:** This does not mean *yet* that C++11 features should be used
in contributions to Godot's codebase.

For now this change is done solely for feature branches working on Vulkan
support and GDScript typed instruction sets for Godot 4.0, which will both
use C++11 features and are based on the master branch.

The plan is to start porting the codebase to C++11 after Godot 3.2 is
released, following upcoming guidelines on the subset of new features that
should be used, and when/how to use them.

We will advertise clearly when C++11 contributions are open, especially
once we start a coordinated effort to port Godot's massive codebase. In the
meantime, please bear with us and good ol' C++03. :)
2019-07-22 17:17:30 +02:00
Hugo Locurcio
b07e46c59f
Add a platform=list SCons argument to list platforms
This also improves the message display and makes an invalid selection
exit with a non-zero status code.
2019-07-17 11:28:07 +02:00
Fabio Alessandrelli
aae6c075aa Remove libwebsocket. No longer used, yay! 2019-07-04 15:03:04 +02:00
Andrii Doroshenko (Xrayez)
7c11a1b162 Add support for creating editor icons per module
The functionality is similar to how `doc_classes` are retrieved per module.
The build system will search for custom icons path defined per module via
`get_icons_path()` method in `config.py` or default icons path.
If such paths don't exist, only the editor's own icons will be built.

Most module icons were moved from editor/icons to respective modules.
2019-06-28 23:42:26 +03:00
Rémi Verschelde
4853870a18 SCons: Enable -Wclobbered in warnings=extra for GCC 2019-06-20 11:11:44 +02:00
Andrii Doroshenko (Xrayez)
33f55369cb Enforce Unicode encoding in MSVC
This can help to solve compilation issues on systems with Japanese
locale with encodings like Shift_JIS and UTF-8-BOM.

Also be more consistent using String::utf8() to represent cyrilic
unicode characters in test_string.cpp

Clarified some comments in test_string.cpp for some Unicode characters.
2019-06-19 14:42:09 +03:00
Rémi Verschelde
beb34a0458 SCons: Enable -Werror and -Wextra in 'dev' build option
We're close to being able to compile all platforms with -Werror -Wextra,
so it's best if developers use those options when compiling their code
as those checks are also done on CI.

Also enabled -Wduplicated-branches on GCC.
2019-06-15 19:06:15 +02:00