Skip to content

Commit

Permalink
build: minor adjustments
Browse files Browse the repository at this point in the history
VS2019: get more of the targets to build (needed to specify modern C
standard for all of them, and SDK "10.0" seems to mean "use latest
version installed").
VS2019: improve README.md instructions.

Makefile: fix PEDANTIC=1 test builds and warning spam.

sys: properly fix warnings related to SDL's wrapping of main() for all
platforms.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
  • Loading branch information
bones-was-here committed Apr 14, 2024
1 parent 58dc787 commit 71e366e
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 23 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ These instructions are adequate for Quake, but for Xonotic please refer to [its
### Required packages

The minimum SDL version is 2.0.18 for Linux and 2.24.0 for Windows.
The supported compilers are GCC and Clang.
The following package names are for Debian, see below for Windows and Mac.

##### Client
Expand Down Expand Up @@ -96,19 +97,16 @@ If you get errors (that don't seem to be about missing dependencies) try `make c

Not recommended due to poor support for C standards, and lack of maintenance.

DarkPlaces requires C11, so Windows SDK 10.0.22000.0 (VS 2019) or 10.0.20348.0 (VS 2022) or later is needed.
To install it, run the Visual Studio Installer, click "Modify", click "Individual components", select the latest Windows SDK version and de-select older versions.
You will also need the NuGet Package Manager selected (to download SDL2 headers the first time you build).
DarkPlaces requires C11, so Windows SDK 10.0.20348.0 or later is needed.
To install it, run the Visual Studio Installer, click "Modify", click "Individual components", type "Windows SDK" in the search box, select the latest Windows SDK and de-select older versions.
You will also need "NuGet package manager" selected (to download SDL2 headers the first time you build).
Click "Modify" to apply the changes.

VS 2019
![MSVC2019](msvc2019_C11.png)
Open `darkplaces-vs2019.sln`, select build type (`Debug` or `Release`) and platform (`Win32` or `x64`), and choose "Build Solution" from the "Build" menu to create files `darkplaces-sdl2-vs2019.exe` and `SDL2.dll`.

Open `darkplaces-vs2019.sln`, select build type "Debug" or "Release, and choose "Build Solution" from the "Build" menu to create the file `darkplaces-sdl2-vs2019.exe`.
The Release build crashes. The Debug x64 build doesn't crash (but is rather slow) so this will be Fun for someone to debug.

The Release build crashes. The Debug build doesn't crash (but is rather slow) so this will be Fun for someone to debug.

To get a build suitable for playing Quake you'll need to use MinGW gcc, or download the autobuild from Xonotic (see above).
To get a build suitable for playing you'll need to use MinGW GCC, or download the autobuild from Xonotic (see above).


## Contributing
Expand Down
14 changes: 9 additions & 5 deletions darkplaces-sdl2-vs2019.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@
<RootNamespace>darkplacessdl2</RootNamespace>
<Keyword>Win32Proj</Keyword>
<ProjectName>darkplaces-sdl2-vs2019</ProjectName>
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -88,6 +88,8 @@
<DisableSpecificWarnings>4706;4127;4100;4055;4054;4244;4305;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions>/wd"4201" %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
Expand Down Expand Up @@ -139,6 +141,8 @@
<DisableSpecificWarnings>4706;4127;4100;4055;4054;4244;4305;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalOptions>/wd"4201" %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
Expand Down
Binary file removed docs/msvc2019_C11.png
Binary file not shown.
4 changes: 3 additions & 1 deletion makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_MENU) $(OBJ_SND_COMM


# Compilation
# -D_POSIX_C_SOURCE=200809L doesn't enable all of POSIX 2008, wtf?
# -D_DEFAULT_SOURCE does enables all of POSIX 2008 (without GNU extensions).
ifeq ($(PEDANTIC),1)
CFLAGS_STANDARD=-std=c11 -pedantic -D_POSIX_C_SOURCE=200809L -DCONFIG_PEDANTIC
CFLAGS_STANDARD=-std=c17 -pedantic -D_DEFAULT_SOURCE -DCONFIG_PEDANTIC
else
CFLAGS_STANDARD=
endif
Expand Down
3 changes: 1 addition & 2 deletions protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "qstats.h"
struct mempool_s;
struct sizebuf_s;
// protocolversion_t is defined in common.h
enum protocolversion_e;

// protocolversion_t is defined in common.h
enum protocolversion_e Protocol_EnumForName(const char *s);
const char *Protocol_NameForEnum(enum protocolversion_e p);
enum protocolversion_e Protocol_EnumForNumber(int n);
Expand Down
2 changes: 2 additions & 0 deletions sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,7 @@ void Sys_InitProcessNice (void);
void Sys_MakeProcessNice (void);
void Sys_MakeProcessMean (void);

int Sys_Main(int argc, char *argv[]);

#endif

5 changes: 5 additions & 0 deletions sys_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ void Sys_SDL_Delay (unsigned int milliseconds)
{
Sys_Error("Called Sys_SDL_Delay on non-SDL target");
}

int main(int argc, char *argv[])
{
return Sys_Main(argc, argv);
}
5 changes: 5 additions & 0 deletions sys_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ void Sys_SDL_Delay (unsigned int milliseconds)
{
SDL_Delay(milliseconds);
}

int main(int argc, char *argv[])
{
return Sys_Main(argc, argv);
}
11 changes: 5 additions & 6 deletions sys_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
#include "taskqueue.h"
#include "thread.h"
#include "libcurl.h"
#if defined(_MSC_VER)
// Not sure why MS compiler needs this here and gcc doesn't...
// and gcc fails to build darkplaces-dedicated if it's included here.
#include "SDL.h"
#endif


sys_t sys;
Expand Down Expand Up @@ -1092,7 +1087,11 @@ static void Sys_InitSignals(void)
#endif
}

int main (int argc, char **argv)
/** main() but renamed so we can wrap it in sys_sdl.c and sys_null.c
* to avoid needing to include SDL.h in this file (would make the dedicated server require SDL).
* SDL builds need SDL.h in the file where main() is defined because SDL renames and wraps main().
*/
int Sys_Main(int argc, char *argv[])
{
sys.argc = argc;
sys.argv = (const char **)argv;
Expand Down

0 comments on commit 71e366e

Please sign in to comment.