Merge branch 'sdl-macos-fix' into sdl-apple-fix

This commit is contained in:
Romain Goyet
2019-09-20 09:53:19 +02:00
13 changed files with 199 additions and 160 deletions

View File

@@ -5,7 +5,9 @@ include build/config.mak
object_for = $(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(basename $(1))))
default: $(BUILD_DIR)/epsilon.$(EXE)
# Define the default recipe
default:
# Define a standard rule helper
# If passed a last parameter value of with_local_version, we also define an
@@ -164,6 +166,10 @@ $(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(call object_fo
# We include them before the standard ones to give them precedence.
-include build/targets.$(PLATFORM).mak
# Fill in the default recipe
DEFAULT ?= $(BUILD_DIR)/epsilon.$(EXE)
default: $(DEFAULT)
$(foreach extension,$(extensions),$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(extension)))))
# Define standard compilation rules

View File

@@ -1,20 +1,17 @@
TOOLCHAIN ?= ios
TOOLCHAIN = apple
EXE = bin
IOS_PLATFORM ?= iphoneos
IOS_MIN_VERSION = 8.0
APPLE_PLATFORM ?= ios
APPLE_PLATFORM_MIN_VERSION = 8.0
# Variables below will be autoconfigured
ifeq ($(APPLE_PLATFORM),ios)
ARCHS ?= arm64 armv7
UI_REQUIRED_CAPABILITIES += armv7
else ifeq ($(APPLE_PLATFORM),ios-simulator)
ARCHS = x86_64
endif
IOS_PLATFORM_VERSION = $(shell xcrun --sdk $(IOS_PLATFORM) --show-sdk-version)
IOS_PLATFORM_BUILD = $(shell xcrun --sdk $(IOS_PLATFORM) --show-sdk-build-version)
IOS_BUILD_MACHINE_OS_BUILD = $(shell sw_vers -buildVersion)
# FIXME: Make the following variables actually automatic
IOS_XCODE_VERSION = "1010"
IOS_XCODE_BUILD = "10B61"
IOS_COMPILER = "com.apple.compilers.llvm.clang.1_0"
BUILD_DIR := $(BUILD_DIR)/$(IOS_PLATFORM)
BUILD_DIR := $(subst $(MODEL),$(APPLE_PLATFORM),$(BUILD_DIR))
ifdef ARCH
BUILD_DIR := $(BUILD_DIR)/$(ARCH)

View File

@@ -1,6 +1,11 @@
TOOLCHAIN ?= macos
TOOLCHAIN = apple
EXE = bin
APPLE_PLATFORM = macos
APPLE_PLATFORM_MIN_VERSION = 10.10
ARCHS = x86_64
ifdef ARCH
BUILD_DIR := $(BUILD_DIR)/$(ARCH)
endif

View File

