Commit graph

1391 commits

Author SHA1 Message Date
Kp 03e12fedd4 Test for overzealous -Wdangling-reference
gcc-13 was released with -Wextra implying -Wdangling-reference, but
-Wdangling-reference as released warns on cases that are safe.  Add a
configure test to detect when the compiler warns incorrectly, and
disable the warning in those cases.  When a future compiler emits fewer
false positives, the suppression of the warning should stop.

Reported-by: ziplantil <https://github.com/dxx-rebirth/dxx-rebirth/issues/718>
2023-05-20 16:37:26 +00:00
Kp b7e96e0dac Reduce list copying in environment overrides
Prefer creating a copy explicitly, then appending or extending it as
needed, rather than using `__add__` and allowing it to duplicate the
sequence.  `__add__` has two undesirable properties in this script:

- Using `A + B + C` can create multiple temporaries unnecessarily.
- `A + B` typically requires that `A` and `B` be the same type of
  sequence, but this script does not need to require that.  Using an
  explicit copy+extend allows `A` and `B` to be different types of
  sequence.

Make use of the latter property to turn some member variables that were
`list` for the sake of `__add__`'s type requirement into `tuple`, since
they are never rewritten.
2023-03-23 01:14:37 +00:00
Kp 9b9a9712e4 Improve output in compile_commands.json
The link line is not used by clang, but is recorded in the hope that it
is useful for other tools.  Stabilize the output by requesting the
`str`, not the `repr`, of the input nodes.  `repr` in scons-4.4
generates a bare Python repr, rather than any useful text.  In addition
to not being useful, the bare repr exposes the memory address of the
`SCons.Node.FS.File`, which can vary from run to run even with no
changes to the code, causing needless rebuilds of the compilation
database.  The `str` of a node is its filename, which is stable across
runs.
2023-03-23 01:14:37 +00:00
Arne de Bruijn 769164a55b Fix SConstruct for scons 4.5.0+
env['CPPDEFINES'] may return a deque object in scons 4.5.0+ (see
SCons/scons#4321).
Explicitly convert it to a list where needed.

Tested with scons 4.4.0, 4.5.0, 4.5.1 and 4.5.2.
2023-03-22 10:52:33 +01:00
Kp 189ac23f61 Prefer V.copy over V[:] for creating shallow copies of sequences
According to `timeit`, this is slightly faster.  Also, `.copy()` will
work when `V` is a `collections.deque`, but `[:]` fails in that case.

SCons issue https://github.com/SCons/scons/issues/3876 (first released
in SCons 4.5.0) changed the storage of the `CPPDEFINES` variable from a
`list` to a `deque`, which broke use of `env.get(name, [])[:]`, since
`deque` cannot copy itself using `[:]`.  Switch to using `.copy()` to
obtain a shallow copy.

```
>>> # timing comparison
>>> timeit.timeit(stmt='a.copy()', setup='a = [1, 2, 3, 4]')
0.05652548000216484
>>> timeit.timeit(stmt='a[:]', setup='a = [1, 2, 3, 4]')
0.06801111809909344
```

```
>>> # deque cannot copy using slice notation
>>> a = [1, 2, 3]
>>> from collections import deque
>>> b = deque([1, 2, 3])
>>> a.copy()
[1, 2, 3]
>>> a[:]
[1, 2, 3]
>>> b.copy()
deque([1, 2, 3])
>>> b[:]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sequence index must be integer, not 'slice'
```

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/704>
2023-03-19 23:39:45 +00:00
Kp 5a5f10ff4f Print shell subcommands in reusable form
Switch from showing the Python tuple, which is unambiguous but hard to
run at a prompt, to showing the output of `shlex.join`, which is
normally correct for use at a shell prompt, and should still be
reasonably unambiguous.
2023-03-18 19:23:17 +00:00
Kp 4580811252 Use Python f-strings for SConstruct formatting 2023-03-18 19:23:17 +00:00
Kp 89e89c8afb Move global constants from mglobal.cpp to cglobal.cpp
These constants can be useful in unit tests, so move them out to their
own file.
2023-03-12 10:40:25 +00:00
Kp 6add766bb3 Generate build failure string in one step 2023-03-11 19:02:48 +00:00
Kp 805f3126db Simplify test for support of explicitly deleted functions
Support for explicitly deleted functions has been mandatory for a long
time.  Historically, this was handled through a special SConf test to
work around a clang-3.4 bug that warned when a deleted function had
named parameters.  Support for clang-3.4 was dropped some time ago, and
newer versions do not require this workaround.  Simplify the SConf
script by declaring explicitly deleted functions a required feature, so
that they can be tested as a group with the other required features.
2023-02-04 19:21:25 +00:00
Kp f76d023ec8 Skip SConf check_glu test when it would return immediately 2023-01-29 20:42:03 +00:00
Kp 54d04acbe1 Check pkg-config exit status
Only trust the output of pkg-config if it exited success.  Capture any
text sent to its stderr and reprint it, with decorations, to the screen
and to the log.
2023-01-26 02:49:21 +00:00
Kp 7b1a0fc643 Tighten and document the physfs zlib workaround 2023-01-26 02:49:21 +00:00
Kp 704bde86bd Move SysNoHogDir to CGameArg
Move DXX_USE_SHAREPATH definition to apply to common files too, since
common files see CGameArg.
2023-01-07 22:17:31 +00:00
Kp 8decd6ec99 Simplify DXX_ALWAYS_ERROR_FUNCTION
Since this should never be invoked, simplify the definition.  The new
version is slightly less informative in case a logic error causes it to
be called, but is far shorter and easier to understand.
2022-12-10 18:09:54 +00:00
Kreeblah 6ec1f8a196
Require SDL 2 for macOS builds 2022-11-11 11:23:52 -08:00
Kp 8a36c4c54b Remove obsolete test for gcc bug #82541
The bug is fixed in gcc-8, and the current minimum version is gcc-10.
2022-11-11 02:03:51 +00:00
Kp 1e836729f5 Remove obsolete test for -Wimplicit-fallthrough
Commit d2478d0708 made support for C++17 fallthrough mandatory, and
should have deleted this test.  Delete it now.

