First compile, Logger works

This commit is contained in:
Madthijs
2021-04-11 14:07:16 +02:00
parent 2234190f24
commit e6df94dac0
8 changed files with 122 additions and 9 deletions

1
.gitignore vendored
View File

@@ -49,3 +49,4 @@ SDL2-2.0.12/Makefile.rules
SDL2-2.0.12/sdl2.pc
SDL2-2.0.12/sdl2-config
install_manifest.txt
AerofoilMac

66
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"files.associations": {
"iostream": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"map": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
}
}

View File

@@ -6,6 +6,10 @@
#include <time.h>
#include <unistd.h>
#ifdef __MACOS__
#include <sys/sysctl.h>
#endif
GpSystemServices_POSIX::GpSystemServices_POSIX()
{
}
@@ -44,7 +48,19 @@ IGpThreadEvent *GpSystemServices_POSIX::CreateThreadEvent(bool autoReset, bool s
uint64_t GpSystemServices_POSIX::GetFreeMemoryCosmetic() const
{
#ifdef __MACOS__
{ /* This works on *bsd and darwin. */
unsigned int usermem;
size_t len = sizeof usermem;
static int mib[2] = { CTL_HW, HW_USERMEM };
if (sysctl (mib, 2, &usermem, &len, NULL, 0) == 0
&& len == sizeof (usermem))
return (long) usermem;
}
#else
long pages = sysconf(_SC_AVPHYS_PAGES);
long pageSize = sysconf(_SC_PAGE_SIZE);
return pages * pageSize;
#endif
}

View File

@@ -9,8 +9,13 @@
#include "PLDrivers.h"
#ifdef __MACOS__
#include <SDL.h>
#include <SDL_rwops.h>
#else
#include "SDL2/SDL.h"
#include "SDL2/SDL_rwops.h"
#endif
#include <string>
#include <vector>
@@ -22,7 +27,7 @@
#include "UTF8.h"
#ifdef __CYGWIN__
#if defined(__CYGWIN__) || defined(__MACOS__)
typedef off_t off64_t;
#define fstat64 fstat
#define fseek64 fseek
@@ -183,6 +188,9 @@ bool GpFileSystem_X::ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDir
case PortabilityLayer::VirtualDirectories::kFontCache:
prefsAppend = "FontCache";
break;
case PortabilityLayer::VirtualDirectories::kLogs:
prefsAppend = "..";
break;
default:
return false;
};
@@ -289,6 +297,7 @@ GpIOStream *GpFileSystem_X::OpenFileNested(PortabilityLayer::VirtualDirectory_t
return nullptr;
std::string resolvedPath;
if (!ResolvePath(virtualDirectory, subPaths, numSubPaths, resolvedPath))
return nullptr;

View File

@@ -26,15 +26,17 @@ IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProp
IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties);
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties);
#ifdef __MACOS__
int main(int argc, char *argv[])
#else
SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[])
#endif
{
GpLogDriver_X::Init();
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0)
return -1;
GpFileSystem_X::GetInstance()->Init();
GpLogDriver_X::Init();
IGpLogDriver *logger = GpLogDriver_X::GetInstance();
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();

View File

@@ -2,7 +2,13 @@
#include "IGpClipboardContents.h"
#include "IGpThreadEvent.h"
#ifdef __MACOS__
#include <SDL.h>
#include <pthread.h>
#else
#include "SDL2/SDL.h"
#endif
#include <time.h>
#include <unistd.h>

View File

@@ -1,13 +1,23 @@
cmake_minimum_required(VERSION 3.10)
project (Aerofoil)
SET(PLATFORM "X" CACHE STRING "Defines the target platform")
SET(EXECNAME "AerofoilX" CACHE STRING "Defines the exec name")
message(${CMAKE_BINARY_DIR})
find_package(SDL2 REQUIRED)
if(PLATFORM STREQUAL "MAC")
SET(EXECNAME "AerofoilMac" CACHE STRING "Defines the exec name" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-D__MACOS__)
endif()
message("Building ${EXECNAME} for: ${PLATFORM}")
add_definitions(-DGP_DEBUG_CONFIG=0)
add_library(stb STATIC
stb/stb_image_write.c
)
@@ -231,7 +241,7 @@ target_include_directories(GpApp PRIVATE
target_link_libraries(GpApp PortabilityLayer)
if(CMAKE_HOST_UNIX)
add_executable(AerofoilX
add_executable(${EXECNAME}
AerofoilPortable/GpSystemServices_POSIX.cpp
AerofoilPortable/GpThreadEvent_Cpp11.cpp
AerofoilSDL/GpAudioDriver_SDL2.cpp
@@ -248,7 +258,7 @@ if(CMAKE_HOST_UNIX)
AerofoilX/GpFileSystem_X.cpp
)
target_include_directories(AerofoilX PRIVATE
target_include_directories(${EXECNAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpCommon>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpShell>
@@ -258,8 +268,8 @@ if(CMAKE_HOST_UNIX)
${SDL2_INCLUDE_DIRS}
)
target_link_libraries(AerofoilX ${SDL2_LIBRARIES} GpApp GpShell)
target_link_libraries(${EXECNAME} ${SDL2_LIBRARIES} GpApp GpShell)
endif()
install (TARGETS AerofoilX)
install (TARGETS ${EXECNAME})

View File

@@ -3,6 +3,9 @@
#define __PL_BINARY_SEARCH_H__
#include <stdint.h>
#ifdef __MACOS__
#include <stddef.h>
#endif
namespace PortabilityLayer
{