Skip to content

Commit aa5041d

Browse files
committed
Revert 34e63f4, and use a different approach for minimizing build impact.
This manages the process by exposing per-OS clean targets, so you can clean an iOS Python build without cleaning the macOS Python.
1 parent e09a9c6 commit aa5041d

File tree

1 file changed

+63
-57
lines changed

1 file changed

+63
-57
lines changed

Makefile

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ all: $(OS_LIST)
111111

112112
.PHONY: \
113113
all clean distclean update-patch vars \
114-
$(foreach product,$(PRODUCTS),$(foreach os,$(OS_LIST),$(product) $(product)-$(os) clean-$(product))) \
114+
$(foreach product,$(PRODUCTS),$(foreach os,$(OS_LIST),$(product) $(product)-$(os) clean-$(product) clean-$(product)-$(os))) \
115115
$(foreach os,$(OS_LIST),$(os) clean-$(os) vars-$(os))
116116

117117
# Clean all builds
@@ -139,14 +139,6 @@ update-patch:
139139
# Setup: BZip2
140140
###########################################################################
141141

142-
# Clean the bzip2 project
143-
clean-BZip2:
144-
@echo ">>> Clean BZip2 build products"
145-
rm -rf build/*/bzip2-$(BZIP2_VERSION)-* \
146-
build/*/bzip2 \
147-
build/*/bzip2-*.log \
148-
build/*/Support/BZip2.xcframework
149-
150142
# Download original BZip2 source code archive.
151143
downloads/bzip2-$(BZIP2_VERSION).tgz:
152144
@echo ">>> Download BZip2 sources"
@@ -160,14 +152,6 @@ downloads/bzip2-$(BZIP2_VERSION).tgz:
160152
# Setup: XZ (LZMA)
161153
###########################################################################
162154

163-
# Clean the XZ project
164-
clean-XZ:
165-
@echo ">>> Clean XZ build products"
166-
rm -rf build/*/xz-$(XZ_VERSION)-* \
167-
build/*/xz \
168-
build/*/xz-*.log \
169-
build/*/Support/XZ.xcframework
170-
171155
# Download original XZ source code archive.
172156
downloads/xz-$(XZ_VERSION).tgz:
173157
@echo ">>> Download XZ sources"
@@ -183,14 +167,6 @@ downloads/xz-$(XZ_VERSION).tgz:
183167
# Felix Shchulze (@x2on) https://github.com/x2on/OpenSSL-for-iPhone
184168
###########################################################################
185169

186-
# Clean the OpenSSL project
187-
clean-OpenSSL:
188-
@echo ">>> Clean OpenSSL build products"
189-
rm -rf build/*/openssl-$(OPENSSL_VERSION)-* \
190-
build/*/openssl \
191-
build/*/openssl-*.log \
192-
build/*/Support/OpenSSL.xcframework
193-
194170
# Download original OpenSSL source code archive.
195171
downloads/openssl-$(OPENSSL_VERSION).tgz:
196172
@echo ">>> Download OpenSSL sources"
@@ -208,13 +184,6 @@ downloads/openssl-$(OPENSSL_VERSION).tgz:
208184
# Setup: libFFI
209185
###########################################################################
210186

