Added optimized device builds and harden the Embedded toolchain setup in both the PlayDate bindings and HelloPlayDate example targets.
This commit is contained in:
+21
-2
@@ -4,7 +4,7 @@ STACK_SIZE = 61800
|
||||
# Locate the Playdate SDK
|
||||
SDK = ${PLAYDATE_SDK_PATH}
|
||||
ifeq ($(SDK),)
|
||||
SDK = $(shell egrep '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | cut -c9-)
|
||||
SDK = $(shell sed -nE 's/^[[:space:]]*SDKRoot[[:space:]]+//p' ~/.Playdate/config | head -n 1)
|
||||
endif
|
||||
|
||||
ifeq ($(SDK),)
|
||||
@@ -28,18 +28,37 @@ else
|
||||
$(error Swift toolchain not found; set ENV value TOOLCHAINS (e.g. TOOLCHAINS=org.swift.59202403121a make))
|
||||
endif
|
||||
|
||||
# Note: paths containing spaces are not supported (make word-splits them).
|
||||
GCC_INCLUDE_PATHS := $(shell $(CC) -E -Wp,-v -xc /dev/null 2>&1 | egrep '^ ' | xargs echo )
|
||||
ifeq ($(GCC_INCLUDE_PATHS),)
|
||||
$(error arm-none-eabi C headers not found; install the Arm GNU toolchain and ensure $(CC) is runnable)
|
||||
endif
|
||||
|
||||
SWIFT_EXEC := "$(shell TOOLCHAINS=$(TOOLCHAINS) xcrun -f swiftc)"
|
||||
# With an unknown TOOLCHAINS id, xcrun silently falls back to Xcode's swiftc,
|
||||
# which lacks the Embedded ARM stdlib; fail early with a clear message.
|
||||
ifeq ($(findstring .xctoolchain,$(SWIFT_EXEC)),)
|
||||
$(error swiftc for toolchain "$(TOOLCHAINS)" not found (xcrun returned $(SWIFT_EXEC)); install a swift.org toolchain or set TOOLCHAINS)
|
||||
endif
|
||||
TOOLCHAIN_PATH := $(shell echo $(SWIFT_EXEC)|sed s'/.xctoolchain.*/.xctoolchain/')
|
||||
|
||||
$(info Using Swift toolchain "$(TOOLCHAINS)" (from $(TOOLCHAIN_PATH)))
|
||||
|
||||
# Optimization mode for Swift compiles. -Osize targets small code, which
|
||||
# suits the device's flash/RAM budget (measured 15% smaller than -O on the
|
||||
# HelloPlaydate example); override per-build for maximum speed instead:
|
||||
# `make SWIFT_OPT=-O`. For larger games, appending
|
||||
# `-Xfrontend -mergeable-symbols -Xfrontend -mergeable-traps` lets the
|
||||
# linker deduplicate stdlib code specialized into both the wrapper and the
|
||||
# game module.
|
||||
SWIFT_OPT ?= -Osize
|
||||
|
||||
C_FLAGS := \
|
||||
$(addprefix -I ,$(GCC_INCLUDE_PATHS)) \
|
||||
|
||||
SWIFT_FLAGS := \
|
||||
$(addprefix -Xcc , $(C_FLAGS)) \
|
||||
-O \
|
||||
$(SWIFT_OPT) \
|
||||
-wmo -enable-experimental-feature Embedded \
|
||||
-Xfrontend -disable-stack-protector \
|
||||
-Xfrontend -function-sections \
|
||||
|
||||
Reference in New Issue
Block a user