Commit graph

5345 commits

Author SHA1 Message Date
6ec6efadf8
tgf: Introduce GfParmReadFileBoth
This new function attempts to read a parameter file from GfLocalDir()
first, and from GfDataDir() if not successful.

This function will be useful to extract car and track data from both
directories. Having car and track data available from GfLocalDir() is
required to allow users downloading new cars and tracks without
administrator/root privileges.
2025-01-19 08:35:35 +01:00
ed97add0a0
grsound.cpp: Use GfFileExists instead of fopen(3)
Opening a file only to check whether it exists is resource-consuming for
no reason, since GfFileExists can achieve the same effect without
requiring to open a file.
2025-01-19 08:35:34 +01:00
36d5490d1a
grsound.cpp: Remove trailing whitespaces 2025-01-19 08:35:34 +01:00
df796359dd
OsgLoader.h: Add missing include guards 2025-01-19 08:35:34 +01:00
05060efeb9
osggraph: Avoid including car.h on header files
car.h defines a bunch of macros with a leading underscore (e.g.: _name)
that can clash with symbols from other projects.

More specifically, the _name macro was causing header files from
OpenSceneGraph to break, since they already used _name for other
purposes.
2025-01-19 08:35:34 +01:00
ec61c3700e Merge pull request 'Several CMake-related improvements and bugfixes' (#23) from cmake-fixes into main
Reviewed-on: #23
2025-01-19 08:35:01 +01:00
48bea8cf25
CMakeLists.txt: Remove reference to INSTALL_SD_CMAKE
Some checks failed
/ build (pull_request) Has been cancelled
This macro had already been removed by the commit below. Moreover,
in-tree builds are discouraged by CMake.

commit cf18241a16
Author: Xavier Del Campo Romero <xavi.dcr@tutanota.com>
Date:   Sat Dec 28 14:13:38 2024 +0100

    cmake: Get SD_DATADIR from speed-dreams-data package
2025-01-19 08:33:07 +01:00
6df4b6bf98
CMakeLists.txt: Assume CMAKE_INSTALL_RPATH for packaging
CPack does not install to CMAKE_INSTALL_PREFIX, but
CPACK_PACKAGING_INSTALL_PREFIX. However, the executables' rpath
would still be configured for ${CMAKE_INSTALL_PREFIX}/${SD_LIBDIR}/lib
instead of ${CPACK_PACKAGING_INSTALL_PREFIX}/${SD_LIBDIR}/lib,
making executables to fail to find their respective shared libraries.

Unfortunately, CPACK_PACKAGING_INSTALL_PREFIX is not defined by CMake,
but CPack, so it is not available from this context, so this commit
assumes its default value. [1]

[1]: https://cmake.org/cmake/help/latest/variable/CPACK_PACKAGING_INSTALL_PREFIX.html
2025-01-19 08:33:07 +01:00
195f223d5f
Remove cmake/uninstall.cmake
Having an uninstall target is unjustified extra maintenance burden for
no benefit.

Instead, it is recommended to install to a CMAKE_INSTALL_PREFIX that the
user can easily remove e.g.: by deleting a directory as a
non-privileged user.
2025-01-19 08:33:07 +01:00
791428f66c
cmake: Remove clobber script
CMake discourages in-tree builds (i.e., when PROJECT_SOURCE_DIR equals
PROJECT_BINARY_DIR), and so is the use of a clobber script for in-tree
builds.
2025-01-19 08:33:07 +01:00
e26c923811
cmake: Remove IN_SOURCETREE
config.h is always generated from config.h.in.cmake, so IN_SOURCETREE
did not provide any actual value.
2025-01-19 08:33:07 +01:00
c5266013fc
cmake: Use CMAKE_CXX_COMPILER_ID
SD_BUILD_INFO_COMPILER_NAME is redundant since CMAKE_CXX_COMPILER_ID can
already be used for this purpose, even if their values are not
identical.
2025-01-19 08:33:07 +01:00
14a19abcc6
Move CMAKE_MODULE_PATH to top-level CMakeLists.txt
There is no need to assign CMAKE_MODULE_PATH every time macros.cmake is
included.
2025-01-19 08:33:07 +01:00
90f44af3b1
CMakeLists.txt: Use CMAKE_INSTALL_RPATH_USE_LINK_PATH
When set, this CMake variable converts the rpath from the build
directory to the installation directory. [1]

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH.html
2025-01-19 08:32:36 +01:00
7e0f8b111a
cmake: Set CMAKE_INSTALL_RPATH from top-level CMakeLists.txt
There is no need to assign this variable every time macros.cmake is
included.
2025-01-19 08:19:23 +01:00
f845faad4a
macros.cmake: Simplify SD install directories
The build system relied on overly complex logic already defined by the
GNUInstallDirs module [1], which is already included by the top-level
CMakeLists.txt.

[1]: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
2025-01-19 08:19:23 +01:00
ce1b5555cd
macros.cmake: Remove CURRENT_LIST_FILE_PATH
CMAKE_CURRENT_LIST_DIR already holds the path to the directory for the
current list file. [1]

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html
2025-01-19 08:19:23 +01:00
ce433d14d2
cmake: Replace SOURCE_DIR with CMAKE_SOURCE_DIR
CMAKE_SOURCE_DIR already points to the directory for the top-level
CMakelists.txt [1], so SOURCE_DIR is redundant.

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_SOURCE_DIR.html
2025-01-19 08:19:23 +01:00
1e660bc583
CMakeLists.txt: Always set data_version
Otherwise, cpack/debian.cmake would be unable to propagate the required
version for speed-dreams-data to CPACK_DEBIAN_PACKAGE_DEPENDS [1] when
SD_ASSUME_DATADIR is defined.

[1]: https://cmake.org/cmake/help/latest/cpack_gen/deb.html#variable:CPACK_DEBIAN_PACKAGE_DEPENDS
2025-01-19 08:19:22 +01:00
ae4f837d5a
CMakeLists.txt: Fix undefined behaviour on EXISTS
According to the documentation [1], EXISTS only has well-defined
behaviour when an absolute path is given. This fixes a bug where
re-configuring the project would fail because CMake would inadverently
jump to the invalid branch.

[1]: https://cmake.org/cmake/help/latest/command/if.html#exists
2025-01-19 08:19:22 +01:00
8d3ca718b5
legacymenu: Make networkingmenu.cpp optional
networkingmenu.cpp was always being built, but the CLIENT_SERVER macro
was used to comment out the implementation. A more orthodox way to
achieve the same effect without relying on macros is to let the build
system decide whether this source file should be built.
2025-01-19 08:19:22 +01:00
4776e34329 Merge pull request 'racemanagers.cpp: Do not list championship on no cars' (#22) from xavi/speed-dreams-code:fix-championship into main
Reviewed-on: #22
2025-01-19 08:18:18 +01:00
1531992af5
Bump speed-dreams-data
Some checks are pending
/ build (pull_request) Has started running
The following commit is related to recent fixes on championship mode:

commit 4af7c4d6f028dabf677941f0b5cdb96bae392648
Author: Xavier Del Campo Romero <xavi.dcr@tutanota.com>
Date:   Fri Jan 17 11:56:30 2025 +0100

    raceman: Remove fixed driver lists

    Drivers can be generated by users, driver indexes are re-computed on
    startup and no drivers are provided on a fresh installation, so it is no
    longer possible to set up a fixed list of drivers on each championship
    type.
2025-01-19 08:16:51 +01:00
f593629982
racemanagers.cpp: Do not list championship on no cars
Some checks failed
/ build (pull_request) Failing after 42s
Some championships depend on a given car category (e.g.: "36GP") that
might have not been installed yet by the user.

Making the championship not available fixes a out-of-bounds access when
reading VecCarCategoryIds in driverselect.cpp.
2025-01-19 07:22:34 +01:00
ac052b58d0 Merge pull request 'README.md: Fix invalid links' (#20) from fix-readme-2 into main
Reviewed-on: #20
2025-01-15 07:44:40 +01:00
6c3eea2dee
README.md: Fix invalid links
Some checks failed
/ build (pull_request) Has been cancelled
2025-01-15 07:43:45 +01:00
5e7335fe99 Merge pull request 'README.md: Minor changes' (#19) from fix-readme into main
Reviewed-on: #19
2025-01-15 07:35:45 +01:00
a990abe1c0
README.md: Add project logo
Some checks failed
/ build (pull_request) Has been cancelled
2025-01-15 07:34:29 +01:00
17af4eab29
README.md: Fix wrong links to submodule 2025-01-15 07:33:19 +01:00
bd5f11b80b Merge pull request 'Add speed-dreams-data as submodule' (#18) from data-submodule into main
Reviewed-on: #18
2025-01-15 07:17:04 +01:00
8cb2219134
build-w64-mingw32.yml: Clone repository recursively
Some checks failed
/ build (pull_request) Failing after 34s
Now that speed-dreams-data is provided as a submodule, this workflow can
package a NSIS installer that contains both code and data.
2025-01-15 07:16:39 +01:00
c5d07414fe
README.md: Update according to new build system features 2025-01-15 07:14:41 +01:00
c34ed2f809
Replace packaging/3rdParty-devel/readme.txt with README.md 2025-01-15 06:36:59 +01:00
880d53d88a
Find speed-dreams-data submodule by default
Now that speed-dreams-data is available as a submodule, this allows the
build system to choose it for in-tree builds. Therefore, CMake will
perform in the following order:

1. Do not search the speed-dreams-data package if SD_ASSUME_DATADIR is
   set.
2. Otherwise, do an in-tree build if the submodule has been updated.
3. Otherwise, search for the speed-dreams-data package on standard
   locations and CMAKE_PREFIX_PATH and/or CMAKE_FIND_ROOT_PATH.
4. Otherwise, return an error message.

SD_HAS_DATADIR was rendered redundant, so it has been removed. However,
SD_DATADIR_INSTALL_PREFIX was introduced because it would not equal
SD_DATADIR_ABS for in-tree builds, where an installed version of the
speed-dreams-data package is not required.

In-tree builds now allow to generate NSIS installers with both code and
data.
2025-01-15 06:36:59 +01:00
2c45379403
Add speed-dreams-data as a submodule
There were several reasons behind splitting the old SVN monorepo in two
Git repositories:

- It made packaging for GNU/Linux distributions easier, since
speed-dreams-data would be often considered as a separate,
portable package, as typically done in other video games. For example,
0ad and 0ad-data, cube2 and cube2-data, and so on.

- It reduced the repository size for the engine repository as much as
possible, which is often desirable for CI/CD runs and developers with
poor connectivity and/or who only want to perform quick changes to the
source code. After all, speed-dreams-data is around 294 MiB as of the
time of this writing, whereas speed-dreams-code is around 36 MiB.

However, there are situations where having both repositories together is
desirable or even mandatory:

- In the case of Windows builds, both repositories must be configured by
the same top-level CMakeLists.txt so that files and targets from both
repositories are installed simultaneously, and therefore packaged into
the NSIS-based installers. Otherwise, it would require users to run two
separate installers, one for speed-dreams-code and another for
speed-dreams-data.

- Having a submodule makes which version from speed-dreams-data is
compatible with speed-dreams-code clearer.

- Not having a submodule required developers to both fetch the
speed-dreams-data repository and install it, which means double disk
space usage.

- Some users might still prefer to work on a monorepo and not have to
worry about installing speed-dreams-data beforehand.
2025-01-15 06:36:50 +01:00
Xavier Del Campo Romero
13b6fc1457 Merge pull request 'Continuous delivery for Debian stable and i686-w64-mingw32' (#11) from cd into main
Reviewed-on: #11
2025-01-13 16:22:41 +01:00
b4662b65b9
Introduce w64-mingw32 workflows
All checks were successful
/ build (pull_request) Successful in 18m20s
- build-3rdparty.yml cross-builds all third-party dependencies for
Windows. This workflow is meant to be run only sparingly, since
it fetches source code from many repositories and takes a long time to
build.

- build-w64-mingw32.yml cross-builds the game engine and tools for
Windows. It requires a pre-existing build of the third-party libraries.
2025-01-13 00:07:07 +01:00
44429fab1f
build-deb.yml: Upload Debian package 2025-01-13 00:07:07 +01:00
3bb02a188c
build-deb.yml: Build Debian package 2025-01-13 00:07:07 +01:00
fa12517208
build-deb.yml: Fetch whole history
Otherwise, git-describe(1) would fail and it would not be possible to
tag the artifacts accordingly.
2025-01-13 00:07:06 +01:00
bb6f43d124
build-deb.yml: Do not report git clone progress
Progress information is noisy and therefore does not provide any
benefits to the CI/CD logs.
2025-01-13 00:07:06 +01:00
f822312fdb
build-deb.yml: Add step names
These get reflected by the web browser interface, enhancing readability.
However, splitting into different steps requires to specify the working
directory.
2025-01-13 00:07:06 +01:00
3567f775d2
build-deb.yml: Change indentation from 4 to 2 spaces
Even if most of the project follows the 4-space convention, 2 spaces
seems more comfortable for YAML files, specially for workflows where
deeper levels of indentations are common.
2025-01-13 00:07:06 +01:00
e9bd5b2ff8
Rename build.yml to build-deb.yml
This workflow will be dedicated to Debian packaging only.
2025-01-13 00:07:06 +01:00
8af4015db8
Revamp Debian and NSIS packaging
The existing scripts for Debian and NSIS packaging were too complex and
dealt unnecessarily with lower level details that should be already
handled by CMake and CPack.

- Packaging-related scripts have been moved to the new cpack/ directory.
There, CPack variables common to all generators are defined in
cpack/common.cmake, and then generator-specific variables are defined
independently (e.g.: cpack/debian.cmake and cpack/nsis.cmake).

- Packaging is now optionally done at a second stage, by running
`cpack -G <generator>` on the build directory. This removes the
requirement to branch based on the system name, and instead all CPack
variables are assigned unconditionally.

- Since now only one version of the game is packaged, there is no need
to maintain the complex scripts in packaging/ and packaging/windows that
used to deal with all variants (e.g.: "wip-cars-and-tracks",
"hq-cars-and-tracks", etc.).

- The use of CPACK_NSIS_EXTRA_INSTALL_COMMANDS,
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS and CPACK_NSIS_CREATE_ICONS_EXTRA
should not be required, let alone modifying the HKLM registry manually,
since CPack already provides everything required to set up the
installer, the uninstaller and shortcuts.

- $INSTDIR is not required, since NSIS would already prepend the
target installation directory.

- PROJECT_VERSION_METADATA is not a standard CMake variable.
CMAKE_PROJECT_VERSION_TWEAK is instead meant for this purpose. [1]

- OPTION_PACKAGING and OPTION_ALL_IN_ONE_PACKAGING were removed since
packaging will always be available, yet optional. Packagers must then
run CPack on a second stage, as described above.

- Outdated comments were removed to avoid confusion.

TODO:

- Add shortcut to track editor on NSIS.

- dmg packaging was not revamped because of lacking compatible
hardware, but still it has been moved to cpack/dmg.cmake.

- Windows portable packaging (OPTION_PORTABLE_PACKAGING) has been left
out since it required 7z and relied on several hacks to work.
Furthermore, portable versions of the game were already not released on
the latest release, either. [2]

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_VERSION_TWEAK.html
[2]: https://sourceforge.net/projects/speed-dreams/files/2.3.0/
2025-01-13 00:07:01 +01:00
8ae4321be6
Introduce i686-w64-mingw32.cmake
This is the i686 counterpart to x86_64-w64-mingw32.cmake, which will be
used to generate 32-bit builds for Windows.
2025-01-12 22:46:40 +01:00
5e9613238c
CMakeLists.txt: Add HOMEPAGE_URL to project
This is later used by CPack for its CPACK_PACKAGE_HOMEPAGE_URL. [1]
This requires CMake >= 3.12, which was released circa 2018. [2]

[1]: https://cmake.org/cmake/help/latest/module/CPack.html#variable:CPACK_PACKAGE_HOMEPAGE_URL
[2]: https://cmake.org/files/v3.12/
2025-01-12 22:46:40 +01:00
76b83654e0
Set executable icon
On Windows, the executable icon is important since it is also inherited
by CPACK_NSIS_INSTALLED_ICON_NAME [1] and CPACK_PACKAGE_EXECUTABLES. [2]

[1]: https://cmake.org/cmake/help/latest/cpack_gen/nsis.html#variable:CPACK_NSIS_INSTALLED_ICON_NAME
[2]: https://cmake.org/cmake/help/latest/module/CPack.html#variable:CPACK_PACKAGE_EXECUTABLES
2025-01-12 22:46:34 +01:00
Xavier Del Campo Romero
1ead0ca79f Merge pull request 'Fix download manager on windows' (#14) from fix-win32-dm into main
Reviewed-on: #14
2025-01-10 08:33:19 +01:00
eab16bcdd9
win32/rmdir_r.cpp: Try with RemoveDirectory
All checks were successful
/ build (pull_request) Successful in 12m53s
SHFileOperation has been shown to fail when removing empty directories,
even if the documentation does not document such behaviour. [1]
Therefore, RemoveDirectoryA is used since it is meant for empty
directories. [2]

[1]: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shfileoperationa
[2]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya
2025-01-09 22:02:09 +01:00