Commit graph

116 commits

Author SHA1 Message Date
Andrii Doroshenko (Xrayez)
670205a22f 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.

(cherry picked from commit 80249e7190)
2020-07-13 15:13:14 +02:00
Rémi Verschelde
c87b4f9d71 SCons: Fix python2 compatibility after #37198 and #37248 2020-06-11 20:15: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)
d201163557 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.

(cherry picked from commit 12389b3736)
2020-06-04 12:09:39 +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
unknown
6e6db2d9cb Remove the dead function win32_spawn from methods.py.
(cherry picked from commit d78a78bc81)
2020-03-25 11:38:54 +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
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
Viktor Ferenczi
c5bd0c37ce Running builder (content generator) functions in subprocesses on Windows
- Refactored all builder (make_*) functions into separate Python modules along to the build tree
- Introduced utility function to wrap all invocations on Windows, but does not change it elsewhere
- Introduced stub to use the builders module as a stand alone script and invoke a selected function

There is a problem with file handles related to writing generated content (*.gen.h and *.gen.cpp)
on Windows, which randomly causes a SHARING VIOLATION error to the compiler resulting in flaky
builds. Running all such content generators in a new subprocess instead of directly inside the
build script works around the issue.

Yes, I tried the multiprocessing module. It did not work due to conflict with SCons on cPickle.
Suggested workaround did not fully work either.

Using the run_in_subprocess wrapper on osx and x11 platforms as well for consistency. In case of
running a cross-compilation on Windows they would still be used, but likely it will not happen
in practice. What counts is that the build itself is running on which platform, not the target
platform.

Some generated files are written directly in an SConstruct or SCsub file, before the parallel build starts. They don't need to be written in a subprocess, apparently, so I left them as is.
2018-07-27 21:37:55 +02:00
karroffel
b64171e79c add initial GLES2 3D renderer 2018-07-27 14:15:46 +02:00
Patrick Kaster
8bb90fd5f3 added 'android_add_asset_dir('...') method to Android module gradle build config
(cherry picked from commit 9190ae2be7)
2018-07-05 01:58:33 +02:00
Rhody Lugo
920224a535 add NoCache wrapper to Command 2018-06-21 03:00:33 -04:00
Ibrahn Sahir
27310974e0 fixed building using scons with python3
I broke python 3 builds by using py2 specific dict functions in
commit 98846b39ee
Fixed with functions in compat.py
2018-05-28 18:41:16 +01:00
Ibrahn Sahir
1433c2cbbb GDScript access to copyright, license, author and donor information.
Adds following functions to the Engine singleton:
get_author_info - names of Godot authors
get_copyright_info - detailed source copyright get_license_info
get_donor_info - donor names
get_license_info - full text of licenses used, indexed by license names
get_license_text - the text of the Godot Expat license
2018-05-19 00:40:16 +01:00
Henry Hirsch
291fa9deb4
Remove commented out code in methods.py 2018-05-05 07:55:30 +02:00
Leon Krause
d8d9eea722 Refactor JavaScript platform build script 2018-03-26 19:46:56 +02:00
Viktor Ferenczi
272ecddb28 Properly closing all files in Python code 2018-03-11 14:55:50 +01:00
karroffel
eac4c984df add GLES 2 renderer for 2D
This commit adds a new rendering backend, GLES2, and adds a
project setting to enable it.

Currently this backend can only be used on the X11 platform,
but integrating into other platforms is planned.
2018-03-01 15:12:30 +01:00
luz.paz
612ab4bbc6 Fix typos with codespell
Found via `codespell -q 3 --skip="./thirdparty,./editor/translations" -I ../godot-word-whitelist.txt`
Whitelist consists of:
```
ang
doubleclick
lod
nd
que
te
unselect
```
2018-02-21 19:46:06 +01:00
Kurtis Harms
e6f787cb02 Fix mixed use of tabs and spaces 2018-01-24 21:45:18 -08:00