MSVC Support (#1199)
* fix stdalign and min/max for MSVC * add missing ISREG and ISDIR for MSVC * use MAX_PATH instead of PATH_MAX * remove unecessary headers inclusion * add MSVC CI * add appropriate macros to platform detection * re-add msvc CI artifacts * upload the generated artifacts * patch lua for MSVC CI builds * update patch for MSVC compatibility
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
#include "api.h"
|
||||
#include <SDL.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ void deinit_dirmonitor(struct dirmonitor_internal* monitor) {
|
||||
|
||||
int translate_changes_dirmonitor(struct dirmonitor_internal* monitor, char* buffer, int buffer_size, int (*change_callback)(int, const char*, void*), void* data) {
|
||||
for (FILE_NOTIFY_INFORMATION* info = (FILE_NOTIFY_INFORMATION*)buffer; (char*)info < buffer + buffer_size; info = (FILE_NOTIFY_INFORMATION*)(((char*)info) + info->NextEntryOffset)) {
|
||||
char transform_buffer[PATH_MAX*4];
|
||||
int count = WideCharToMultiByte(CP_UTF8, 0, (WCHAR*)info->FileName, info->FileNameLength, transform_buffer, PATH_MAX*4 - 1, NULL, NULL);
|
||||
char transform_buffer[MAX_PATH*4];
|
||||
int count = WideCharToMultiByte(CP_UTF8, 0, (WCHAR*)info->FileName, info->FileNameLength, transform_buffer, MAX_PATH*4 - 1, NULL, NULL);
|
||||
change_callback(count, transform_buffer, data);
|
||||
if (!info->NextEntryOffset)
|
||||
break;
|
||||
|
||||
@@ -12,6 +12,20 @@
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
#include "../utfconv.h"
|
||||
|
||||
// Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do.
|
||||
// We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h
|
||||
// in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR,
|
||||
// rather than just defining _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does.
|
||||
#define _CRT_INTERNAL_NONSTDC_NAMES 1
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#else
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
+5
-4
@@ -90,13 +90,14 @@ void set_macos_bundle_resources(lua_State *L);
|
||||
#endif
|
||||
|
||||
#ifndef LITE_ARCH_TUPLE
|
||||
#if __x86_64__ || _WIN64 || __MINGW64__
|
||||
// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-140
|
||||
#if defined(__x86_64__) || defined(_M_AMD64) || defined(__MINGW64__)
|
||||
#define ARCH_PROCESSOR "x86_64"
|
||||
#elif __i386__
|
||||
#elif defined(__i386__) || defined(_M_IX86) || defined(__MINGW32__)
|
||||
#define ARCH_PROCESSOR "x86"
|
||||
#elif __aarch64__
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64) || defined (_M_ARM64EC)
|
||||
#define ARCH_PROCESSOR "aarch64"
|
||||
#elif __arm__
|
||||
#elif defined(__arm__) || defined(_M_ARM)
|
||||
#define ARCH_PROCESSOR "arm"
|
||||
#endif
|
||||
|
||||
|
||||
+22
-12
@@ -2,9 +2,19 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdalign.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef alignof
|
||||
#define alignof _Alignof
|
||||
#endif
|
||||
/* max_align_t is a compiler defined type, but
|
||||
** MSVC doesn't provide it, so we'll have to improvise */
|
||||
typedef long double max_align_t;
|
||||
#else
|
||||
#include <stdalign.h>
|
||||
#endif
|
||||
|
||||
#include <lauxlib.h>
|
||||
#include "rencache.h"
|
||||
|
||||
@@ -42,8 +52,8 @@ static int command_buf_idx;
|
||||
static RenRect screen_rect;
|
||||
static bool show_debug;
|
||||
|
||||
static inline int min(int a, int b) { return a < b ? a : b; }
|
||||
static inline int max(int a, int b) { return a > b ? a : b; }
|
||||
static inline int rencache_min(int a, int b) { return a < b ? a : b; }
|
||||
static inline int rencache_max(int a, int b) { return a > b ? a : b; }
|
||||
|
||||
|
||||
/* 32bit fnv-1a hash */
|
||||
@@ -69,19 +79,19 @@ static inline bool rects_overlap(RenRect a, RenRect b) {
|
||||
|
||||
|
||||
static RenRect intersect_rects(RenRect a, RenRect b) {
|
||||
int x1 = max(a.x, b.x);
|
||||
int y1 = max(a.y, b.y);
|
||||
int x2 = min(a.x + a.width, b.x + b.width);
|
||||
int y2 = min(a.y + a.height, b.y + b.height);
|
||||
return (RenRect) { x1, y1, max(0, x2 - x1), max(0, y2 - y1) };
|
||||
int x1 = rencache_max(a.x, b.x);
|
||||
int y1 = rencache_max(a.y, b.y);
|
||||
int x2 = rencache_min(a.x + a.width, b.x + b.width);
|
||||
int y2 = rencache_min(a.y + a.height, b.y + b.height);
|
||||
return (RenRect) { x1, y1, rencache_max(0, x2 - x1), rencache_max(0, y2 - y1) };
|
||||
}
|
||||
|
||||
|
||||
static RenRect merge_rects(RenRect a, RenRect b) {
|
||||
int x1 = min(a.x, b.x);
|
||||
int y1 = min(a.y, b.y);
|
||||
int x2 = max(a.x + a.width, b.x + b.width);
|
||||
int y2 = max(a.y + a.height, b.y + b.height);
|
||||
int x1 = rencache_min(a.x, b.x);
|
||||
int y1 = rencache_min(a.y, b.y);
|
||||
int x2 = rencache_max(a.x + a.width, b.x + b.width);
|
||||
int y2 = rencache_max(a.y + a.height, b.y + b.height);
|
||||
return (RenRect) { x1, y1, x2 - x1, y2 - y1 };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user