211-
# Clean the libFFI project
212-
clean-libFFI:
213-
@echo ">>> Clean libFFI build products"
214-
rm -rf build/*/libffi-$(LIBFFI_VERSION) \
215-
build/*/libffi-*.log \
216-
build/*/Support/libFFI.xcframework
217-
218187
# Download original XZ source code archive.
219188
downloads/libffi-$(LIBFFI_VERSION).tgz:
220189
@echo ">>> Download libFFI sources"
@@ -228,28 +197,6 @@ downloads/libffi-$(LIBFFI_VERSION).tgz:
228197
# Setup: Python
229198
###########################################################################
230199

231-
# Clean the Python project
232-
clean-Python:
233-
@echo ">>> Clean Python build products"
234-
rm -rf \
235-
dist/Python-$(PYTHON_VER)-* \
236-
build/*/Python-$(PYTHON_VERSION)-* \
237-
build/*/python \
238-
build/*/python-*.log \
239-
build/*/Support/Python.xcframework \
240-
build/*/Support/Python
241-
242-
dev-clean-Python:
243-
@echo ">>> Partially clean Python build products to the point where local code modifications can be made"
244-
rm -rf \
245-
dist/Python-$(PYTHON_VER)-* \
246-
build/*/Python-$(PYTHON_VERSION)-*/python.exe \
247-
build/*/Python-$(PYTHON_VERSION)-*/_install \
248-
build/*/python \
249-
build/*/python-*.log \
250-
build/*/Support/Python.xcframework \
251-
build/*/Support/Python
252-
253200
# Download original Python source code archive.
254201
downloads/Python-$(PYTHON_VERSION).tgz:
255202
@echo ">>> Download Python sources"
@@ -466,6 +413,7 @@ $$(PYTHON_DIR-$(target))/Makefile: \
466413
$$(XZ_XCFRAMEWORK-$(os)) \
467414
$$(OPENSSL_XCFRAMEWORK-$(os)) \
468415
$$(LIBFFI_XCFRAMEWORK-$(os)) \
416+
$$(PYTHON_XCFRAMEWORK-macOS) \
469417
downloads/Python-$(PYTHON_VERSION).tgz
470418
@echo ">>> Unpack and configure Python for $(target)"
471419
mkdir -p $$(PYTHON_DIR-$(target))
@@ -700,6 +648,13 @@ $$(BZIP2_XCFRAMEWORK-$(os)): $$(foreach sdk,$$(SDKS-$(os)),$$(BZIP2_FATLIB-$$(sd
700648

701649
BZip2-$(os): $$(BZIP2_XCFRAMEWORK-$(os))
702650

651+
clean-BZip2-$(os):
652+
@echo ">>> Clean BZip2 build products on $(os)"
653+
rm -rf build/$(os)/bzip2-$(BZIP2_VERSION)-* \
654+
build/$(os)/bzip2 \
655+
build/$(os)/bzip2-*.log \
656+
build/$(os)/Support/BZip2.xcframework
657+
703658
###########################################################################
704659
# Build: XZ (LZMA)
705660
###########################################################################
@@ -715,6 +670,13 @@ $$(XZ_XCFRAMEWORK-$(os)): $$(foreach sdk,$$(SDKS-$(os)),$$(XZ_FATLIB-$$(sdk)))
715670

716671
XZ-$(os): $$(XZ_XCFRAMEWORK-$(os))
717672

673+
clean-XZ-$(os):
674+
@echo ">>> Clean XZ build products on $(os)"
675+
rm -rf build/$(os)/xz-$(XZ_VERSION)-* \
676+
build/$(os)/xz \
677+
build/$(os)/xz-*.log \
678+
build/$(os)/Support/XZ.xcframework
679+
718680
###########################################################################
719681
# Build: OpenSSL
720682
###########################################################################
@@ -730,6 +692,13 @@ $$(OPENSSL_XCFRAMEWORK-$(os)): $$(foreach sdk,$$(SDKS-$(os)),$$(OPENSSL_FATLIB-$
730692

731693
OpenSSL-$(os): $$(OPENSSL_XCFRAMEWORK-$(os))
732694

695+
clean-OpenSSL-$(os):
696+
@echo ">>> Clean OpenSSL build products on $(os)"
697+
rm -rf build/$(os)/openssl-$(OPENSSL_VERSION)-* \
698+
build/$(os)/openssl \
699+
build/$(os)/openssl-*.log \
700+
build/$(os)/Support/OpenSSL.xcframework
701+
733702
###########################################################################
734703
# Build: libFFI
735704
###########################################################################
@@ -741,14 +710,15 @@ ifneq ($(os),macOS)
741710
LIBFFI_XCFRAMEWORK-$(os)=build/$(os)/Support/libFFI.xcframework
742711
LIBFFI_DIR-$(os)=build/$(os)/libffi-$(LIBFFI_VERSION)
743712

744-
$$(LIBFFI_DIR-$(os))/darwin_common/include/ffi.h: downloads/libffi-$(LIBFFI_VERSION).tgz
713+
$$(LIBFFI_DIR-$(os))/darwin_common/include/ffi.h: downloads/libffi-$(LIBFFI_VERSION).tgz $$(PYTHON_XCFRAMEWORK-macOS)
745714
@echo ">>> Unpack and configure libFFI sources on $(os)"
746715
mkdir -p $$(LIBFFI_DIR-$(os))
747716
tar zxf downloads/libffi-$(LIBFFI_VERSION).tgz --strip-components 1 -C $$(LIBFFI_DIR-$(os))
748717
# Patch the build to add support for new platforms
749718
cd $$(LIBFFI_DIR-$(os)) && patch -p1 < $(PROJECT_DIR)/patch/libffi.patch
750719
# Configure the build
751720
cd $$(LIBFFI_DIR-$(os)) && \
721+
PATH=$(PROJECT_DIR)/$(PYTHON_DIR-macOS)/_install/bin:$(PATH) \
752722
python$(PYTHON_VER) generate-darwin-source-and-headers.py --only-$(shell echo $(os) | tr '[:upper:]' '[:lower:]') \
753723
2>&1 | tee -a ../libffi-$(os).config.log
754724

@@ -759,9 +729,15 @@ $$(LIBFFI_XCFRAMEWORK-$(os)): $$(foreach sdk,$$(SDKS-$(os)),$$(LIBFFI_FATLIB-$$(
759729
-output $$@ $$(foreach sdk,$$(SDKS-$(os)),-library $$(LIBFFI_FATLIB-$$(sdk)) -headers $$(LIBFFI_DIR-$(os))/_install/$$(sdk)/include) \
760730
2>&1 | tee -a build/$(os)/libffi-$(os).xcframework.log
761731

732+
endif
733+
762734
libFFI-$(os): $$(LIBFFI_XCFRAMEWORK-$(os))
763735

764-
endif
736+
clean-libFFI-$(os):
737+
@echo ">>> Clean libFFI build products on $(os)"
738+
rm -rf build/$(os)/libffi-$(LIBFFI_VERSION) \
739+
build/$(os)/libffi-*.log \
740+
build/$(os)/Support/libFFI.xcframework
765741

766742

767743
###########################################################################
@@ -845,6 +821,27 @@ $$(PYTHON_XCFRAMEWORK-$(os)): $$(foreach sdk,$$(SDKS-$(os)),$$(PYTHON_FATLIB-$$(
845821

846822
Python-$(os): dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz
847823

824+
clean-Python-$(os):
825+
@echo ">>> Clean Python build products on $(os)"
826+
rm -rf \
827+
dist/Python-$(PYTHON_VER)-$(os) \
828+
build/$(os)/Python-$(PYTHON_VERSION)-* \
829+
build/$(os)/python \
830+
build/$(os)/python-*.log \
831+
build/$(os)/Support/Python.xcframework \
832+
build/$(os)/Support/Python
833+
834+
dev-clean-Python-$(os):
835+
@echo ">>> Partially clean Python build products on $(os) so that local code modifications can be made"
836+
rm -rf \
837+
dist/Python-$(PYTHON_VER)-$(os)-* \
838+
build/$(os)/Python-$(PYTHON_VERSION)-*/python.exe \
839+
build/$(os)/Python-$(PYTHON_VERSION)-*/_install \
840+
build/$(os)/python \
841+
build/$(os)/python-*.log \
842+
build/$(os)/Support/Python.xcframework \
843+
build/$(os)/Support/Python
844+
848845
###########################################################################
849846
# Build
850847
###########################################################################
@@ -907,12 +904,21 @@ endef # build
907904
# Dump environment variables (for debugging purposes)
908905
vars: $(foreach os,$(OS_LIST),vars-$(os))
909906

910-
# Expand cross-platform build targets for each output product
907+
# Expand cross-platform build and clean targets for each output product
911908
XZ: $(foreach os,$(OS_LIST),XZ-$(os))
909+
clean-XZ: $(foreach os,$(OS_LIST),clean-XZ-$(os))
910+
912911
BZip2: $(foreach os,$(OS_LIST),BZip2-$(os))
912+
clean-BZip2: $(foreach os,$(OS_LIST),clean-BZip2-$(os))
913+
913914
OpenSSL: $(foreach os,$(OS_LIST),OpenSSL-$(os))
915+
clean-OpenSSL: $(foreach os,$(OS_LIST),clean-OpenSSL-$(os))
916+
914917
libFFI: $(foreach os,$(OS_LIST),libFFI-$(os))
918+
clean-libFFI: $(foreach os,$(OS_LIST),clean-libFFI-$(os))
919+
915920
Python: $(foreach os,$(OS_LIST),Python-$(os))
921+
clean-Python: $(foreach os,$(OS_LIST),clean-Python-$(os) dev-clean-Python-$(os))
916922

917923
# Expand the build macro for every OS
918924
$(foreach os,$(OS_LIST),$(eval $(call build,$(os))))

0 commit comments

Comments
 (0)