33# Special-Targets #
44# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
55.DEFAULT_GOAL := install
6- SUBDIRS := $(wildcard Sources/* )
6+ OPENAPI_PATH := Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.yaml
7+ .SECONDARY : $(%.yml )
78
89.PHONY : force
910force :
@@ -14,28 +15,47 @@ Submodule: force
1415 git commit -m " [Make] Pull $$ (git submodule status Submodule/github/rest-api-description)" || true
1516 echo " ::notice:: make $@ "
1617
17- OPENAPI_FILES := $(addsuffix /openapi.yml, $(SUBDIRS ) )
18- % /openapi.yml : Submodule
19- ln -sf ../../Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.yaml $@
20- git add $@
18+ TAG_NAMES := $(shell yq -r '.tags[].name' $(OPENAPI_PATH ) )
19+ SUBDIRS := $(addprefix Sources/, $(TAG_NAMES ) )
20+ OPENAPI_CONFIG_FILES := $(addsuffix /openapi-generator-config.yml, $(SUBDIRS ) )
21+ % /openapi-generator-config.yml : Submodule
22+ mkdir -p " $( @D) "
23+ @tag_name=$(shell basename $(shell dirname $@ ) ) ; \
24+ echo " generate:" > $@ ; \
25+ echo " - types" >> $@ ; \
26+ echo " - client" >> $@ ; \
27+ echo " " >> $@ ; \
28+ echo " " >> $@ ; \
29+ echo " filter:" >> $@ ; \
30+ echo " tags:" >> $@ ; \
31+ echo " - $$ tag_name" >> $@ ; \
32+ echo " " >> $@ ; \
33+ echo " " >> $@ ; \
34+ echo " accessModifier: public" >> $@ ; \
35+ echo " " >> $@ ;
36+ # git add $@ # INTERMEDIATE file after *.swift
37+
38+ % /openapi.yml : % /openapi-generator-config.yml Submodule
39+ ln -sf ../../$(OPENAPI_PATH ) $@
40+ # git add $@ # INTERMEDIATE file after *.swift
2141
2242SWIFT_FILES := $(addsuffix /Client.swift, $(SUBDIRS ) )
23- % .swift : $( OPENAPI_FILES )
43+ % /Client .swift : % /openapi.yml
2444 mint run apple/swift-openapi-generator generate $(@D ) /openapi.yml \
25- --config $(@D ) /openapi-generator-config.yml \
26- --output-directory $(@D )
27- git add $@ $(@D ) /Types.swift
45+ --config $(@D ) /openapi-generator-config.yml \
46+ --output-directory $(@D )
47+ git add $(@D )
48+ git commit -m " [Make] Sync *.swift" || true
2849
29- install-files : $(SWIFT_FILES )
30- git commit -m " [Make] Re-link openapi.yml & re-gen swift files." || true
50+ install : $(SWIFT_FILES )
3151 echo " ::notice:: make $@ "
32-
52+
3353# XCFrameworks:
3454# mint run giginet/Scipio create . \
35- # --embed-debug-symbols \
36- # --support-simulators
55+ # --embed-debug-symbols \
56+ # --support-simulators
3757# echo "::notice:: make $@"
38- #
58+
3959# XCFRAMEWORKS := $(wildcard XCFrameworks/*.xcframework)
4060# ZIP_FILES := $(XCFRAMEWORKS:%.xcframework=%.zip)
4161# %.zip: %.xcframework
@@ -47,14 +67,12 @@ install-files: $(SWIFT_FILES)
4767# git commit -m "[Make] Re-gen framework zips" || true
4868# echo "::notice:: make $@"
4969
50- install : install-files
51-
52- .build/docs : # # Need env GITHUB_PAGES is created as 'true'
53- swift package --allow-writing-to-directory $@ generate-documentation \
54- --disable-indexing \
55- --output-path $@ \
56- --transform-for-static-hosting \
57- --hosting-base-path github-rest-api-swift-openapi;
70+ # .build/docs: ## Need env GITHUB_PAGES is created as 'true'
71+ # swift package --allow-writing-to-directory $@ generate-documentation \
72+ # --disable-indexing \
73+ # --output-path $@ \
74+ # --transform-for-static-hosting \
75+ # --hosting-base-path github-rest-api-swift-openapi;
5876
5977.PHONY : help
6078.SILENT : help
0 commit comments