Fixes: d2478d0708 ("Require support for C++17 attribute [[fallthrough]]")
2022-11-11 02:03:51 +00:00
Kp b2e1345ac9 Remove test for gcc -Wuseless-cast constructor inheritance bug
The bug is fixed in all supported versions of gcc, so there is no need
to test for it anymore.
2022-11-11 02:03:51 +00:00
Kp 1110b110c2 Remove obsolete compiler test
gcc-5 and later produce the desired result by default.  The current
minimum gcc is gcc-10.
2022-11-11 02:03:51 +00:00
Kp 562fee9d09 Use #if for DXX_HAVE_CXX_BUILTIN_FILE_LINE 2022-11-10 02:04:09 +00:00
Kp 962a37e75e Backport more ranges support for OS X clang
Apple clang is currently version 14, but Apple's libc++ is version 13,
and so lacks even more std::ranges support than previously reported.
Add more stub backports to work around this.
2022-11-06 18:18:57 +00:00
Kp 3d5de92058 Fix OS X clang build
OS X still uses clang-14, which lacks sufficient std::ranges support for
recent Rebirth changes.

- Rewrite uses of std::ranges::SYMBOL to ranges::SYMBOL
- Add a stub header that, on gcc, provides for each SYMBOL a statement
  `using std::ranges::SYMBOL;`, to delegate back to the standard library
  implementation.
- On clang, define a minimal implementation of the required symbols,
  without constraint enforcement.  Compile-testing with gcc will catch
  constraint violations.

Once OS X clang ships a standard library with the required features,
this stub header will be removed and the uses changed back to their full
names.
2022-10-31 00:51:32 +00:00
Kp 4506d0f6f3 Change check_size_type_format_modifier to use ''.format 2022-10-23 23:00:24 +00:00
Kp ee4268bf9f Simplify variable binding in check_size_type_format_modifier 2022-10-23 23:00:24 +00:00
Kp 16698137ea Enable gcc attribute suggestion warnings
Adding `final` can allow gcc to devirtualize a call.  Request compiler
warnings wherever `final` would improve this.  As of this writing, there
are no places where `final` would be helpful and would also be wrong, so
this is enabled everywhere.
2022-10-16 23:20:34 +00:00
Kp 90d3d82d8e Default disable VR side-by-side for OpenGL ES
VR requires glDrawBuffer, which Mesa OpenGL ES does not offer.  Default
VR to disabled for OpenGL ES users.  Users who want to try it anyway can
still set use_stereo_render=1 in the SCons environment.
2022-10-09 23:15:20 +00:00
Kp e385ff1c3b Use std::ranges::find_if instead of std::find_if
std::ranges::find_if permits use of a sentinel instead of a full
iterator, and supports std::ranges::find as an alternative to certain
simple uses of std::find_if.

Where possible, use the form that takes a range, rather than the form
that takes two iterators.

Add a declared, but not defined, default constructor for
self_return_iterator to satisfy the standard library's concept
`semiregular`, which insists that sentinels be default-constructible,
even for those functions that never need to do so.

Add a defined, but unused, operator++(postfix) for zip_iterator to
satisfy a standard library concept for `forward_iterator`.
2022-10-09 23:15:20 +00:00
Kp d74dbeb79d Add constexpr to SConf operator== test
This allows using static_assert instead of a runtime comparison.
2022-10-09 23:15:20 +00:00
Kp d84de58d9b Add more special handling for Haiku OS
Haiku does not accept `-pthread`, and puts its network functions in a
separate library.  Add a special HaikuPlatformSettings to handle these
quirks.

