Commit graph

128 commits

Author SHA1 Message Date
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
Rémi Verschelde
c7dc5142b5 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.
2020-02-26 14:23:34 +01:00
Rémi Verschelde
dd4eb5494f SCons: Re-allow upcoming GCC 8.4, fixes C++17 copy elision
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-26 09:06:39 +01:00
Nickolai Korshunov
c491232ae2 Scons: fixed build for vanilla clang in mac os x 2020-02-24 12:19:41 +03:00
Rémi Verschelde
214d852ffd SCons: Add GCC/Clang minimum version check
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-23 21:13:29 +01:00
Juan Linietsky
4fe3ee1730 Moved the shader source compilation code outside RenderingDevice and Vulkan 2020-02-11 11:53:29 +01:00
Rémi Verschelde
4e2dbb1bc0 SCons: Split libmodules.a in folder-based libs
This removes the need for the hacky split_libmodules logic on Windows,
since all libs are now of manageable size.
2020-02-07 14:19:51 +01:00
Rémi Verschelde
b7297fb39c SCons: Generate header with info on which modules are enabled
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-02-07 11:31:37 +01:00
Joost Heitbrink
dc61323b2c PCK: Set VERSION_PATCH in header, factor out header magic
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-06 13:13:17 +01:00
unknown
0ab7bd402a Remove unused imports 2020-01-03 01:02:38 +05:30
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
santouits
21297a533e fix getting correct mingw-w64 version
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-26 00:04:16 +03:00
Rémi Verschelde
66d09a6b4c SCons: Fix uses of [].append instead of env.add_source_files()
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-22 15:08:32 +02:00
Rémi Verschelde
b0d41847ed SCons: Use CPPDEFINES instead of CPPFLAGS for pre-processor defines
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.
2019-07-03 09:59:04 +02:00
hbina085
f4e1ed7e63 some variables in methods.py are not used
Thus they can be safely ignored
2019-06-29 06:56:57 -04:00
Rémi Verschelde
b10dd110e5 Print engine version to stdout when starting Godot
Also include website URL and make it configurable via version.py
together with the rest of the engine branding.

Add mention to MIT license in --help output.
2019-05-28 11:19:21 +02:00
Rémi Verschelde
c2a669a9f0 SCons: Review uses of CCFLAGS, CXXFLAGS and CPPFLAGS
Many contributors (me included) did not fully understand what CCFLAGS,
CXXFLAGS and CPPFLAGS refer to exactly, and were thus not using them
in the way they are intended to be.

As per the SCons manual: https://www.scons.org/doc/HTML/scons-user/apa.html

- CCFLAGS: General options that are passed to the C and C++ compilers.
- CFLAGS: General options that are passed to the C compiler (C only;
  not C++).
- CXXFLAGS: General options that are passed to the C++ compiler. By
  default, this includes the value of $CCFLAGS, so that setting
  $CCFLAGS affects both C and C++ compilation.
- CPPFLAGS: User-specified C preprocessor options. These will be
  included in any command that uses the C preprocessor, including not
  just compilation of C and C++ source files [...], but also [...]
  Fortran [...] and [...] assembly language source file[s].

TL;DR: Compiler options go to CCFLAGS, unless they must be restricted
to either C (CFLAGS) or C++ (CXXFLAGS). Preprocessor defines go to
CPPFLAGS.
2019-04-24 16:57:58 +02:00
Rémi Verschelde
8d867cf7c5 Also disable C and C++ specific warnings in thirdparty code
Move the `Append` up to make sure that the keys exist and avoid the
need to check `if CPPFLAGS in self`, etc.
2019-04-24 07:41:00 +02:00
Juan Linietsky
dd03dcbd5a Android now (optionally) builds the template when exporting
Added new way to create add-ons
Removed old way to create add-ons
2019-04-07 15:46:52 -03:00
Hendrikto
49a81308c0 Remove unused imports 2019-04-06 18:05:05 +02:00
Rémi Verschelde
e4a96164b6 SCons: add methods.using_clang to check used compiler
Also rename `use_gcc` to `using_gcc` to make it clear that it returns
a config but does not alter it.
2019-04-05 12:51:15 +02:00
Rémi Verschelde
195c5e0925 Move YEAR definition to version.py
If it needs to be hardcoded (for the sake of reproducible builds),
it should be together with the other hardcoded version info.

