incomplete support for macOS builds
This commit is contained in:
parent
70fea48b38
commit
0502906e28
5
.gitignore
vendored
5
.gitignore
vendored
@ -2,4 +2,7 @@
|
|||||||
*.spv
|
*.spv
|
||||||
*.o
|
*.o
|
||||||
main
|
main
|
||||||
*.pack
|
*.pack
|
||||||
|
tool/pack_file
|
||||||
|
*.zip
|
||||||
|
*.tar
|
||||||
15
Makefile
15
Makefile
@ -5,7 +5,9 @@ AS=$(PREFIX)as
|
|||||||
|
|
||||||
OBJARCH = elf64-x86-64
|
OBJARCH = elf64-x86-64
|
||||||
|
|
||||||
OPT = -O0 -march=x86-64-v3
|
UNAME := $(shell uname -s)
|
||||||
|
|
||||||
|
OPT += -O0 -march=x86-64-v3
|
||||||
|
|
||||||
DEBUG = -g
|
DEBUG = -g
|
||||||
|
|
||||||
@ -25,9 +27,13 @@ CFLAGS += -fpic
|
|||||||
FLAGS += -fstack-protector -fstack-protector-all -fno-omit-frame-pointer -fsanitize=address
|
FLAGS += -fstack-protector -fstack-protector-all -fno-omit-frame-pointer -fsanitize=address
|
||||||
|
|
||||||
LDFLAGS += -lm
|
LDFLAGS += -lm
|
||||||
ifeq ($(shell uname),Linux)
|
ifeq ($(UNAME),Linux)
|
||||||
LDFLAGS += -Wl,-z noexecstack
|
LDFLAGS += -Wl,-z noexecstack
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(UNAME),Darwin)
|
||||||
|
LDFLAGS += -framework Foundation -framework Cocoa -framework IOKit -framework AVFoundation -framework CoreVideo -framework CoreAudio -framework CoreMedia -framework CoreHaptics -framework AudioToolbox -framework GameController -framework ForceFeedback -framework Carbon -framework Metal -framework QuartzCore -framework UniformTypeIdentifiers
|
||||||
|
LDFLAGS += -lstdc++
|
||||||
|
endif
|
||||||
|
|
||||||
OBJS = \
|
OBJS = \
|
||||||
src/main.o \
|
src/main.o \
|
||||||
@ -35,8 +41,13 @@ OBJS = \
|
|||||||
src/file.o \
|
src/file.o \
|
||||||
src/pack.o
|
src/pack.o
|
||||||
|
|
||||||
|
ifeq ($(UNAME),Darwin)
|
||||||
|
LIBS = \
|
||||||
|
../SDL3-dist/lib/libSDL3.a
|
||||||
|
else
|
||||||
LIBS = \
|
LIBS = \
|
||||||
../SDL3-dist/lib64/libSDL3.a
|
../SDL3-dist/lib64/libSDL3.a
|
||||||
|
endif
|
||||||
|
|
||||||
all: main
|
all: main
|
||||||
|
|
||||||
|
|||||||
14
src/file.cpp
14
src/file.cpp
@ -8,8 +8,17 @@
|
|||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
extern uint8_t const files_pack_start[];
|
||||||
|
extern uint8_t const files_pack_end[];
|
||||||
|
#define files_pack_start files_pack_start
|
||||||
|
#define files_pack_end files_pack_end
|
||||||
|
#else
|
||||||
extern uint8_t const _files_pack_start[];
|
extern uint8_t const _files_pack_start[];
|
||||||
extern uint8_t const _files_pack_end[];
|
extern uint8_t const _files_pack_end[];
|
||||||
|
#define files_pack_start _files_pack_start
|
||||||
|
#define files_pack_end _files_pack_end
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace file {
|
namespace file {
|
||||||
@ -18,12 +27,12 @@ namespace file {
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "(pack) filename: %s\n", r_filename);
|
fprintf(stderr, "(pack) filename: %s\n", r_filename);
|
||||||
|
|
||||||
pack::header const * header = (pack::header const *)&_files_pack_start[0];
|
pack::header const * header = (pack::header const *)&files_pack_start[0];
|
||||||
if (header->magic != pack::magic_value) {
|
if (header->magic != pack::magic_value) {
|
||||||
fprintf(stderr, "invalid header magic: %08x expected magic value: %08x\n", header->magic, pack::magic_value);
|
fprintf(stderr, "invalid header magic: %08x expected magic value: %08x\n", header->magic, pack::magic_value);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
ptrdiff_t data = (ptrdiff_t)&_files_pack_start[header->header_size];
|
ptrdiff_t data = (ptrdiff_t)&files_pack_start[header->header_size];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < header->entry_count; i++) {
|
for (unsigned int i = 0; i < header->entry_count; i++) {
|
||||||
if (strcmp(header->entry[i].filename, r_filename) == 0) {
|
if (strcmp(header->entry[i].filename, r_filename) == 0) {
|
||||||
@ -35,5 +44,4 @@ namespace file {
|
|||||||
fprintf(stderr, "filename not found in pack file %s\n", r_filename);
|
fprintf(stderr, "filename not found in pack file %s\n", r_filename);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user