Reported-by: LambdaCalculus37 <https://github.com/dxx-rebirth/dxx-rebirth/issues/641>
2022-10-02 19:51:36 +00:00
Kp 5b7fb9c402 Reduce use of quotes for passing vers_id defines
Windows shells interpret quoting differently from Linux shells, causing
some of the generated strings to have ugly escape sequences in them.
Switch to passing the defined values as lists of character codes, so
that no quoting is needed.  This makes the command line uglier, but
produces more readable strings in the generated program.
2022-10-02 19:51:36 +00:00
Kp 98b7679732 Remove obsolete MacOS C source files
These are not referenced in SConstruct.  messagebox.c uses C linkage for
symbols that would be referenced from a C++ file, so this has likely
been broken since the common code moved to C++.
2022-10-02 19:51:36 +00:00
Kp 8f1055ca6b Use std::span for poison helper functions 2022-09-24 17:47:51 +00:00
Kp ee68f43bb5 Remove SConf tests for curl, jsoncpp
These have been disabled since they were added in 2016, and the new HTTP
tracker they were meant to support was never put into service.  Remove
the tests.

Fixes: 9a8bd1aecb ("Add disabled tests for curl/jsoncpp")
2022-09-24 17:47:51 +00:00
Kp 232c648024 Add Windows version resource for Windows build 2022-09-11 17:00:45 +00:00
Kp 231acfe0ae Include git-describe data in archived snapshots 2022-08-31 01:46:58 +00:00
Kp c08b35ff45 Add SConf test for C++17 attribute [[nodiscard]]
This attribute is already in use in the code, but add an explicit test
to detect at configure time if the compiler lacks support for it.
2022-08-22 01:24:49 +00:00
Kp b8313fdeb0 Filter out empty feature text fragments
Avoid generating a banner comment over an empty text fragment.
2022-08-22 01:24:49 +00:00
Kp dc674eafe8 Replace various uses of std::enable_if with C++20 requires()
Compiler error messages are generally better when reporting a misuse
that fails a requires() versus reporting a misuse that fails a
std::enable_if.  In some cases, this also makes the code clearer, and
avoids the need for dummy template parameters as a place to invoke
std::enable_if.
2022-07-30 17:42:59 +00:00
Kp e5dcb8a505 Prefer C++20 std::span over internal span for decode_row
This generates the same code before and after.
2022-07-30 17:42:59 +00:00
Kp 25d0ae8f65 Use an explicitly defaulted exact_type<T>::operator==
clang-13 needed an operator==(const exact_type<T>&) defined to avoid an
ambiguity.  Now that C++20 mode is enabled, switch to a
compiler-generated operator== instead of manually defining the
equivalent function.
2022-07-02 18:10:45 +00:00
Kp aee963c015 Switch dialect to C++20
Future commits will introduce tests for and uses of C++20 features.
2022-07-02 18:10:45 +00:00
Kp e66da397a5 Add dummy 'file' key to executable entry in compilation database
clang rejects the entire database if any entry lacks a 'file' key,
regardless of whether the entry is used.

Fixes: bc6d043f5d ("Extend SConstruct compilation_database support to cover Program()")
2022-06-05 17:44:53 +00:00
Kp 58deb3c333 Rename check_header_includes object directory to be descriptive
Change from `chi` to `check_header_includes`.
2022-05-05 02:59:11 +00:00
Kp 97f8aea2f8 Use header path for check_header_includes=1 compilation database entries 2022-05-05 02:59:11 +00:00
Kp f95bc3193f Fix traceback when using GIT='' and check_header_includes=1
`check_header_includes` requires `git` to be installed and able to list
files from a working copy.  When `GIT=''` is used, SConstruct is told
not to find or run `git`.  This caused a traceback when
`check_header_includes` tried to use git to list headers.  Reorder the
test to report a clear failure message.
2022-04-24 20:42:01 +00:00
Kp 71b4c11f8c Combine DXX_HAVE_BUILTIN_BSWAP, DXX_HAVE_BUILTIN_BSWAP16
Commit f1606f7747 ("Simplify test for
__builtin_bswap16") changed the SConstruct test to either define both
DXX_HAVE_BUILTIN_BSWAP and DXX_HAVE_BUILTIN_BSWAP16 or to define neither
of them.  Follow up that commit by removing the definition of
DXX_HAVE_BUILTIN_BSWAP16 and redirecting uses of it to
DXX_HAVE_BUILTIN_BSWAP.
2022-04-17 22:27:19 +00:00
Kp 600a4f9d62 Remove special case for negative crc32
According to the documentation, starting in Python 3, the result is
always unsigned.
2022-04-16 19:38:02 +00:00
Kp f38a1b95a1 Simplify use of git-archive handling
The result of git-archive expanding `$Format:%H` will always be a valid
string.  Repeat the format specifier, so that the call to `.format()`
can be removed.
2022-02-13 19:13:38 +00:00
Kp 72064c62e7 Add unit tests for enumerate 2022-02-13 19:13:38 +00:00