Skip to content

Commit 5f4e7c7

Browse files
authored
Merge 24705af into 897ef17
2 parents 897ef17 + 24705af commit 5f4e7c7

File tree

15 files changed

+2250
-18
lines changed

15 files changed

+2250
-18
lines changed

build.macos32x86/common/Makefile.app

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ $(VMLOCALIZATION): $(OSXCOMMONDIR)/English.lproj/$(SYSTEM)-Localizable.strings
144144
@mkdir -p $(dir $@)
145145
cp -p $< $@
146146

147-
$(VMMENUNIB): $(PLATDIR)/iOS/vm/English.lproj/MainMenu.xib
147+
$(VMMENUNIB): $(PLATDIR)/iOS/vm/English.lproj/MainMenu-opengl.xib
148148
@mkdir -p $(dir $@)
149149
$(XCUB)/ibtool --errors --warnings --notices --module $(VM) \
150150
--minimum-deployment-target $(TARGET_VERSION_MIN) \
151151
--auto-activate-custom-fonts --output-format human-readable-text \
152152
--compile $(VMMENUNIB) \
153-
$(PLATDIR)/iOS/vm/English.lproj/MainMenu.xib
153+
$(PLATDIR)/iOS/vm/English.lproj/MainMenu-opengl.xib
154154

155155
$(APP)/Contents/Resources/%.icns: $(OSXDIR)/%.icns
156156
@mkdir -p $(APP)/Contents/Resources

build.macos32x86/common/Makefile.flags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ifdef CLANG_7_3_OR_ABOVE
2929
else
3030
OBJC_CODE_MODEL := -fno-objc-arc
3131
endif
32-
CFLAGS:=$(CFLAGS) -DBUILD_FOR_OSX=1 \
32+
CFLAGS:=$(CFLAGS) -DBUILD_FOR_OSX=1 -DNO_METAL=1 \
3333
-arch $(TARGET_ARCH) \
3434
-mmacosx-version-min=$(TARGET_VERSION_MIN) -msse4.2 \
3535
-fvisibility=default -fwrapv \

