blob: 6465fa30abc808d153558df2b09618c82be636d8 [file] [log] [blame]
Erik Doernenburgbf30e692020-12-22 00:35:24 +01001# This makefile has the following top-level targets:
2# - ci used by Travis for continuous integration
3# - dist used to build the binary distribution
4#
Erik Doernenburg7438b182020-12-23 19:50:10 +01005# Note that the dist target uses git checkout to copy the source into the
Erik Doernenburg826310b2021-10-16 14:12:39 +02006# product directory. This means you should make sure that you don't have
Erik Doernenburg7438b182020-12-23 19:50:10 +01007# uncommited local changes when building a distribution.
Erik Doernenburg4fe18e92014-08-28 11:11:19 +02008
Erik Doernenburg7438b182020-12-23 19:50:10 +01009BUILD_DIR = $(CURDIR)/Build
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020010ARCHIVE_DIR = $(BUILD_DIR)/Archives
Erik Doernenburg7438b182020-12-23 19:50:10 +010011PRODUCT_DIR = $(BUILD_DIR)/Product
Erik Doernenburg826310b2021-10-16 14:12:39 +020012SOURCE_DIR = $(CURDIR)/Source
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020013FWK_PATH = /Products/Library/Frameworks/OCMock.framework
Erik Doernenburg826310b2021-10-16 14:12:39 +020014XCODECI = xcodebuild -project "$(SOURCE_DIR)/OCMock.xcodeproj" -xcconfig "$(SOURCE_DIR)/OCMockCI.xcconfig" -destination-timeout 600
15XCODEDIST = xcodebuild -project "$(SOURCE_DIR)/OCMock.xcodeproj" -xcconfig "$(SOURCE_DIR)/OCMockDist.xcconfig"
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020016XCODEXCF = xcodebuild
Erik Doernenburg7438b182020-12-23 19:50:10 +010017SHELL = /bin/bash -e -o pipefail
Maksym Shcheglovb7261342014-08-26 00:52:50 +020018
Maksym Koshtenko120308c2022-07-27 17:22:22 +010019.PHONY: macos ioslib ios catalyst tvos watchos buildcheck archives xcframework sourcecode ci-swiftpm carthage
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020020
Erik Doernenburg826310b2021-10-16 14:12:39 +020021
Maksym Shcheglovb7261342014-08-26 00:52:50 +020022clean:
Erik Doernenburg826310b2021-10-16 14:12:39 +020023 rm -rf "$(BUILD_DIR)"
24 rm -rf "$(SOURCE_DIR)/Carthage"
Maksym Shcheglovb7261342014-08-26 00:52:50 +020025
Maksym Shcheglovb7261342014-08-26 00:52:50 +020026
Erik Doernenburg826310b2021-10-16 14:12:39 +020027ci: ci-macos ci-ios ci-swiftpm
Maksym Shcheglovb7261342014-08-26 00:52:50 +020028
Erik Doernenburgbf30e692020-12-22 00:35:24 +010029ci-macos:
30 @echo "Building macOS framework and running tests..."
Erik Doernenburg939039f2021-10-26 22:13:38 +020031 $(XCODECI) -scheme OCMock -destination 'platform=macOS' test | xcpretty -c
Erik Doernenburgbf30e692020-12-22 00:35:24 +010032
33ci-ios:
34 @echo "Building iOS library and running tests..."
Erik Doernenburg7a5f2332023-10-03 23:18:28 +020035 $(XCODECI) -scheme OCMockLib -destination 'platform=iOS Simulator,OS=latest,name=iPhone 15' test | xcpretty -c
Erik Doernenburgbf30e692020-12-22 00:35:24 +010036
37
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020038dist: archives xcframework sourcecode dmg
Erik Doernenburg826310b2021-10-16 14:12:39 +020039
Erik Doernenburg7438b182020-12-23 19:50:10 +010040macos:
Erik Doernenburgbf30e692020-12-22 00:35:24 +010041 @echo "** Building macOS framework..."
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020042 $(XCODEDIST) archive -scheme OCMock -destination 'generic/platform=macOS' -archivePath $(ARCHIVE_DIR)/OCMock-macOS | xcpretty -c
Erik Doernenburg826310b2021-10-16 14:12:39 +020043
Erik Doernenburg7438b182020-12-23 19:50:10 +010044ioslib:
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020045 @echo "** Building iOS libraries..."
46 $(XCODEDIST) archive -scheme OCMockLib -destination 'generic/platform=iOS' -archivePath $(ARCHIVE_DIR)/OCMock-iOS-lib | xcpretty -c
47 $(XCODEDIST) archive -scheme OCMockLib -destination 'generic/platform=iOS Simulator' -archivePath $(ARCHIVE_DIR)/OCMock-iOS-lib-sim | xcpretty -c
Erik Doernenburgbf30e692020-12-22 00:35:24 +010048
Erik Doernenburg7438b182020-12-23 19:50:10 +010049ios:
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020050 @echo "** Building iOS frameworks..."
51 $(XCODEDIST) archive -scheme "OCMock iOS" -destination 'generic/platform=iOS' -archivePath $(ARCHIVE_DIR)/OCMock-iOS | xcpretty -c
52 $(XCODEDIST) archive -scheme "OCMock iOS" -destination 'generic/platform=iOS Simulator' -archivePath $(ARCHIVE_DIR)/OCMock-iOS-sim | xcpretty -c
Erik Doernenburgbf30e692020-12-22 00:35:24 +010053
Maksym Koshtenko120308c2022-07-27 17:22:22 +010054catalyst:
55 @echo "** Building Mac Catalyst framework..."
56 $(XCODEDIST) archive -scheme "OCMock iOS" -destination 'generic/platform=macOS,variant=Mac Catalyst' -archivePath $(ARCHIVE_DIR)/OCMock-catalyst | xcpretty -c
57
Erik Doernenburg7438b182020-12-23 19:50:10 +010058tvos:
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020059 @echo "** Building tvOS frameworks..."
60 $(XCODEDIST) archive -scheme "OCMock tvOS" -destination 'generic/platform=tvOS' -archivePath $(ARCHIVE_DIR)/OCMock-tvOS | xcpretty -c
61 $(XCODEDIST) archive -scheme "OCMock tvOS" -destination 'generic/platform=tvOS Simulator' -archivePath $(ARCHIVE_DIR)/OCMock-tvOS-sim | xcpretty -c
Erik Doernenburg826310b2021-10-16 14:12:39 +020062
Erik Doernenburg7438b182020-12-23 19:50:10 +010063watchos:
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020064 @echo "** Building watchOS frameworks..."
65 $(XCODEDIST) archive -scheme "OCMock watchOS" -destination 'generic/platform=watchOS' -archivePath $(ARCHIVE_DIR)/OCMock-watchOS | xcpretty -c
66 $(XCODEDIST) archive -scheme "OCMock watchOS" -destination 'generic/platform=watchOS Simulator' -archivePath $(ARCHIVE_DIR)/OCMock-watchOS-sim | xcpretty -c
67
68buildcheck:
69 @echo "** Verifying archives..."
70 Tools/buildcheck.rb $(ARCHIVE_DIR)
71
Maksym Koshtenko120308c2022-07-27 17:22:22 +010072archives: macos ioslib ios catalyst tvos watchos buildcheck
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020073
74xcframework:
75 @echo "** Creating XCFrameworks..."
76 rm -rf $(PRODUCT_DIR)/OCMock.xcframework
77 $(XCODEXCF) -create-xcframework -output $(PRODUCT_DIR)/OCMock.xcframework \
Maksym Koshtenko120308c2022-07-27 17:22:22 +010078 -framework $(ARCHIVE_DIR)/OCMock-catalyst.xcarchive$(FWK_PATH) \
Erik Doernenburg7c0b4652021-10-26 21:02:00 +020079 -framework $(ARCHIVE_DIR)/OCMock-macOS.xcarchive$(FWK_PATH) \
80 -framework $(ARCHIVE_DIR)/OCMock-iOS.xcarchive$(FWK_PATH) \
81 -framework $(ARCHIVE_DIR)/OCMock-iOS-sim.xcarchive$(FWK_PATH) \
82 -framework $(ARCHIVE_DIR)/OCMock-tvOS.xcarchive$(FWK_PATH) \
83 -framework $(ARCHIVE_DIR)/OCMock-tvOS-sim.xcarchive$(FWK_PATH) \
84 -framework $(ARCHIVE_DIR)/OCMock-watchOS.xcarchive$(FWK_PATH) \
85 -framework $(ARCHIVE_DIR)/OCMock-watchOS-sim.xcarchive$(FWK_PATH)
86 rm -rf $(PRODUCT_DIR)/libOCMock.xcframework
87 $(XCODEXCF) -create-xcframework -output $(PRODUCT_DIR)/libOCMock.xcframework \
88 -library $(ARCHIVE_DIR)/OCMock-iOS-lib.xcarchive/Products/usr/local/lib/libOCMock.a -headers $(ARCHIVE_DIR)/OCMock-iOS-lib.xcarchive/Products/usr/local/lib/OCMock \
89 -library $(ARCHIVE_DIR)/OCMock-iOS-lib-sim.xcarchive/Products/usr/local/lib/libOCMock.a -headers $(ARCHIVE_DIR)/OCMock-iOS-lib-sim.xcarchive/Products/usr/local/lib/OCMock
90
Erik Doernenburg826310b2021-10-16 14:12:39 +020091
Erik Doernenburg7438b182020-12-23 19:50:10 +010092sourcecode:
93 @echo "** Checking out source code..."
94 mkdir -p "$(PRODUCT_DIR)"
95 git archive master | tar -x -C "$(PRODUCT_DIR)" Source
Erik Doernenburgbf30e692020-12-22 00:35:24 +010096
Erik Doernenburg826310b2021-10-16 14:12:39 +020097dmg:
Erik Doernenburgbf30e692020-12-22 00:35:24 +010098 @echo "** Creating disk image..."
Erik Doernenburg7438b182020-12-23 19:50:10 +010099 Tools/makedmg.rb $(PRODUCT_DIR) $(BUILD_DIR)
Erik Doernenburg4a49ebb2020-12-30 18:30:57 +0100100
101
Erik Doernenburg826310b2021-10-16 14:12:39 +0200102ci-swiftpm:
103 @echo "** Testing Swift Package Manager Distribution"
104 rm -rf $(SOURCE_DIR)/Carthage
Erik Doernenburg7261b392021-05-11 18:11:19 +0200105 swift build
106 swift test
107
108
Erik Doernenburg4a49ebb2020-12-30 18:30:57 +0100109carthage:
Erik Doernenburgef21a2e2021-10-26 22:26:40 +0200110 carthage build --project-directory "$(SOURCE_DIR)" --no-skip-current --use-xcframeworks