@@ -1,21 +0,0 @@
.PHONY: force_rebuild_libepsilon
$(BUILD_DIR)/%/epsilon.bin: force_rebuild_libepsilon
$(Q) echo "MAKE ARCH=$*"
$(Q) $(MAKE) ARCH=$*
ARCHS ?= x86_64
.PHONY: epsilon.ipa
epsilon.ipa: $(BUILD_DIR)/app/Epsilon.app
$(BUILD_DIR)/app/Epsilon.app: $(patsubst %,$(BUILD_DIR)/%/epsilon.bin,$(ARCHS))
rm -rf $@
mkdir -p $@/Contents/MacOS
lipo -create $^ -output $@/Contents/MacOS/Epsilon
cp ion/src/sdl/macos/Info.plist $@/Contents
mkdir -p $@/Contents/Resources
cp ion/src/sdl/assets/* $@/Contents/Resources
epsilon_run:
open $(BUILD_DIR)/app/Epsilon.app

54
build/toolchain.apple.mak Normal file
View File

@@ -0,0 +1,54 @@
# Configure per-platform variables
# For some reason, all the variables aren't very consistent. For example, the
# keyword used to specify a minimum OS version doesn't always match the one used
# to specify an SDK (e.g. "iphonesimulator" vs "ios-simulator").
ifeq ($(APPLE_PLATFORM),ios)
APPLE_SDK = iphoneos
APPLE_PLATFORM_MIN_VERSION_KEYWORD = iphoneos
else ifeq ($(APPLE_PLATFORM),ios-simulator)
APPLE_SDK = iphonesimulator
APPLE_PLATFORM_MIN_VERSION_KEYWORD = ios-simulator
else ifeq ($(APPLE_PLATFORM),macos)
APPLE_SDK = macosx
APPLE_PLATFORM_MIN_VERSION_KEYWORD = macosx
else
$(error Unrecognized APPLE_PLATFORM)
endif
IOS_PLATFORM_VERSION = $(shell xcrun --sdk $(APPLE_SDK) --show-sdk-version)
IOS_PLATFORM_BUILD = $(shell xcrun --sdk $(APPLE_SDK) --show-sdk-build-version)
IOS_BUILD_MACHINE_OS_BUILD = $(shell sw_vers -buildVersion)
# FIXME: Make the following variables actually automatic
IOS_XCODE_VERSION = "1010"
IOS_XCODE_BUILD = "10B61"
IOS_COMPILER = "com.apple.compilers.llvm.clang.1_0"
ifdef ARCH
CC = $(shell xcrun --sdk $(APPLE_SDK) --find clang)
CXX = $(shell xcrun --sdk $(APPLE_SDK) --find clang++)
LD = $(shell xcrun --sdk $(APPLE_SDK) --find clang++)
SYSROOT = $(shell xcrun --sdk $(APPLE_SDK) --show-sdk-path)
SFLAGS += -arch $(ARCH)
SFLAGS += -isysroot $(SYSROOT)
SFLAGS += -fPIC
SFLAGS += -m$(APPLE_PLATFORM_MIN_VERSION_KEYWORD)-version-min=$(APPLE_PLATFORM_MIN_VERSION)
LDFLAGS += -arch $(ARCH)
LDFLAGS += -isysroot $(SYSROOT)
LDFLAGS += -m$(APPLE_PLATFORM_MIN_VERSION_KEYWORD)-version-min=$(APPLE_PLATFORM_MIN_VERSION)
else
CC = echo "Error: ARCH has not been defined" ; false
CXX = $(CC)
LD = $(CC)
endif
ACTOOL = $(shell xcrun --sdk $(APPLE_SDK) --find actool)
IBTOOL = $(shell xcrun --sdk $(APPLE_SDK) --find ibtool)
LIPO = $(shell xcrun --sdk $(APPLE_SDK) --find lipo)

View File

@@ -1,28 +0,0 @@
ifdef ARCH
CC = $(shell xcrun --sdk $(IOS_PLATFORM) --find clang)
CXX = $(shell xcrun --sdk $(IOS_PLATFORM) --find clang++)
LD = $(shell xcrun --sdk $(IOS_PLATFORM) --find clang++)
SYSROOT = $(shell xcrun --sdk $(IOS_PLATFORM) --show-sdk-path)
SFLAGS += -arch $(ARCH)
SFLAGS += -isysroot $(SYSROOT)
SFLAGS += -fPIC
SFLAGS += -miphoneos-version-min=$(IOS_MIN_VERSION)
LDFLAGS += -arch $(ARCH)
LDFLAGS += -isysroot $(SYSROOT)
LDFLAGS += -miphoneos-version-min=$(IOS_MIN_VERSION)
else
CC = false
CXX = false
LD = false
endif
ACTOOL = $(shell xcrun --sdk $(IOS_PLATFORM) --find actool)
IBTOOL = $(shell xcrun --sdk $(IOS_PLATFORM) --find ibtool)
LIPO = $(shell xcrun --sdk $(IOS_PLATFORM) --find lipo)

View File

@@ -1,14 +0,0 @@
CC = clang
CXX = clang++
LD = clang++
#ARCH = x86_64
#SDK = iphonesimulator
# ARCH = arm64
# SDK = iphoneos
SYSROOT = $(shell xcrun --sdk macosx --show-sdk-path)
SFLAGS += -fPIC -arch $(ARCH) -isysroot $(SYSROOT)
LDFLAGS += -arch $(ARCH) -isysroot $(SYSROOT)
#-framework Foundation -framework OpenGLES -framework UIKit -framework AVFoundation -framework AudioToolbox -framework QuartzCore -framework GameController -framework CoreGraphics -framework CoreMotion

View File

@@ -1,12 +1,20 @@
ion_src += $(addprefix ion/src/sdl/ios/, \
images.m \
language.m \
)
ion_src += $(addprefix ion/src/sdl/shared/, \
apple/language.m \
)
$(call object_for,ion/src/sdl/shared/main.cpp) : SFLAGS += -DEPSILON_SDL_FULLSCREEN=1
GOOGLE_ANALYTICS = 1
ifeq ($(GOOGLE_ANALYTICS),1)
# Display a nice error if the Google Analytics SDK is not installed
$(call object_for,ion/src/sdl/ios/telemetry.m): ion/src/sdl/ios/GoogleAnalyticsServices/GoogleAnalytics/Library/GAI.h
ion/src/sdl/ios/GoogleAnalyticsServices/GoogleAnalytics/Library/GAI.h:
$(error GoogleAnalyticsServices needs to be installed in ion/src/sdl/ios/GoogleAnalyticsServices)
ion_src += ion/src/sdl/ios/telemetry.m
$(call object_for,ion/src/sdl/ios/telemetry.m): SFLAGS += -Iion/src/sdl/ios/GoogleAnalyticsServices/GoogleAnalytics/Library
@@ -20,43 +28,25 @@ else
ion_src += ion/src/sdl/shared/telemetry_dummy.cpp
endif
# Cross-ARCH epsilon.bin
# App resources
.PHONY: force_remake
SIMULATOR_ICON_SIZES = 20x20 29x29 40x40 40x40 40x40 58x58 58x58 60x60 76x76 \
80x80 80x80 87x87 120x120 120x120 152x152 167x167 180x180 1024x1024
SIMULATOR_ASSETS_PATH = $(BUILD_DIR)/app/assets/Assets.xcassets
SIMULATOR_ICONSET = $(SIMULATOR_ASSETS_PATH)/AppIcon.appiconset
$(BUILD_DIR)/%/epsilon.bin: force_remake
$(Q) echo "MAKE ARCH=$*"
$(Q) $(MAKE) ARCH=$*
include ion/src/sdl/shared/apple/Makefile
ifeq ($(IOS_PLATFORM),iphoneos)
ARCHS ?= arm64 armv7
UI_REQUIRED_CAPABILITIES += armv7
else ifeq ($(IOS_PLATFORM),iphonesimulator)
ARCHS ?= x86_64
endif
# iOS resources
ios_resource = $(addprefix $(BUILD_DIR)/app/Payload/Epsilon.app/,$(1))
$(call ios_resource,Epsilon): $(patsubst %,$(BUILD_DIR)/%/epsilon.bin,$(ARCHS)) | $$(@D)/.
$(call rule_label,LIPO)
$(Q) $(LIPO) -create $^ -output $@
$(call ios_resource,background.jpg): ion/src/sdl/assets/background.jpg | $$(@D)/.
$(call rule_label,COPY)
$(Q) cp $^ $@
$(call ios_resource,Info.plist): ion/src/sdl/ios/Info.plist $(call ios_resource,Assets.car)
$(call simulator_app_plist,Info.plist): ion/src/sdl/ios/Info.plist $(call simulator_app_resource,Assets.car)
$(call rule_label,PLUTIL)
$(Q) cp $< $@
$(Q) plutil -insert "BuildMachineOSBuild" -string "$(IOS_BUILD_MACHINE_OS_BUILD)" $@
$(Q) plutil -insert "MinimumOSVersion" -string "$(IOS_MIN_VERSION)" $@
$(Q) plutil -insert "MinimumOSVersion" -string "$(APPLE_PLATFORM_MIN_VERSION)" $@
$(Q) plutil -insert "DTCompiler" -string "$(IOS_COMPILER)" $@
$(Q) plutil -insert "DTPlatformBuild" -string "$(IOS_PLATFORM_BUILD)" $@
$(Q) plutil -insert "DTPlatformName" -string "$(IOS_PLATFORM)" $@
$(Q) plutil -insert "DTPlatformName" -string "$(APPLE_SDK)" $@
$(Q) plutil -insert "DTPlatformVersion" -string "$(IOS_PLATFORM_VERSION)" $@
$(Q) plutil -insert "DTSDKName" -string "$(IOS_PLATFORM)$(IOS_PLATFORM_VERSION)" $@
$(Q) plutil -insert "DTSDKName" -string "$(APPLE_SDK)$(IOS_PLATFORM_VERSION)" $@
$(Q) plutil -insert "DTSDKBuild" -string "$(IOS_PLATFORM_BUILD)" $@
$(Q) plutil -insert "DTXcode" -string "$(IOS_XCODE_VERSION)" $@
$(Q) plutil -insert "DTXcodeBuild" -string "$(IOS_XCODE_BUILD)" $@
@@ -66,61 +56,48 @@ $(call ios_resource,Info.plist): ion/src/sdl/ios/Info.plist $(call ios_resource,
$(Q) plutil -replace CFBundleIcons -json `plutil -extract CFBundleIcons json -o - $(BUILD_DIR)/app/assets/partial.plist` $@
$(Q) plutil -replace CFBundleIcons~ipad -json `plutil -extract CFBundleIcons~ipad json -o - $(BUILD_DIR)/app/assets/partial.plist` $@
$(call ios_resource,launch.storyboardc): ion/src/sdl/ios/launch.storyboard | $$(@D)/.
$(call simulator_app_resource,launch.storyboardc): ion/src/sdl/ios/launch.storyboard | $$(@D)/.
$(call rule_label,IBTOOL)
$(Q) $(IBTOOL) --minimum-deployment-target $(IOS_MIN_VERSION) --compile $@ $^
$(Q) $(IBTOOL) --minimum-deployment-target $(APPLE_PLATFORM_MIN_VERSION) --compile $@ $^
ifdef IOS_PROVISIONNING_PROFILE
$(call ios_resource,embedded.mobileprovision): $(IOS_PROVISIONNING_PROFILE) | $$(@D)/.
$(call simulator_app_resource,embedded.mobileprovision): $(IOS_PROVISIONNING_PROFILE) | $$(@D)/.
$(call rule_label,COPY)
$(Q) cp $^ $@
else
$(call ios_resource,embedded.mobileprovision):
$(call simulator_app_resource,embedded.mobileprovision):
$(error Please define IOS_PROVISIONNING_PROFILE to point to the .mobileprovision file you want to use)
endif
$(BUILD_DIR)/app/entitlements.plist: $(call ios_resource,embedded.mobileprovision)
$(BUILD_DIR)/app/entitlements.plist: $(call simulator_app_resource,embedded.mobileprovision)
$(call rule_label,SCMS)
$(Q) security cms -D -i $(IOS_PROVISIONNING_PROFILE) | plutil -extract Entitlements xml1 - -o $@
asset_for = $(addprefix $(BUILD_DIR)/app/assets/Assets.xcassets/AppIcon.appiconset/,$(1))
icon_assets = $(addsuffix .png,$(addprefix icon_, \
20x20 29x29 40x40 40x40 40x40 58x58 58x58 60x60 76x76 80x80 80x80 87x87 \
120x120 120x120 152x152 167x167 180x180 1024x1024 \
))
$(call asset_for,Contents.json): ion/src/sdl/ios/icon_assets.json $(call asset_for,$(icon_assets)) | $$(@D)/.
$(SIMULATOR_ICONSET)/Contents.json: ion/src/sdl/ios/icon_assets.json $(SIMULATOR_ICONS) | $$(@D)/.
$(call rule_label,COPY)
$(Q) cp $< $@
$(call asset_for,icon_%.png): ion/src/sdl/assets/logo.svg | $$(@D)/.
$(call rule_label,CONVERT)
$(Q) convert -background "#FFB734" -resize $* $< $@
$(call ios_resource,Assets.car): $(call asset_for,Contents.json) | $$(@D)/.
$(call simulator_app_resource,Assets.car): $(SIMULATOR_ICONSET)/Contents.json | $$(@D)/.
$(call rule_label,ACTOOL)
$(Q) $(ACTOOL) --compile $(BUILD_DIR)/app/Payload/Epsilon.app --minimum-deployment-target $(IOS_MIN_VERSION) --platform $(IOS_PLATFORM) --app-icon AppIcon --output-partial-info-plist $(BUILD_DIR)/app/assets/partial.plist $(BUILD_DIR)/app/assets/Assets.xcassets > /dev/null
$(Q) $(ACTOOL) --compile $(BUILD_DIR)/app/Payload/Epsilon.app --minimum-deployment-target $(APPLE_PLATFORM_MIN_VERSION) --platform $(APPLE_SDK) --app-icon AppIcon --output-partial-info-plist $(BUILD_DIR)/app/assets/partial.plist $(SIMULATOR_ASSETS_PATH) > /dev/null
epsilon_app_deps = $(call ios_resource,\
SIMULATOR_APP_DEPS += $(call simulator_app_resource,\
Assets.car \
Epsilon \
Info.plist \
background.jpg \
launch.storyboardc \
)
$(BUILD_DIR)/app/epsilon.ipa: $(epsilon_app_deps) $(BUILD_DIR)/app/entitlements.plist
$(BUILD_DIR)/app/epsilon.ipa: $(SIMULATOR_APP_DEPS) $(BUILD_DIR)/app/entitlements.plist
$(call rule_label,SIGN)
$(Q) codesign --force --entitlements $(BUILD_DIR)/app/entitlements.plist --sign "iPhone Distribution: NumWorks" $(BUILD_DIR)/app/Payload/Epsilon.app
$(call rule_label,ZIP)
$(Q) cd $(dir $@) ; zip -qr9 $(notdir $@) Payload
.PHONY: epsilon.ipa
epsilon.ipa: $(BUILD_DIR)/app/epsilon.ipa
ifndef ARCH
DEFAULT := $(BUILD_DIR)/app/epsilon.ipa
endif
ifeq ($(IOS_PLATFORM),iphonesimulator)
ifeq ($(APPLE_PLATFORM),ios-simulator)
.PHONY: epsilon_run
epsilon_run: $(epsilon_app_deps)
epsilon_run: $(SIMULATOR_APP_DEPS)
xcrun simctl install booted $(BUILD_DIR)/app/Payload/Epsilon.app
endif

View File

@@ -2,44 +2,24 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>18B75</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>Epsilon</string>
<key>CFBundleIconFile</key>
<string>app.icns</string>
<key>CFBundleIdentifier</key>
<string>com.numworks.calculator</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Epsilon</string>
<string>NumWorks</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>10B61</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>18B71</string>
<key>DTSDKName</key>
<string>macosx10.14</string>
<key>DTXcode</key>
<string>1010</string>
<key>DTXcodeBuild</key>
<string>10B61</string>
<key>LSMinimumSystemVersion</key>
<string>10.14</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 NumWorks. All rights reserved.</string>
<key>NSPrincipalClass</key>

View File

@@ -1,3 +1,37 @@
ion_src += $(addprefix ion/src/sdl/macos/, \
images.m \
)
ion_src += $(addprefix ion/src/sdl/shared/, \
apple/language.m \
telemetry_dummy.cpp \
)
# App resources
SIMULATOR_ICON_SIZES = 16x16 32x32 64x64 128x128 256x256 512x512 1024x1024
SIMULATOR_APP_BINARY_PATH = Contents/MacOS/
SIMULATOR_APP_RESOURCE_PATH = Contents/Resources/
SIMULATOR_APP_PLIST_PATH = Contents/
SIMULATOR_ICONSET = $(BUILD_DIR)/app/assets/app.iconset
include ion/src/sdl/shared/apple/Makefile
$(call simulator_app_plist,Info.plist): ion/src/sdl/macos/Info.plist
$(call rule_label,PLUTIL)
$(Q) cp $< $@
$(Q) plutil -insert "LSMinimumSystemVersion" -string "$(MACOS_MIN_VERSION)" $@
$(Q) plutil -insert "CFBundleVersion" -string "$(EPSILON_VERSION)" $@
$(Q) plutil -insert "CFBundleShortVersionString" -string "$(EPSILON_VERSION)" $@
# macOS uses icns files
$(call simulator_app_resource,app.icns): $(SIMULATOR_ICONS) | $$(@D)/.
$(call rule_label,ICNUTIL)
$(Q) iconutil --convert icns --output $@ $(SIMULATOR_ICONSET)
SIMULATOR_APP_DEPS += $(call simulator_app_resource,app.icns)
ifndef ARCH
DEFAULT := $(SIMULATOR_APP_DEPS)
endif

View File

@@ -0,0 +1,49 @@
# This file contains all the recipies shared between iOS and macOS.
# The only things that have to be customized per platform are the icons and the
# Info.plist.
SIMULATOR_APP_PATH = $(BUILD_DIR)/app/Payload/Epsilon.app
simulator_app_binary = $(addprefix $(SIMULATOR_APP_PATH)/$(SIMULATOR_APP_BINARY_PATH),$(1))
simulator_app_resource = $(addprefix $(SIMULATOR_APP_PATH)/$(SIMULATOR_APP_RESOURCE_PATH),$(1))
simulator_app_plist = $(addprefix $(SIMULATOR_APP_PATH)/$(SIMULATOR_APP_PLIST_PATH),$(1))
# Epsilon binary
.PHONY: force_remake
$(BUILD_DIR)/%/epsilon.bin: force_remake
$(Q) echo "MAKE ARCH=$*"
$(Q) $(MAKE) ARCH=$*
$(call simulator_app_binary,Epsilon): $(patsubst %,$(BUILD_DIR)/%/epsilon.bin,$(ARCHS)) | $$(@D)/.
$(call rule_label,LIPO)
$(Q) $(LIPO) -create $^ -output $@
# Background image
$(call simulator_app_resource,background.jpg): ion/src/sdl/assets/background.jpg | $$(@D)/.
$(call rule_label,COPY)
$(Q) cp $^ $@
# Process icons
ifndef SIMULATOR_ICON_SIZES
$(error SIMULATOR_ICON_SIZES should be defined)
endif
ifndef SIMULATOR_ICONSET
$(error SIMULATOR_ICONSET should be defined)
endif
SIMULATOR_ICONS = $(addprefix $(SIMULATOR_ICONSET)/,$(addsuffix .png,$(addprefix icon_, $(SIMULATOR_ICON_SIZES))))
$(addprefix $(SIMULATOR_ICONSET)/,icon_%.png): ion/src/sdl/assets/logo.svg | $$(@D)/.
$(call rule_label,CONVERT)
$(Q) convert -background "#FFB734" -resize $* $< $@
# Export simulator app dependencies
SIMULATOR_APP_DEPS += $(call simulator_app_binary,Epsilon)
SIMULATOR_APP_DEPS += $(call simulator_app_plist,Info.plist)
SIMULATOR_APP_DEPS += $(call simulator_app_resource,background.jpg)

View File

@@ -1,4 +1,4 @@
#include "../shared/platform.h"
#include "../platform.h"
#include <Foundation/Foundation.h>

View File

@@ -2,7 +2,7 @@ ion_src += $(addprefix ion/src/sdl/windows/, \
images.cpp \
resources.rc \
)
ion_src += $(addprefix ion/src/sdl/windows/, \
ion_src += $(addprefix ion/src/sdl/shared/, \
telemetry_dummy.cpp \
)