Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# - iOS - build everything for iOS
# - tvOS - build everything for tvOS
# - watchOS - build everything for watchOS
# - visionOS - build everything for visionOS

# Current directory
PROJECT_DIR=$(shell pwd)
Expand Down Expand Up @@ -33,26 +34,34 @@ OPENSSL_VERSION=3.0.16-1
XZ_VERSION=5.6.4-1

# Supported OS
OS_LIST=macOS iOS tvOS watchOS
OS_LIST=macOS iOS tvOS watchOS visionOS

CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar

# macOS targets
TARGETS-macOS=macosx.x86_64 macosx.arm64
TRIPLE_OS-macOS=macos
VERSION_MIN-macOS=11.0

# iOS targets
TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64
TRIPLE_OS-iOS=ios
VERSION_MIN-iOS=13.0

# tvOS targets
TARGETS-tvOS=appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64
TRIPLE_OS-tvOS=tvos
VERSION_MIN-tvOS=12.0

# watchOS targets
TARGETS-watchOS=watchsimulator.x86_64 watchsimulator.arm64 watchos.arm64_32
TRIPLE_OS-watchOS=watchos
VERSION_MIN-watchOS=4.0

TARGETS-visionOS=xrsimulator.arm64 xros.arm64
TRIPLE_OS-visionOS=xros
VERSION_MIN-visionOS=2.0

# The architecture of the machine doing the build
HOST_ARCH=$(shell uname -m)
HOST_PYTHON=$(shell which python$(PYTHON_VER))
Expand Down Expand Up @@ -128,10 +137,10 @@ ARCH-$(target)=$$(subst .,,$$(suffix $(target)))

ifneq ($(os),macOS)
ifeq ($$(findstring simulator,$$(SDK-$(target))),)
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(TRIPLE_OS-$(os))$$(VERSION_MIN-$(os))
IS_SIMULATOR-$(target)=False
else
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(TRIPLE_OS-$(os))$$(VERSION_MIN-$(os))-simulator
IS_SIMULATOR-$(target)=True
endif
endif
Expand Down Expand Up @@ -398,15 +407,13 @@ define build-sdk
sdk=$1
os=$2

OS_LOWER-$(sdk)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]')

SDK_TARGETS-$(sdk)=$$(filter $(sdk).%,$$(TARGETS-$(os)))
SDK_ARCHES-$(sdk)=$$(sort $$(subst .,,$$(suffix $$(SDK_TARGETS-$(sdk)))))

ifeq ($$(findstring simulator,$(sdk)),)
SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")
SDK_SLICE-$(sdk)=$$(TRIPLE_OS-$(os))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")
else
SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")-simulator
SDK_SLICE-$(sdk)=$$(TRIPLE_OS-$(os))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")-simulator
endif

# Expand the build-target macro for target on this OS
Expand Down Expand Up @@ -481,11 +488,15 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk))
mkdir -p $$(PYTHON_INSTALL-$(sdk))/include
ln -si ../Python.framework/Headers $$(PYTHON_INSTALL-$(sdk))/include/python$(PYTHON_VER)

ifeq ($(os), visionOS)
echo "Skipping arch-specific header copying for visionOS"
else
# Add the individual headers from each target in an arch-specific name
$$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_INCLUDE-$$(target))/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig-$$(ARCH-$$(target)).h; )
$(foreach target,$(SDK_TARGETS-$(sdk)),cp $(PYTHON_INCLUDE-$(target))/pyconfig.h $(PYTHON_INCLUDE-$(sdk))/pyconfig-$(ARCH-$(target)).h;)

# Copy the cross-target header from the source folder of the first target in the $(sdk) SDK
cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$(sdk))))/$(os)/Resources/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
cp $(PYTHON_SRCDIR-$(firstword $(SDK_TARGETS-$(sdk))))/$(os)/Resources/pyconfig.h $(PYTHON_INCLUDE-$(sdk))/pyconfig.h
endif


$$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-$(sdk))/Info.plist $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_PLATFORM_SITECUSTOMIZE-$$(target)))
Expand Down
Loading