3
3
# Special-Targets #
4
4
# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
5
5
.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 )
7
8
8
9
.PHONY : force
9
10
force :
@@ -14,28 +15,47 @@ Submodule: force
14
15
git commit -m " [Make] Pull $$ (git submodule status Submodule/github/rest-api-description)" || true
15
16
echo " ::notice:: make $@ "
16
17
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
21
41
22
42
SWIFT_FILES := $(addsuffix /Client.swift, $(SUBDIRS ) )
23
- % .swift : $( OPENAPI_FILES )
43
+ % /Client .swift : % /openapi.yml
24
44
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
28
49
29
- install-files : $(SWIFT_FILES )
30
- git commit -m " [Make] Re-link openapi.yml & re-gen swift files." || true
50
+ install : $(SWIFT_FILES )
31
51
echo " ::notice:: make $@ "
32
-
52
+
33
53
# XCFrameworks:
34
54
# mint run giginet/Scipio create . \
35
- # --embed-debug-symbols \
36
- # --support-simulators
55
+ # --embed-debug-symbols \
56
+ # --support-simulators
37
57
# echo "::notice:: make $@"
38
- #
58
+
39
59
# XCFRAMEWORKS := $(wildcard XCFrameworks/*.xcframework)
40
60
# ZIP_FILES := $(XCFRAMEWORKS:%.xcframework=%.zip)
41
61
# %.zip: %.xcframework
@@ -47,14 +67,12 @@ install-files: $(SWIFT_FILES)
47
67
# git commit -m "[Make] Re-gen framework zips" || true
48
68
# echo "::notice:: make $@"
49
69
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;
58
76
59
77
.PHONY : help
60
78
.SILENT : help
0 commit comments