forked from Actomaton/Actomaton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
106 lines (84 loc) · 5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M])
PLATFORM_MACOS = macOS
PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS,TV)
PLATFORM_VISIONOS = visionOS Simulator,id=$(call udid_for,visionOS,Vision)
PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS,Watch)
TEST_MAIN_ACTOR = 1
# Base path after host name, required for GitHub Pages.
# Note that `documentation/{module_name}` is automatically added to the end of this path in Swift-DocC,
# e.g. https://actomaton.github.io/Actomaton/documentation/actomatonui/ .
DOC_HOSTING_BASE_PATH := /Actomaton
DOCBUILD_BUILD_DIR := .docbuild
DOCBUILD_PRODUCT_DIR := $(DOCBUILD_BUILD_DIR)/Build/Products/Debug-iphonesimulator
DOCBUILD_OUTPUT_DIR := docbuild
# e.g. `make xcode-build OS=iOS`
.PHONY: xcode-build
xcode-build:
$(MAKE) _xcode ACTION="clean build"
# e.g. `make xcode-test OS=iOS`
# WARNING: Swift Concurrency does not work well on GitHub Actions Mac runners.
.PHONY: xcode-test
xcode-test:
$(MAKE) _xcode ACTION="clean build test"
.PHONY: _xcode
_xcode:
set -o pipefail && TEST_MAIN_ACTOR=$(TEST_MAIN_ACTOR) xcodebuild $(ACTION) -scheme Actomaton-Package -destination 'platform=$(PLATFORM_$(shell echo $(OS) | tr '[:lower:]' '[:upper:]'))' | xcpretty
.PHONY: swift-test
swift-test:
TEST_MAIN_ACTOR=$(TEST_MAIN_ACTOR) swift test
#--------------------------------------------------
# DocC
#--------------------------------------------------
.PHONY: docs
docs:
$(MAKE) _docs DOC_HOSTING_BASE_PATH=$(DOC_HOSTING_BASE_PATH)
.PHONY: docs-local
docs-local:
@# NOTE: `DOC_HOSTING_BASE_PATH=/` is only for local viewer, and does not work for GitHub Pages.
$(MAKE) _docs DOC_HOSTING_BASE_PATH=/
#--------------------------------------------------
# Open http://localhost:8000/documentation
#--------------------------------------------------
python3 -m http.server 8000 -d docbuild
# NOTE:
# `xcodebuild docbuild` allows spcifying iOS platform and generates dependency's doccarchives.
# https://forums.swift.org/t/generate-documentation-failing-on-import-uikit/55202/7
#
# NOTE: This task may fail once (Error 65), so in such case, retry.
.PHONY: _docs
_docs:
@# Clean up.
rm -rf $(DOCBUILD_BUILD_DIR) $(DOCBUILD_OUTPUT_DIR)
xcodebuild docbuild \
-scheme ActomatonUI \
-destination 'platform=iOS Simulator,name=iPhone 15 Pro' \
-derivedDataPath $(DOCBUILD_BUILD_DIR) \
OTHER_DOCC_FLAGS="--transform-for-static-hosting --hosting-base-path $(DOC_HOSTING_BASE_PATH)" \
EXTRA_DOCC_FLAGS="--transform-for-static-hosting --hosting-base-path $(DOC_HOSTING_BASE_PATH)"
@#--------------------------------------------------
@# (Immaturely) gathering multiple doccarchives
@#--------------------------------------------------
@# Delete unnecessary DB files.
find "$(DOCBUILD_PRODUCT_DIR)/Actomaton.doccarchive/index" -type f ! -name "index.json" -exec rm -f {} +
find "$(DOCBUILD_PRODUCT_DIR)/ActomatonDebugging.doccarchive/index" -type f ! -name "index.json" -exec rm -f {} +
find "$(DOCBUILD_PRODUCT_DIR)/ActomatonUI.doccarchive/index" -type f ! -name "index.json" -exec rm -f {} +
@# Copy `ActomatonUI.doccarchive` to output_dir.
cp -Rf $(DOCBUILD_PRODUCT_DIR)/ActomatonUI.doccarchive $(DOCBUILD_OUTPUT_DIR)
@# Gather each module's `index/index.json` into output_dir's `./index/index-xxxxx.json`.
jq . "$(DOCBUILD_PRODUCT_DIR)/Actomaton.doccarchive/index/index.json" > $(DOCBUILD_OUTPUT_DIR)/index/index-actomaton.json
jq . "$(DOCBUILD_PRODUCT_DIR)/ActomatonDebugging.doccarchive/index/index.json" > $(DOCBUILD_OUTPUT_DIR)/index/index-actomatondebugging.json
jq . "$(DOCBUILD_PRODUCT_DIR)/ActomatonUI.doccarchive/index/index.json" > $(DOCBUILD_OUTPUT_DIR)/index/index-actomatonui.json
@# Merge each module's `index-xxxxx.json`s into a single `index.json`.
jq -s '.[0].schemaVersion as $$schemaVersion | .[0].interfaceLanguages.swift[0] as $$file1 | .[1].interfaceLanguages.swift[0] as $$file2 | .[2].interfaceLanguages.swift[0] as $$file3 | { "interfaceLanguages": { "swift": [$$file1, $$file2, $$file3], "schemaVersion": $$schemaVersion } }' $(DOCBUILD_OUTPUT_DIR)/index/index-actomaton.json $(DOCBUILD_OUTPUT_DIR)/index/index-actomatondebugging.json $(DOCBUILD_OUTPUT_DIR)/index/index-actomatonui.json > $(DOCBUILD_OUTPUT_DIR)/index/index.json
@# Gather each module's `./data/documentation` into output_dir.
cp -rf $(DOCBUILD_PRODUCT_DIR)/Actomaton.doccarchive/data/documentation/* $(DOCBUILD_OUTPUT_DIR)/data/documentation/
cp -rf $(DOCBUILD_PRODUCT_DIR)/ActomatonDebugging.doccarchive/data/documentation/* $(DOCBUILD_OUTPUT_DIR)/data/documentation/
@# Gather each module's `./documentation` into output_dir.
cp -rf $(DOCBUILD_PRODUCT_DIR)/Actomaton.doccarchive/documentation/* $(DOCBUILD_OUTPUT_DIR)/documentation/
cp -rf $(DOCBUILD_PRODUCT_DIR)/ActomatonDebugging.doccarchive/documentation/* $(DOCBUILD_OUTPUT_DIR)/documentation/
@# Clean up.
rm -rf $(DOCBUILD_BUILD_DIR)
define udid_for
$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')
endef