Permalink
Browse files

Add support for MinGW

  • Loading branch information...
vvs- committed Nov 17, 2018
1 parent 1ddd4e8 commit bc4303cc188003f891d0d5360430ffe7861725a3
Showing with 68 additions and 7 deletions.
  1. +2 −0 external/glaserl/glaserl_gl.h
  2. +4 −0 external/thp/thp_format.cpp
  3. +2 −0 makefile
  4. +2 −2 mk/pkgs.mk
  5. +1 −0 mk/vars.mk
  6. +3 −1 platform/gl/gl.mk
  7. +29 −0 platform/mingw/platform.in
  8. +5 −0 src/Event.h
  9. +2 −2 src/Levels.cpp
  10. +18 −2 src/Os.cpp
@@ -23,6 +23,8 @@
# define GLASERL_GLSL_PRECISION_INFO "precision mediump float;\n"
#elif defined(__APPLE__)
# include <OpenGL/gl.h>
#elif defined(__WIN32__)
# include "gl.h"
#else
# define GL_GLEXT_PROTOTYPES
# include <GL/gl.h>
@@ -13,6 +13,10 @@
* General Public License for more details.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "thp_format.h"
#include <string>
@@ -29,6 +29,8 @@ TARGET ?= $(APP)
app: $(TARGET)
$(OBJECTS): $(GENERATED_HEADERS)
$(TARGET): $(OBJECTS) $(LOCAL_LIBS)
$(SILENTMSG) "\tLD\t$@\n"
$(SILENTCMD) $(CXX) -o $@ $^ $(LIBS)
@@ -1,4 +1,4 @@
ifneq ($(PKGS),)
CXXFLAGS += $(shell pkg-config --cflags $(PKGS))
LIBS += $(shell pkg-config --libs $(PKGS))
CXXFLAGS += $(shell $(CROSS_COMPILE)pkg-config --cflags $(PKGS))
LIBS += $(shell $(CROSS_COMPILE)pkg-config --libs $(PKGS))
endif
@@ -1,5 +1,6 @@
PKGS :=
GENERATED_MAKEFILES :=
GENERATED_HEADERS :=
ADDITIONAL_CLEAN_TARGETS :=
ADDITIONAL_DISTCLEAN_TARGETS :=
ADDITIONAL_INSTALL_TARGETS :=
@@ -1,12 +1,14 @@
# OpenGL library
ifeq ($(shell uname),Darwin)
LIBS += -framework OpenGL
else
else ifneq ($(PLATFORM),mingw)
ifneq ($(wildcard $(patsubst %,%/libGL.so.1,/usr/lib /usr/lib64 /usr/lib/* /usr/lib/*/mesa)),)
$(eval $(call add_pkgconfig,gl))
else
$(eval $(call add_pkgconfig,glesv2))
CFLAGS += -DUSE_OPENGL_ES
CXXFLAGS += -DUSE_OPENGL_ES
endif
else
LIBS += -lopengl32
endif
@@ -0,0 +1,29 @@
# Platform build definition for SDL2
# Will be processed by makefile
APP := $(APP).exe
GENERATED_HEADERS += external/glaserl/gl.h
DISTCLEAN_FILES += external/glaserl/gl.[ch]
external/glaserl/gl.h:
galogen gl.xml --ver 3.0 --profile compatibility
mv gl.[ch] external/glaserl
add_platform(freedesktop)
add_platform(gl)
add_pkgconfig(sdl2)
add_pkgconfig(SDL2_image)
add_pkgconfig(gio-2.0)
SOURCES += $(wildcard platform/sdl2/*.cpp)
CXXFLAGS += -Iplatform/sdl2
ifeq ($(wildcard $(patsubst %,%/SDL2_ttf.dll,platform/$(PLATFORM)/SDL2_ttf/.libs)),)
add_pkgconfig(SDL2_ttf)
else
CXXFLAGS += -Iplatform/$(PLATFORM)/SDL2_ttf
LIBS += -Lplatform/$(PLATFORM)/SDL2_ttf/.libs -lSDL2_ttf.dll
endif
include platform/gl/gl.mk
include platform/freedesktop/install.mk
@@ -19,6 +19,9 @@
#include "Common.h"
#pragma push_macro("DELETE")
#undef DELETE
struct ToolkitEvent {
public:
enum Type {
@@ -167,4 +170,6 @@ enum NumptyKeySym {
NUMPTYKEY_F6,
};
#pragma pop_macro("DELETE")
#endif //EVENT_H
@@ -247,7 +247,7 @@ Collection &Levels::getCollection(const std::string &file)
bool Levels::scanCollection(const std::string &file)
{
std::string collectionName = file.substr(file.find_last_of('/')+1);
std::string collectionName = file.substr(file.find_last_of(Os::pathSep)+1);
DIR *dir = opendir(file.c_str());
if (dir) {
bool result = false;
@@ -256,7 +256,7 @@ bool Levels::scanCollection(const std::string &file)
continue;
}
std::string filename = file + "/" + entry->d_name;
std::string filename = file + Os::pathSep + entry->d_name;
std::string ext = fileExtension(filename);
if (ext == ".nph" || ext == ".npsvg") {
if (addLevel(getCollection(collectionName), filename)) {
@@ -23,6 +23,10 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
#ifdef __WIN32__
#include <windows.h>
#undef DELETE
#endif
#include "thp_format.h"
#include "petals_log.h"
@@ -169,7 +173,11 @@ bool Os::ensurePath(const std::string& path)
if ( sep != std::string::npos && sep > 0 ) {
ensurePath(path.substr(0,sep));
}
#ifdef __WIN32__
if (mkdir(path.c_str()) != 0 ) {
#else
if (mkdir(path.c_str(), 0755) != 0) {
#endif
LOG_WARNING("Failed to create dir: %s", path.c_str());
return false;
} else {
@@ -191,7 +199,11 @@ static Os *
g_os = nullptr;
const char
#ifdef __WIN32__
Os::pathSep = '\\';
#else
Os::pathSep = '/';
#endif
Os::Os()
{
@@ -228,12 +240,16 @@ Os::init(int argc, char **argv)
char buf[PATH_MAX];
const char *progname = argv[0];
const char *slash = strrchr(progname, '/');
const char *slash = strrchr(progname, Os::pathSep);
if (!slash) {
#ifdef __WIN32__
if (GetModuleFileName(NULL, buf, sizeof(buf)) != -1) {
#else
if (readlink("/proc/self/exe", buf, sizeof(buf)) != -1) {
#endif
progname = buf;
slash = strrchr(progname, '/');
slash = strrchr(progname, Os::pathSep);
}
}

0 comments on commit bc4303c

Please sign in to comment.