Support fat macos binaries; rudimentary support for ios
This commit is contained in:
parent
8265eb658f
commit
21464c44fb
42
Makefile
42
Makefile
|
@ -61,48 +61,53 @@ else
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
PTYPE != uname -m
|
|
||||||
|
|
||||||
CFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) -MD $(WARNING_FLAGS) -I. -DVER=\"$(VER)\" -DINFO=\"$(INFO)\"
|
CFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) -MD $(WARNING_FLAGS) -I. -DVER=\"$(VER)\" -DINFO=\"$(INFO)\"
|
||||||
|
|
||||||
PKGCMD = tar --directory $(BIN) --exclude="./*.a" --exclude="./obj" -czf $(DISTDIR)/$(DIST) .
|
PKGCMD = tar --directory $(BIN) --exclude="./*.a" --exclude="./obj" -czf $(DISTDIR)/$(DIST) .
|
||||||
ZIP = .tar.gz
|
ZIP = .tar.gz
|
||||||
UNZIP = cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST)
|
UNZIP = cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST)
|
||||||
|
|
||||||
ARCH = x64
|
ifeq ($(ARCH),)
|
||||||
|
ARCH != uname -m
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(OS), Windows_NT)
|
ifeq ($(OS), Windows_NT)
|
||||||
LDFLAGS += -mwin32 -static -g
|
LDFLAGS += -mwin32 -static -g
|
||||||
CFLAGS += -mwin32 -g
|
CFLAGS += -mwin32 -g
|
||||||
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
|
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
|
||||||
EXT = .exe
|
EXT = .exe
|
||||||
PLAT = w64
|
ARCH := x86_64
|
||||||
PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
|
||||||
ZIP = .zip
|
ZIP = .zip
|
||||||
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR)
|
||||||
|
else ifeq ($(OS), ios)
|
||||||
|
TTARGET = arm64-apple-ios13.1
|
||||||
|
SYSRT := /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
|
||||||
|
CFLAGS += --target=$(TTARGET) -isysroot $(SYSRT) -DTARGET_OS_IPHONE -x objective-c
|
||||||
|
LDFLAGS += --target=$(TTARGET) -isysroot $(SYSRT) -framework Foundation -framework UIKit -framework Metal -framework MetalKit -framework AudioToolbox -framework AVFoundation
|
||||||
else ifeq ($(CC), emcc)
|
else ifeq ($(CC), emcc)
|
||||||
|
OS := Web
|
||||||
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -pthread -sTOTAL_MEMORY=450MB
|
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -pthread -sTOTAL_MEMORY=450MB
|
||||||
CFLAGS += -pthread
|
CFLAGS += -pthread
|
||||||
LDLIBS += pthread quickjs GL openal c m dl
|
LDLIBS += pthread quickjs GL openal c m dl
|
||||||
CC = emcc
|
CC = emcc
|
||||||
EXT = .html
|
EXT = .html
|
||||||
PLAT = html5
|
|
||||||
else
|
else
|
||||||
UNAME != uname -s
|
UNAME != uname -s
|
||||||
ifeq ($(UNAME), Linux)
|
ifeq ($(UNAME), Linux)
|
||||||
|
OS := Linux
|
||||||
LDFLAGS += -pthread -rdynamic
|
LDFLAGS += -pthread -rdynamic
|
||||||
LDLIBS += GL pthread c m dl X11 Xi Xcursor EGL asound
|
LDLIBS += GL pthread c m dl X11 Xi Xcursor EGL asound
|
||||||
PLAT = linux-$(ARCH)$(INFO)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME), Darwin)
|
ifeq ($(UNAME), Darwin)
|
||||||
CFLAGS += -x objective-c
|
OS := macos
|
||||||
LDFLAGS += -framework Cocoa -framework QuartzCore -framework AudioToolbox -framework Metal -framework MetalKit
|
CFLAGS += -arch $(ARCH) -x objective-c
|
||||||
PLAT = osx-$(ARCH)$(INFO)
|
LDFLAGS += -arch $(ARCH) -framework Cocoa -framework QuartzCore -framework AudioToolbox -framework Metal -framework MetalKit
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BIN = bin/$(CC)/$(INFO)
|
BIN = bin/$(OS)/$(ARCH)$(INFO)
|
||||||
|
|
||||||
OBJDIR = $(BIN)/obj
|
OBJDIR = $(BIN)/obj
|
||||||
|
|
||||||
|
@ -113,7 +118,7 @@ OBJS := $(addprefix $(BIN)/obj/, $(OBJS))
|
||||||
|
|
||||||
engineincs != find source/engine -maxdepth 1 -type d
|
engineincs != find source/engine -maxdepth 1 -type d
|
||||||
includeflag != find source -type d -name include
|
includeflag != find source -type d -name include
|
||||||
includeflag += $(engineincs) source/engine/thirdparty/Nuklear source/engine/thirdparty/tinycdb source/shaders
|
includeflag += $(engineincs) source/engine/thirdparty/tinycdb source/shaders
|
||||||
includeflag := $(addprefix -I, $(includeflag))
|
includeflag := $(addprefix -I, $(includeflag))
|
||||||
|
|
||||||
WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function -Wno-unused-const-variable
|
WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function -Wno-unused-const-variable
|
||||||
|
@ -128,9 +133,7 @@ LDLIBS := $(addprefix -l, $(LDLIBS))
|
||||||
DEPENDS = $(OBJS:.o=.d)
|
DEPENDS = $(OBJS:.o=.d)
|
||||||
-include $(DEPENDS)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
DIST = yugine-$(OS)$(ARCH)$(INFO)-$(COM)$(ZIP)
|
||||||
|
|
||||||
DIST = yugine-$(PLAT)-$(COM)$(ZIP)
|
|
||||||
DISTDIR = ./dist
|
DISTDIR = ./dist
|
||||||
|
|
||||||
.DEFAULT_GOAL := all
|
.DEFAULT_GOAL := all
|
||||||
|
@ -195,7 +198,7 @@ input.md: $(INPUTMD)
|
||||||
|
|
||||||
$(BIN)/libquickjs.a:
|
$(BIN)/libquickjs.a:
|
||||||
make -C quickjs clean
|
make -C quickjs clean
|
||||||
make -C quickjs DBG=$(DBG) OPT=$(OPT) HOST_CC=$(CC) AR=$(AR) libquickjs.a libquickjs.lto.a CC=$(CC)
|
make -C quickjs SYSRT=$(SYSRT) TTARGET=$(TTARGET) ARCH=$(ARCH) DBG=$(DBG) OPT=$(OPT) HOST_CC=$(CC) AR=$(AR) libquickjs.a libquickjs.lto.a CC=$(CC)
|
||||||
@mkdir -p $(BIN)
|
@mkdir -p $(BIN)
|
||||||
cp -rf quickjs/libquickjs.* $(BIN)
|
cp -rf quickjs/libquickjs.* $(BIN)
|
||||||
|
|
||||||
|
@ -209,7 +212,7 @@ shaders: $(SHADERS)
|
||||||
|
|
||||||
%.sglsl.h:%.sglsl
|
%.sglsl.h:%.sglsl
|
||||||
@echo Creating shader $^
|
@echo Creating shader $^
|
||||||
@./sokol-shdc --ifdef -i $^ --slang=glsl330:hlsl5:metal_macos:glsl300es -o $@
|
@./sokol-shdc --ifdef -i $^ --slang=glsl330:hlsl5:metal_macos:metal_ios:metal_sim:glsl300es -o $@
|
||||||
|
|
||||||
cdb: tools/cdb.c tools/libcdb.a
|
cdb: tools/cdb.c tools/libcdb.a
|
||||||
cc $^ -I$(CDB) -o cdb
|
cc $^ -I$(CDB) -o cdb
|
||||||
|
@ -249,6 +252,13 @@ WINCC = x86_64-w64-mingw32-gcc
|
||||||
crosswin:
|
crosswin:
|
||||||
make CC=$(WINCC) OS=Windows_NT
|
make CC=$(WINCC) OS=Windows_NT
|
||||||
|
|
||||||
|
crossmac:
|
||||||
|
make ARCH=arm64
|
||||||
|
mv primum primum_arm64
|
||||||
|
make ARCH=x86_64
|
||||||
|
mv primum primum_x86_64
|
||||||
|
lipo primum_arm64 primum_x86_64 -create -output primum
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo Cleaning project
|
@echo Cleaning project
|
||||||
@rm -rf bin dist
|
@rm -rf bin dist
|
||||||
|
|
|
@ -76,6 +76,11 @@ ifdef CONFIG_CLANG
|
||||||
CFLAGS += -Wwrite-strings
|
CFLAGS += -Wwrite-strings
|
||||||
CFLAGS += -Wchar-subscripts -funsigned-char
|
CFLAGS += -Wchar-subscripts -funsigned-char
|
||||||
CFLAGS += -MMD -MF $(OBJDIR)/$(@F).d
|
CFLAGS += -MMD -MF $(OBJDIR)/$(@F).d
|
||||||
|
CFLAGS += -arch $(ARCH)
|
||||||
|
ifneq ($(TTARGET),)
|
||||||
|
CFLAGS += --target=$(TTARGET)
|
||||||
|
CFLAGS += -isysroot $(SYSRT)
|
||||||
|
endif
|
||||||
ifdef CONFIG_DEFAULT_AR
|
ifdef CONFIG_DEFAULT_AR
|
||||||
AR=$(CROSS_PREFIX)ar
|
AR=$(CROSS_PREFIX)ar
|
||||||
else
|
else
|
||||||
|
|
|
@ -1102,7 +1102,7 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
||||||
|
|
||||||
case 143:
|
case 143:
|
||||||
str = JS_ToCString(js, argv[1]);
|
str = JS_ToCString(js, argv[1]);
|
||||||
system(str);
|
// system(str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 144:
|
case 144:
|
||||||
|
|
38
source/engine/thirdparty/sokol/sokol_gfx_ext.h
vendored
38
source/engine/thirdparty/sokol/sokol_gfx_ext.h
vendored
|
@ -17,17 +17,9 @@ https://github.com/edubart/sokol_gp
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SOKOL_GFX_API_DECL void sg_query_image_pixels(sg_image img_id, sg_sampler smp_id, void* pixels, int size);
|
SOKOL_GFX_API_DECL void sg_query_image_pixels(sg_image img_id, sg_sampler smp_id, void* pixels, int size);
|
||||||
SOKOL_GFX_API_DECL void sg_query_pixels(int x, int y, int w, int h, bool origin_top_left, void *pixels, int size);
|
SOKOL_GFX_API_DECL void sg_query_pixels(int x, int y, int w, int h, bool origin_top_left, void *pixels, int size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} // extern "C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // SOKOL_GFX_EXT_INCLUDED
|
#endif // SOKOL_GFX_EXT_INCLUDED
|
||||||
|
|
||||||
#ifdef SOKOL_GFX_EXT_IMPL
|
#ifdef SOKOL_GFX_EXT_IMPL
|
||||||
|
@ -88,43 +80,23 @@ static void _sg_gl_query_pixels(int x, int y, int w, int h, bool origin_top_left
|
||||||
#elif defined(SOKOL_D3D11)
|
#elif defined(SOKOL_D3D11)
|
||||||
|
|
||||||
static inline void _sgext_d3d11_Texture2D_GetDesc(ID3D11Texture2D* self, D3D11_TEXTURE2D_DESC* pDesc) {
|
static inline void _sgext_d3d11_Texture2D_GetDesc(ID3D11Texture2D* self, D3D11_TEXTURE2D_DESC* pDesc) {
|
||||||
#if defined(__cplusplus)
|
|
||||||
self->GetDesc(pDesc);
|
|
||||||
#else
|
|
||||||
self->lpVtbl->GetDesc(self, pDesc);
|
self->lpVtbl->GetDesc(self, pDesc);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _sgext_d3d11_SamplerState_GetDesc(ID3D11SamplerState* self, D3D11_SAMPLER_DESC* pDesc) {
|
static inline void _sgext_d3d11_SamplerState_GetDesc(ID3D11SamplerState* self, D3D11_SAMPLER_DESC* pDesc) {
|
||||||
#if defined(__cplusplus)
|
|
||||||
self->GetDesc(pDesc);
|
|
||||||
#else
|
|
||||||
self->lpVtbl->GetDesc(self, pDesc);
|
self->lpVtbl->GetDesc(self, pDesc);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _sgext_d3d11_CopySubresourceRegion(ID3D11DeviceContext* self, ID3D11Resource *pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, ID3D11Resource *pSrcResource, UINT SrcSubresource, const D3D11_BOX *pSrcBox) {
|
static inline void _sgext_d3d11_CopySubresourceRegion(ID3D11DeviceContext* self, ID3D11Resource *pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, ID3D11Resource *pSrcResource, UINT SrcSubresource, const D3D11_BOX *pSrcBox) {
|
||||||
#if defined(__cplusplus)
|
|
||||||
self->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, pSrcResource, SrcSubresource, pSrcBox);
|
|
||||||
#else
|
|
||||||
self->lpVtbl->CopySubresourceRegion(self, pDstResource, DstSubresource, DstX, DstY, DstZ, pSrcResource, SrcSubresource, pSrcBox);
|
self->lpVtbl->CopySubresourceRegion(self, pDstResource, DstSubresource, DstX, DstY, DstZ, pSrcResource, SrcSubresource, pSrcBox);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _sgext_d3d11_OMGetRenderTargets(ID3D11DeviceContext* self, UINT NumViews, ID3D11RenderTargetView **ppRenderTargetViews, ID3D11DepthStencilView **ppDepthStencilView) {
|
static inline void _sgext_d3d11_OMGetRenderTargets(ID3D11DeviceContext* self, UINT NumViews, ID3D11RenderTargetView **ppRenderTargetViews, ID3D11DepthStencilView **ppDepthStencilView) {
|
||||||
#if defined(__cplusplus)
|
|
||||||
self->OMGetRenderTargets(NumViews, ppRenderTargetViews, ppDepthStencilView);
|
|
||||||
#else
|
|
||||||
self->lpVtbl->OMGetRenderTargets(self, NumViews, ppRenderTargetViews, ppDepthStencilView);
|
self->lpVtbl->OMGetRenderTargets(self, NumViews, ppRenderTargetViews, ppDepthStencilView);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _sgext_d3d11_RenderTargetView_GetResource(ID3D11RenderTargetView* self, ID3D11Resource** ppResource) {
|
static inline void _sgext_d3d11_RenderTargetView_GetResource(ID3D11RenderTargetView* self, ID3D11Resource** ppResource) {
|
||||||
#if defined(__cplusplus)
|
|
||||||
self->GetResource(ppResource);
|
|
||||||
#else
|
|
||||||
self->lpVtbl->GetResource(self, ppResource);
|
self->lpVtbl->GetResource(self, ppResource);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sg_d3d11_query_image_pixels(_sg_image_t* img, void* pixels) {
|
static void _sg_d3d11_query_image_pixels(_sg_image_t* img, void* pixels) {
|
||||||
|
@ -232,6 +204,15 @@ static void _sg_d3d11_query_pixels(int x, int y, int w, int h, bool origin_top_l
|
||||||
|
|
||||||
#elif defined(SOKOL_METAL)
|
#elif defined(SOKOL_METAL)
|
||||||
|
|
||||||
|
#ifdef TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
static void _sg_metal_commit_command_buffer(){};
|
||||||
|
static void _sg_metal_encode_texture_pixels(int x, int y, int w, int h, bool origin_top_left, id<MTLTexture> mtl_src_texture, void* pixels) {};
|
||||||
|
static void _sg_metal_query_image_pixels(_sg_image_t* img, void* pixels) {};
|
||||||
|
static void _sg_metal_query_pixels(int x, int y, int w, int h, bool origin_top_left, void *pixels) {};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
#import <QuartzCore/CAMetalLayer.h>
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
|
@ -287,6 +268,7 @@ static void _sg_metal_query_pixels(int x, int y, int w, int h, bool origin_top_l
|
||||||
_sg_metal_encode_texture_pixels(x, y, w, h, origin_top_left, mtl_drawable.texture, pixels);
|
_sg_metal_encode_texture_pixels(x, y, w, h, origin_top_left, mtl_drawable.texture, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sg_query_image_pixels(sg_image img_id, sg_sampler smp_id, void* pixels, int size) {
|
void sg_query_image_pixels(sg_image img_id, sg_sampler smp_id, void* pixels, int size) {
|
||||||
|
|
Loading…
Reference in a new issue