ref: dda3108ef832909e13f17bee3fd25eab50784d09
parent: 89de47b4eb86e2defa44fc129be08122c7bb3aab
parent: 9398dca2dd4ac3234fba0004cbbafb9eee0c7e29
author: Tanguy Fautre <GPSnoopy@users.noreply.github.com>
date: Sun Feb 23 08:26:47 EST 2020
Added MacOS X build support with CI
--- /dev/null
+++ b/.github/workflows/macosx.yml
@@ -1,0 +1,15 @@
+name: MacOS X CI
+
+on: [push, pull_request]
+
+jobs:
+ build:
+
+ runs-on: macos-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Compile vcpkg dependencies
+ run: ./vcpkg_macosx.sh
+ - name: Compile Duke3D
+ run: ./build_macosx.sh
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,20 +51,18 @@
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(project_suffix ".64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
- set(project_suffix ".32")
+ set(project_suffix ".32")
endif()
find_package(ENet REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
-if (WIN32)
- # On Windows we can use vcpkg to build all the dependencies.
+if (VCPKG_TARGET_TRIPLET)
+ # On Windows and MacOS we can use vcpkg to build all the dependencies.
find_path(SDL2_INCLUDE_DIR SDL2/SDL.h NO_SYSTEM_ENVIRONMENT_PATH)
find_package(SDL2-mixer CONFIG REQUIRED)
set(SDL2_ALL_LIBRARIES SDL2::SDL2main SDL2::SDL2-static SDL2::SDL2_mixer)
-endif()
-
-if (UNIX)
+else()
# On Linux we have to rely on the package system (e.g. apt-get).
# Otherwise we are likely to be missing some SDL-mixer components (e.g. proper MIDI sound support).
find_path(SDL2_INCLUDE_DIR SDL2/SDL.h)
--- a/Engine/src/display.c
+++ b/Engine/src/display.c
@@ -671,9 +671,9 @@
}
}
-#ifdef __APPLE__
- SDL_putenv("SDL_VIDEODRIVER=Quartz");
-#endif
+//#ifdef __APPLE__
+// SDL_putenv("SDL_VIDEODRIVER=Quartz");
+//#endif
SDL_CHECK_SUCCESS( SDL_Init(SDL_INIT_VIDEO) );
--- a/Engine/src/macos_compat.h
+++ b/Engine/src/macos_compat.h
@@ -22,14 +22,11 @@
#include <inttypes.h>
#define O_BINARY 0
-
-#define UDP_NETWORKING 1
-
#define PLATFORM_MACOSX 1
+//
+//#define SOL_IP SOL_SOCKET
+//#define IP_RECVERR SO_BROADCAST
-#define SOL_IP SOL_SOCKET
-#define IP_RECVERR SO_BROADCAST
-
#define stricmp strcasecmp
#define strcmpi strcasecmp
@@ -40,7 +37,5 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
-
-#define USER_DUMMY_NETWORK 1
#endif
--- a/Engine/src/mmulti.c
+++ b/Engine/src/mmulti.c
@@ -576,16 +576,17 @@
# define sockettype SOCKET
# define socketclose(x) closesocket(x)
#else
-# include <sys/types.h>
-# include <sys/socket.h>
-# include <netinet/in.h>
# include <arpa/inet.h>
-# include <netdb.h>
-# include <sys/uio.h>
+# include <netinet/in.h>
+# include <netinet/ip.h>
# include <sys/ioctl.h>
+# include <sys/socket.h>
# include <sys/time.h>
+# include <sys/types.h>
+# include <sys/uio.h>
# include <errno.h>
# include <fcntl.h>
+# include <netdb.h>
# include <time.h>
# define netstrerror() strerror(errno)
# define neterrno() errno
@@ -959,7 +960,12 @@
printf("Stun is currently %s\n", (g_bStun) ? "Enabled":"Disabled");
udpsocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+
+#if WIN32
+ if (udpsocket == INVALID_SOCKET)
+#else
if (udpsocket == -1)
+#endif
{
printf("socket creation failed: %s\n", netstrerror());
return(0);
@@ -968,7 +974,7 @@
if (!set_socket_blockmode(0))
return(0);
- #if !WIN32
+ #if !WIN32 && !__APPLE__
{
/* !!! FIXME: Might be Linux (not Unix, not BSD, not WinSock) specific. */
int flags = 1;
--- a/Game/src/rts.c
+++ b/Game/src/rts.c
@@ -24,7 +24,10 @@
*/
//-------------------------------------------------------------------------
-#include <malloc.h>
+#if !__APPLE__
+ #include <malloc.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
--- a/README.md
+++ b/README.md
@@ -34,13 +34,13 @@
## Build
-**Windows (Visual Studio 2019 x86 solution)** [![Windows CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/Windows%20x86%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22Windows+x86+CI%22)
+**Windows (Visual Studio 2019 x86 solution)** [![Windows x86 CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/Windows%20x86%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22Windows+x86+CI%22)
```
> vcpkg_windows_x86.bat
> build_windows_x86.bat
```
-**Windows (Visual Studio 2019 x64 solution)** [![Windows CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/Windows%20x64%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22Windows+x64+CI%22)
+**Windows (Visual Studio 2019 x64 solution)** [![Windows x64 CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/Windows%20x64%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22Windows+x64+CI%22)
```
> vcpkg_windows_x64.bat
> build_windows_x64.bat
@@ -53,8 +53,11 @@
```
Here we do not use vcpkg but instead rely on the distro packages for ENet and SDL2. Unfortunately vcpkg SDL2 (and mixer) still depends on some development packages to be installed, and the MIDI subsystem is not correctly configured.
-**MacOS**
-_Not yet supported._
+**MacOS X (Clang Makefile)** [![MacOS X CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/MacOS%20X%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22MacOS+X+CI%22)
+```
+> ./vcpkg_macosx.sh
+> ./build_macosx.sh
+```
## Music (MIDI)
@@ -71,15 +74,16 @@
> SDL_SOUNDFONTS=WeedsGM3.sf2 SDL_FORCE_SOUNDFONTS=1 ./ChocoDuke3D.64
```
-**MacOs**
-_Not yet supported._
+**MacOS X**
+_Not yet tested._
+
## Contributors
* **Project Initiator:** [Fabien Sanglard](https://github.com/fabiensanglard)
* **Linux Integration:** [Juan Manuel Borges Caño](https://github.com/juanmabc)
* **64-bit Port:** [Rohit Nirmal](https://github.com/rohit-n)
-* **64-bit Port:** [Jonathon Fowler] (https://github.com/jonof/jfduke3d)
+* **64-bit Port:** [Jonathon Fowler](https://github.com/jonof/jfduke3d)
* **Belgian Chocolate fork:** [Tanguy Fautre](https://github.com/GPSnoopy/)
## More Information
--- /dev/null
+++ b/build_macosx.sh
@@ -1,0 +1,7 @@
+#!/bin/bash
+set -e
+
+mkdir -p build/linux
+cd build/linux
+cmake -D VCPKG_TARGET_TRIPLET=x64-osx -D CMAKE_TOOLCHAIN_FILE=../vcpkg.macosx/scripts/buildsystems/vcpkg.cmake -D CMAKE_BUILD_TYPE=Release ../..
+make -j
--- /dev/null
+++ b/vcpkg_macosx.sh
@@ -1,0 +1,14 @@
+#!/bin/bash
+set -e
+
+mkdir -p build
+cd build
+git clone https://github.com/Microsoft/vcpkg.git vcpkg.macosx
+cd vcpkg.macosx
+git checkout 2020.01
+./bootstrap-vcpkg.sh
+
+./vcpkg install \
+ enet:x64-osx \
+ sdl2:x64-osx \
+ sdl2-mixer:x64-osx
\ No newline at end of file