build.macos64x64/common/Makefile.app

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ OSXICONS:=$(OSXDIR)/$(VM).icns $(wildcard $(OSXDIR)/$(SYSTEM)*.icns)
8383
VMICONS:=$(addprefix $(APP)/Contents/Resources/,$(notdir $(OSXICONS)))
8484
VMMENUNIB:=$(APP)/Contents/Resources/English.lproj/MainMenu.nib
8585
VMLOCALIZATION:=$(APP)/Contents/Resources/English.lproj/Localizable.strings
86+
OSXMETAL_SHADERS:=$(wildcard $(OSXDIR)/*.metal)
87+
VMMETAL_SHADERS:=$(addprefix $(APP)/Contents/Resources/,$(notdir $(OSXMETAL_SHADERS:.metal=.metallib)))
8688
SOURCES:=
8789
ifneq ($(SOURCEFILE),)
8890
SOURCES:=./$(SOURCEFILE)
@@ -94,7 +96,7 @@ $(APP)/Contents/Resources/$(APPSOURCE): $(SOURCESDIR)/$(APPSOURCE)
9496
endif
9597

9698
$(APP): cleanbundles $(THIRDPARTYPREREQS) $(VMEXE) $(VMBUNDLES) $(VMPLUGINDYLIBS) \
97-
$(VMPLIST) $(VMLOCALIZATION) $(VMMENUNIB) $(VMICONS) \
99+
$(VMPLIST) $(VMLOCALIZATION) $(VMMENUNIB) $(VMICONS) $(VMMETAL_SHADERS) \
98100
$(SOURCES) $(THIRDPARTYLIBS) $(APPPOST) signapp touchapp
99101

100102
# Bundles with missing prerequisites won't be built. But we need to force the
@@ -111,6 +113,10 @@ $(VMEXE): $(OBJDIR)/$(VM)
111113
@mkdir -p $(APP)/Contents/MacOS
112114
cp -p $(OBJDIR)/$(VM) $(APP)/Contents/MacOS
113115

116+
$(APP)/Contents/Resources/%.metallib: $(OBJDIR)/%.metallib
117+
@mkdir -p $(APP)/Contents/Resources
118+
cp $< $(APP)/Contents/Resources
119+
114120
$(APP)/Contents/Resources/%.bundle: $(BLDDIR)/vm/%.bundle
115121
@mkdir -p $(APP)/Contents/Resources
116122
@if [ -f $(basename $<).ignore ]; then \

build.macos64x64/common/Makefile.flags

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
XCODE:=$(shell /usr/bin/xcode-select -p)
77
XCUB:=$(XCODE)/usr/bin
88
SDKsDIR:=$(XCODE)/Platforms/MacOSX.platform/Developer/SDKs
9-
#Build the oldest SDK installed (must be MacOSX10.10.sdk and later)
10-
SDKs:=MacOSX10.10.sdk MacOSX10.11.sdk MacOSX10.12.sdk MacOSX10.13.sdk MacOSX10.14.sdk
9+
#Build the oldest SDK installed (must be MacOSX10.11.sdk because of Metal and later)
10+
SDKs:=MacOSX10.11.sdk MacOSX10.12.sdk MacOSX10.13.sdk MacOSX10.14.sdk
1111
SDK:=$(firstword $(realpath $(addprefix $(SDKsDIR)/, $(SDKs))))
1212
ifeq ($(strip $(SDK)),)
1313
$(error could not find a valid SDK)
@@ -58,4 +58,5 @@ FRAMEWORKS:=-fobjc-link-runtime \
5858
-framework AudioToolbox -framework CoreAudio \
5959
-framework SystemConfiguration \
6060
-framework ApplicationServices -framework Security \
61-
-framework QuartzCore
61+
-framework QuartzCore \
62+
-framework Metal -framework MetalKit

build.macos64x64/common/Makefile.rules

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
# /usr/bin/clang, a.k.a. /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
88
CC := clang
99
LD := clang
10+
1011
LDCXX := clang++ # For linking c++ bundles
1112

1213
include ../common/Makefile.flags
1314

15+
METAL_CC := xcrun -sdk $(SDK) metal -std=osx-metal1.1
16+
METAL_LD := xcrun -sdk $(SDK) metallib
17+
1418
DEPFLAGS = -MT $@ -MMD -MP -MF deps/$(*F).Td
1519
ALLFLAGS = $(DEPFLAGS) $(WARNINGS) $(CFLAGS)
1620
POSTCOMPILE = sed '/^$$/d' <deps/$(*F).Td | sed '/^.*:$$/d' | sed 's/^build[^/]*/$$(BUILD)/' > deps/$(*F).d; rm deps/$(*F).Td; touch -r $< deps/$(*F).d
@@ -27,6 +31,12 @@ $(OBJDIR)/%.o: %.cpp deps/%.d $(MAKEFILE)
2731
$(CC) -x c++ $(ALLFLAGS) $(INCLUDES) -c $< -o $@
2832
$(POSTCOMPILE)
2933

34+
$(OBJDIR)/%.air: %.metal $(MAKEFILE)
35+
$(METAL_CC) $(INCLUDES) -c $< -o $@
36+
37+
$(OBJDIR)/%.metallib: $(OBJDIR)/%.air $(MAKEFILE)
38+
$(METAL_LD) $< -o $@
39+
3040
deps/%.d: ;
3141

3242
.PRECIOUS: deps/%.d

build.macos64x64/common/Makefile.vm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ endif
106106
TZ:=$(shell date +%Z)
107107
DEFS:= $(COGDEFS) -DUSE_GLOBAL_STRUCT=0 -DNO_ISNAN=1 \
108108
-DUSE_INLINE_MEMORY_ACCESSORS -D'TZ="$(TZ)"' \
109+
-DUSE_METAL=1 \
109110
$(INTERPFLAGS)
110111
XDEFS:= -DSQUEAK_BUILTIN_PLUGIN
111112
CFLAGS:= $(OFLAGS) $(COGDEFS) $(DEBUGVM) $(DEFS) $(XDEFS)

platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ Some of this code was funded via a grant from the European Smalltalk User Group
4343
#import "sqSqueakNullScreenAndWindow.h"
4444
#import "sqaio.h"
4545

46+
#if !defined(USE_METAL)
4647
# import <OpenGL/gl.h>
47-
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
48-
# import <OpenGL/OpenGL.h>
49-
#else
50-
# import <OpenGL/Opengl.h>
48+
# if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
49+
# import <OpenGL/OpenGL.h>
50+
# else
51+
# import <OpenGL/Opengl.h>
52+
# endif
5153
#endif
5254

5355
extern sqSqueakAppDelegate *gDelegateApp;
@@ -94,16 +96,19 @@ extern void setIoProcessEventsHandler(void * handler) {
9496
sqInt ioProcessEvents(void) {
9597
aioPoll(0);
9698

99+
#if !defined(USE_METAL)
97100
// We need to restore the opengl context to whatever the image was
98101
// already using. This is required by SDL2 in Pharo.
99102
NSOpenGLContext *oldContext = [NSOpenGLContext currentContext];
103+
#endif
100104

101105
// We need to run the vmIOProcessEvents even if we are using SDL2,
102106
// otherwise we end with some double free errors in an autorelease pool.
103107
vmIOProcessEvents();
104108
if(ioProcessEventsHandler && ioProcessEventsHandler != vmIOProcessEvents)
105109
ioProcessEventsHandler();
106110

111+
#if !defined(USE_METAL)
107112
NSOpenGLContext *newContext = [NSOpenGLContext currentContext];
108113
if(oldContext != newContext) {
109114
if (oldContext != nil) {
@@ -112,6 +117,7 @@ sqInt ioProcessEvents(void) {
112117
[NSOpenGLContext clearCurrentContext];
113118
}
114119
}
120+
#endif
115121

116122
return 0;
117123
}

0 commit comments

Comments
 (0)