1- TARGET_NAME = SQLyra
2- OUTPUD_DIR = ./Build
3- DERIVED_DATA_PATH = $(OUTPUD_DIR ) /DerivedData
1+ TARGET = SQLyra
2+ SNIPPETS := $(notdir $(basename $(wildcard Snippets/* .swift) ) )
43
5- .PHONY : clean lint format test test-macos test-ios test-linux
4+ .PHONY : clean lint format test-linux $( SNIPPETS ) test-snippets learn preview-doc
65
76clean :
87 swift package clean
9- rm -rf $(OUTPUD_DIR )
8+ rm -rf ./build
9+ rm -rf ./Snippets/db.sqlite
1010
1111README.md : Playgrounds/README.playground/Contents.swift
1212 cat $< | ./Scripts/markdown.swift > $@
@@ -19,60 +19,54 @@ lint:
1919format :
2020 xcrun swift-format --recursive --in-place ./
2121
22- # MARK: - Tests
22+ # MARK: - Apple Tests
2323
24- test :
25- swift test
24+ XCODEBUILD_TEST = xcodebuild test \
25+ -quiet \
26+ -scheme $(TARGET ) \
27+ -resultBundlePath $@
2628
27- test-macos : $(OUTPUD_DIR ) /test-macos.xcresult
28- test-ios : $(OUTPUD_DIR ) /test-ios.xcresult
29+ XCCOV = xcrun xccov view --files-for-target $(TARGET ) --report $@
2930
30- XCODEBUILD_TEST = xcodebuild test -quiet -scheme $(TARGET_NAME ) -resultBundlePath $@
31- XCCOV = xcrun xccov view --files-for-target $(TARGET_NAME ) --report $@
32-
33- $(OUTPUD_DIR ) /test-macos.xcresult :
31+ build/test-macos.xcresult :
3432 $(XCODEBUILD_TEST ) -destination ' platform=macOS'
3533 $(XCCOV )
3634
37- $( OUTPUD_DIR ) /test-ios.xcresult :
35+ build /test-ios.xcresult :
3836 $(XCODEBUILD_TEST ) -destination ' platform=iOS Simulator,name=iPhone 17'
3937 $(XCCOV )
4038
41- # Apple Containerization or Docker
39+ # MARK: - Linux Tests
40+
41+ # Apple Container or Docker
4242CONTAINER ?= container
4343
4444test-linux :
4545 $(CONTAINER ) run --rm -v " $( PWD) :/src" -w /src swift:latest /bin/bash -c \
4646 " apt-get update && apt-get install -y libsqlite3-dev && swift test"
4747
48- # MARK: - DocC
49-
50- DOCC_ARCHIVE = $(DERIVED_DATA_PATH ) /Build/Products/Debug/$(TARGET_NAME ) .doccarchive
48+ # MARK: - Snippets
5149
52- $(DOCC_ARCHIVE ) :
53- xcodebuild docbuild \
54- -quiet \
55- -scheme $(TARGET_NAME ) \
56- -destination " generic/platform=macOS" \
57- -derivedDataPath $(DERIVED_DATA_PATH )
50+ $(SNIPPETS ) :
51+ swift run --quiet $@
5852
59- $(OUTPUD_DIR ) /Docs : $(DOCC_ARCHIVE )
60- xcrun docc process-archive transform-for-static-hosting $^ \
61- --hosting-base-path $(TARGET_NAME ) \
62- --output-path $@
63-
64- # MARK: - DocC preview
53+ run-snippets : $(SNIPPETS )
6554
66- DOC_CATALOG = Sources/ $( TARGET_NAME ) / $( TARGET_NAME ) .docc
67- SYMBOL_GRAPHS = $( OUTPUD_DIR ) /symbol-graphs
55+ learn :
56+ SWIFTPM_ENABLE_SNIPPETS=1 swift package learn
6857
69- $(SYMBOL_GRAPHS ) :
70- swift build --target $(TARGET_NAME ) -Xswiftc -emit-symbol-graph -Xswiftc -emit-symbol-graph-dir -Xswiftc $@
58+ # MARK: - DocC
7159
72- $(OUTPUD_DIR ) /doc-preview : $(DOC_CATALOG ) $(SYMBOL_GRAPHS )
73- xcrun docc preview $(DOC_CATALOG ) \
74- --fallback-display-name $(TARGET_NAME ) \
75- --fallback-bundle-identifier org.swift.$(TARGET_NAME ) \
76- --fallback-bundle-version 1.0.0 \
77- --additional-symbol-graph-dir $(SYMBOL_GRAPHS ) \
60+ build/docs :
61+ env SQLYRA_DOCС_PLUGIN=1 \
62+ swift package --allow-writing-to-directory $@ \
63+ generate-documentation \
64+ --target $(TARGET ) \
65+ --transform-for-static-hosting \
66+ --hosting-base-path $(TARGET ) \
7867 --output-path $@
68+
69+ preview-doc :
70+ env SQLYRA_DOCС_PLUGIN=1 \
71+ swift package --disable-sandbox \
72+ preview-documentation --target $(TARGET )
0 commit comments