And yeah, two months in, let's move to 2019.
2019-03-05 23:07:03 +01:00
marxin
0d2a105e6b Come up with use_gcc.
Add new method. Fix wrong version condition for -fpie.
2019-02-23 09:17:11 +01:00
marxin
8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
George Marques
874cbefa26 Get Git commit hash when Godot is a submodule
Submodules don't have a .git folder in the same place, but a .git file
that points to the actual folder. This change take this into account.
2019-02-08 16:17:07 -02:00
Naoto Kondo
577e547b6a [macOS] Fixed a problem sdk path could not be detected 2018-11-26 19:42:17 +09:00
Rémi Verschelde
a2a5793e13
Merge pull request #21339 from Placinta/master
Fix regular macOS build by passing -isysroot to compiler so correct system headers are found
2018-11-20 14:11:13 +01:00
Rémi Verschelde
173b342ca7 Remove trailing whitespace
With `sed -i $(rg -l '[[:blank:]]*$' -g'!thirdparty') -e 's/[[:blank:]]*$//g'`
(+ manual revert of some thirdparty code under `platform/android`).
2018-11-20 11:15:02 +01:00
lupoDharkael
edcca5f7ad Dont use equality operators with None singleton in python files 2018-10-27 01:18:15 +02:00
Rémi Verschelde
2024666305 SCons: Add 'werror' opt-in to treat warning as errors
Also reorder advanced options to a more natural order,
and fix MSVC warning when disabling warnings in secondary environment.
2018-10-04 10:11:07 +02:00
Rémi Verschelde
3a2ca68af3 SCons: Build thirdparty code in own env, disable warnings
Also remove unnecessary `Export('env')` in other SCsubs,
Export should only be used when exporting *new* objects.
2018-09-28 14:07:39 +02:00
K. S. Ernest (iFire) Lee
35e5ba84d3 Fix #17843 inability to generate vs projects without being in a MSVC command prompt by guessing variables.
The vcxproj extension has been in MSVC 2012.
The sln extension has been in MSVC 2012.
2018-09-13 03:53:28 -07:00
Bernhard M. Wiedemann
83b856c046 BuildSystem: Sort input file lists
so that godot package builds reproducibly
in spite of indeterministic filesystem readdir order
and http://bugs.python.org/issue30461

See https://reproducible-builds.org/ for why this is good.

Sort font input file list, so that builtin_fonts.gen.h
is created in a reproducible way

Sort list of platforms, so that editor/register_exporters.gen.cpp
is created in a reproducible way

Sort list of source files, so that .a files and resulting godot binaries
are created in a reproducible way
2018-08-29 10:24:07 +02:00
Bernhard M. Wiedemann
853d9c0807 Do not record year of build
This value becomes part of get_version_info output,
but if it is changing every year without any other change,
it cannot be a useful indicator of anything.

Using a constant value, makes the package build reproducible.
See https://reproducible-builds.org/ for why this is good.
2018-08-29 05:55:37 +02:00
Alexandru Croitor
3624644630 Pass -isysroot to compiler / linker when doing a macOS build
Previously the compiler would use system headers located at
/System/Library/Frameworks, which could result in compilation failures
due to the headers not always being up-to-date in regards to the
latest installed macOS SDK headers that come with Xcode.

Fix the issue by passing the SDK path via the -isysroot option to the
compiler and linker invocations.

If no custom SDK path is given, the build system queries the SDK path
via xcrun --show-sdk-path, which returns something similar to

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/
 /Developer/SDKs/MacOSX.sdk/

Querying via xcrun is now also done for iphone (and simulator)
platforms as well.

Here is an example of a compilation failure message due to outdated
headers:

platform/osx/os_osx.mm:1421:41: error: use of undeclared identifier 'NSAppKitVersionNumber10_12'; did you mean 'NSAppKitVersionNumber'?
                                if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) {
                                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                    NSAppKitVersionNumber
/System/Library/Frameworks/AppKit.framework/Headers/NSApplication.h:26:28: note: 'NSAppKitVersionNumber' declared here
2018-08-27 18:01:05 +02:00
dragmz
8fd337e2df fix windows build using python 3.7
fixes NameError (missing "subprocess_main" and "basestring")
2018-07-28 18:13:48 +02:00