11# !make
22
3+ # Maintanence
4+ # The path and implemenet for OPENAPI_PATH.
5+ # The pattern and implemenet for TAG_NAMES.
6+
37# Special-Targets #
48# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
59.DEFAULT_GOAL := install
610OPENAPI_PATH := Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.yaml
711.SECONDARY : $(%.yml )
812
9- Submodule :
10- @echo " ::notice:: make $@ "
13+ Source/% /openapi.yml : $(OPENAPI_PATH )
14+ @ln -sf ../../$(OPENAPI_PATH ) $@
15+ @git add $@
16+ @echo " ::debug:: make $@ "
1117
1218TAG_NAMES := $(shell yq -r '.tags[].name' $(OPENAPI_PATH ) )
1319SUBDIRS := $(addprefix Sources/, $(TAG_NAMES ) )
1420OPENAPI_CONFIG_FILES := $(addsuffix /openapi-generator-config.yml, $(SUBDIRS ) )
15- % /openapi-generator-config.yml : Submodule
21+ % /openapi-generator-config.yml : $( OPENAPI_PATH )
1622 mkdir -p " $( @D) "
1723 @tag_name=$(shell basename $(shell dirname $@ ) ) ; \
1824 echo " generate:" > $@ ; \
@@ -28,31 +34,30 @@ OPENAPI_CONFIG_FILES := $(addsuffix /openapi-generator-config.yml, $(SUBDIRS))
2834 @git add $@
2935 @echo " ::debug:: make $@ "
3036
31- % /openapi.yml : % /openapi-generator-config.yml
32- @ln -sf ../../$(OPENAPI_PATH ) $@
33- @git add $@
34- @echo " ::debug:: make $@ "
35-
3637SWIFT_FILES := $(addsuffix /Client.swift, $(SUBDIRS ) )
37- % /Client.swift : % /openapi.yml Submodule
38+ % /Client.swift : % /openapi.yml % /openapi-generator-config.yml
3839 mint run apple/swift-openapi-generator generate $(@D ) /openapi.yml \
3940 --config $(@D ) /openapi-generator-config.yml \
4041 --output-directory $(@D )
4142 @git add $(@D )
42- @git commit -m " [Make] Sync *.swift" || true
43- @echo " ::debug:: make $@ "
43+ @git commit -m " [Make] Sync *.swift" > /dev/null \
44+ && echo " ::notice:: make $@ " \
45+ || true
4446
45- check-submodule : Submodule
47+ .PHONY : install-$(OPENAPI_PATH )
48+ install-$(OPENAPI_PATH ) :
4649ifdef GITHUB_ACTIONS ## https ://docs.github.com/en/actions/learn-github-actions/variables
4750 @echo " ::notice:: make $@ "
4851else
4952 git submodule update --recursive --remote
50- @git add $^
51- @git commit -m "[Make]$$(git submodule status Submodule/github/rest-api-description)" && touch $^ || true
52- @echo "::notice:: make $@"
53+ @git add Submodule
54+ @git commit -m "[Make]$$(git submodule status Submodule/github/rest-api-description)" >/dev/null \
55+ && touch $(OPENAPI_PATH) \
56+ && echo "::notice:: make $@" \
57+ || true
5358endif
5459
55- install : check-submodule $(SWIFT_FILES )
60+ install : install- $( OPENAPI_PATH ) $(SWIFT_FILES )
5661 @echo " ::notice:: make $@ "
5762
5863XCFrameworks :
@@ -76,7 +81,7 @@ install-zips: XCFrameworks
7681
7782.PHONY : update-to-date
7883update-to-date :
79- touch Submodule
84+ touch $( OPENAPI_PATH )
8085 touch Sources/** /openapi-generator-config.yml
8186 touch Sources/** /openapi.yml
8287 touch Sources/** /Client.swift
0 commit comments