Browse Source

Windows build now compiles (but still has major problems)

pull/35/head
Xadhoom 7 years ago
parent
commit
1fede67d48
  1. 2
      CMake/FindSDL2.cmake
  2. 10
      CMake/mingwcc.cmake
  3. 1
      CMakeLists.txt
  4. 7
      README.md
  5. 5
      SourceS/miniwin.h
  6. 7
      SourceS/miniwin_com.h
  7. 2
      SourceS/miniwin_macro.h
  8. 6
      SourceS/miniwin_misc.h
  9. 2
      SourceX/dvlnet/udp_p2p.cpp
  10. 8
      SourceX/miniwin.cpp
  11. 4
      SourceX/miniwin_io.cpp
  12. 2
      SourceX/storm.cpp

2
CMake/FindSDL2.cmake

@ -214,6 +214,8 @@ if(SDL2_FOUND)
set(SDL2MAIN_LIBRARIES SDL2::SDL2main_real ${SDL2MAIN_LIBRARIES})
endif()
if(MINGW)
# Bugfix
set(SDL2MAIN_LIBRARIES -Wl,--whole-archive ${SDL2MAIN_LIBRARIES} -Wl,--no-whole-archive)
# MinGW requires some additional libraries to appear earlier in the link line.
if(SDL2PC_LIBRARIES)
# Use pkgconfig-suggested extra libraries if available.

10
CMake/mingwcc.cmake

@ -2,8 +2,14 @@ SET(CROSS_PREFIX "/usr" CACHE STRING "crosstool-NG prefix")
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER "${CROSS_PREFIX}/i686-w64-mingw32/bin/i686-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "${CROSS_PREFIX}/i686-w64-mingw32/bin/i686-w64-mingw32-g++")
# workaround
list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "${CROSS_PREFIX}/i686-w64-mingw32/include")
set(ASAN OFF)
set(DIST ON)
SET(CMAKE_C_COMPILER "i686-w64-mingw32-gcc")
SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-g++")
SET(CMAKE_FIND_ROOT_PATH "${CROSS_PREFIX}/i686-w64-mingw32" "${CROSS_PREFIX}/i686-w64-mingw32/i686-w64-mingw32")

1
CMakeLists.txt

@ -217,6 +217,7 @@ endif()
if(WIN32)
target_link_libraries(devilutionx PRIVATE wsock32 ws2_32 wininet)
target_compile_options(devilution PUBLIC $<$<CONFIG:Debug>:-gstabs>)
endif()
# Note: In Debug mode, GCC generates spurious memory references that upset Valgrind,

7
README.md

@ -63,11 +63,12 @@ Install the dependencies using [Homebrew](https://brew.sh/):
brew install cmake sdl2_mixer sdl2_ttf libsodium pkg-config
```
### Cross-compiling using MinGW (work in progress, does not yet compile)
Use the following cmake invocation:
### Cross-compiling using MinGW (work in progress, currently crashes)
You `PATH` must contain `i686-w64-mingw32-gcc` and `i686-w64-mingw32-gcc`. Use the following cmake invocation:
```
cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake -DCROSS_PREFIX=/path/to/crosstool-NG/prefix ..
cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake ..
```
Use `-DCROSS_PREFIX=/path/to/prefix` if the `i686-w64-mingw32` directory is not in `/usr`.
Now run the following commands:
```

5
SourceS/miniwin.h

@ -1,7 +1,6 @@
#pragma once
#include <ctype.h>
#include <fcntl.h>
#include <math.h>
// work around https://reviews.llvm.org/D51265
#ifdef __APPLE__
@ -13,11 +12,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
// For _rotr()
#ifdef DEVILUTION_ENGINE
#include <x86intrin.h>
#endif
// Constants
#define CONST const

7
SourceS/miniwin_com.h

@ -12,6 +12,13 @@ namespace dvl {
#pragma push_macro("THIS")
#pragma push_macro("PURE")
#pragma push_macro("REFIID")
#undef DECLARE_INTERFACE_
#undef STDMETHOD
#undef STDMETHOD_
#undef THIS_
#undef THIS
#undef PURE
#undef REFIID
#endif
//

2
SourceS/miniwin_macro.h

@ -236,3 +236,5 @@
#define OF_EXIST 1
#define MAKEINTRESOURCE DVL_MAKEINTRESOURCE
#define _finddata_t DVL_finddata_t

6
SourceS/miniwin_misc.h

@ -195,7 +195,7 @@ typedef struct tagWNDCLASSEXA {
typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
struct _finddata_t {
struct DVL_finddata_t {
unsigned attrib;
time_t time_create; /* -1 for FAT file systems */
time_t time_access; /* -1 for FAT file systems */
@ -298,8 +298,8 @@ HGDIOBJ GetStockObject(int i);
HCURSOR LoadCursorA(HINSTANCE hInstance, LPCSTR lpCursorName);
BOOL GetUserNameA(LPSTR lpBuffer, LPDWORD pcbBuffer);
void GetLocalTime(LPSYSTEMTIME lpSystemTime);
long __cdecl _findfirst(const char *, struct _finddata_t *);
int __cdecl _findnext(long, struct _finddata_t *);
long __cdecl _findfirst(const char *, struct DVL_finddata_t *);
int __cdecl _findnext(long, struct DVL_finddata_t *);
HICON LoadIconA(HINSTANCE hInstance, LPCSTR lpIconName);
HANDLE LoadImageA(HINSTANCE hInst, LPCSTR name, UINT type, int cx, int cy, UINT fuLoad);

2
SourceX/dvlnet/udp_p2p.cpp

@ -59,7 +59,7 @@ int udp_p2p::join(std::string addrstr, std::string passwd)
recv();
if (plr_self != PLR_BROADCAST)
break; // join successful
sleep(1);
SDL_Delay(1000);
}
}
return (plr_self == PLR_BROADCAST ? 4 : plr_self);

8
SourceX/miniwin.cpp

@ -3,6 +3,8 @@
#include <sys/statvfs.h>
#endif
#include <SDL.h>
namespace dvl {
DWORD last_error;
@ -69,7 +71,7 @@ DWORD GetTickCount()
void Sleep(DWORD dwMilliseconds)
{
usleep(dwMilliseconds * 1000);
SDL_Delay(dwMilliseconds);
}
HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
@ -419,13 +421,13 @@ void GetLocalTime(LPSYSTEMTIME lpSystemTime)
UNIMPLEMENTED();
}
long _findfirst(const char *, struct _finddata_t *)
long _findfirst(const char *, struct DVL_finddata_t *)
{
UNIMPLEMENTED();
return -1;
}
int _findnext(long, struct _finddata_t *)
int _findnext(long, struct DVL_finddata_t *)
{
UNIMPLEMENTED();
return -1;

4
SourceX/miniwin_io.cpp

@ -1,5 +1,9 @@
#include "pch.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
namespace dvl {
extern "C" void TranslateFileName(char *dst, int dstLen, const char *src)

2
SourceX/storm.cpp

@ -2,6 +2,8 @@
#include "../3rdParty/libsmacker/smacker.h"
#include "pch.h"
#include <unistd.h>
namespace dvl {
extern "C" DWORD nLastError = 0;

Loading…
Cancel
Save