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
|
||||
*.o
|
||||
main
|
||||
*.pack
|
||||
*.pack
|
||||
tool/pack_file
|
||||
*.zip
|
||||
*.tar
|
||||
15
Makefile
15
Makefile
@ -5,7 +5,9 @@ AS=$(PREFIX)as
|
||||
|
||||
OBJARCH = elf64-x86-64
|
||||
|
||||
OPT = -O0 -march=x86-64-v3
|
||||
UNAME := $(shell uname -s)
|
||||
|
||||
OPT += -O0 -march=x86-64-v3
|
||||
|
||||
DEBUG = -g
|
||||
|
||||
@ -25,9 +27,13 @@ CFLAGS += -fpic
|
||||
FLAGS += -fstack-protector -fstack-protector-all -fno-omit-frame-pointer -fsanitize=address
|
||||
|
||||
LDFLAGS += -lm
|
||||
ifeq ($(shell uname),Linux)
|
||||
ifeq ($(UNAME),Linux)
|
||||
LDFLAGS += -Wl,-z noexecstack
|
||||
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 = \
|
||||
src/main.o \
|
||||
@ -35,8 +41,13 @@ OBJS = \
|
||||
src/file.o \
|
||||
src/pack.o
|
||||
|
||||
ifeq ($(UNAME),Darwin)
|
||||
LIBS = \
|
||||
../SDL3-dist/lib/libSDL3.a
|
||||
else
|
||||
LIBS = \
|
||||
../SDL3-dist/lib64/libSDL3.a
|
||||
endif
|
||||
|
||||
all: main
|
||||
|
||||
|
||||
14
src/file.cpp
14
src/file.cpp
@ -8,8 +8,17 @@
|
||||
#include "file.h"
|
||||
|
||||
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_end[];
|
||||
#define files_pack_start _files_pack_start
|
||||
#define files_pack_end _files_pack_end
|
||||
#endif
|
||||
};
|
||||
|
||||
namespace file {
|
||||
@ -18,12 +27,12 @@ namespace file {
|
||||
{
|
||||
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) {
|
||||
fprintf(stderr, "invalid header magic: %08x expected magic value: %08x\n", header->magic, pack::magic_value);
|
||||
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++) {
|
||||
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);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user