Skip to content

Commit 0164ae3

Browse files
committed
Update Makefile
1 parent c7be756 commit 0164ae3

File tree

3 files changed

+27
-41
lines changed

3 files changed

+27
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## User settings
66
xcuserdata/
77
docs/
8+
openapi-generator-config.yml
89

910
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
1011
*.xcscmblueprint

Makefile

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,89 +5,73 @@
55
# [Special-Targets](https://www.gnu.org/software/make/manual/html_node/Special-Targets.html)
66
.DEFAULT_GOAL := install
77
OPENAPI_PATH := Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.json
8+
FILTERED_NAMES = $(shell jq -r '.tags[].name' $(OPENAPI_PATH))
9+
SOURCE_DIRS = $(addprefix Sources/, $(FILTERED_NAMES))
810
PACKAGE_PATHS := Package.swift
911

1012
## Helper
1113

1214
.SILENT: commit
1315
.PHONY: commit
1416
commit:
15-
@echo "::debug::[commit] start $(file)"
1617
git add "$(file)"
1718
git commit -m "Commit via running: make $(file)" >/dev/null \
18-
&& @echo "::notice:: git commit $(file)\n" \
19+
&& touch "$(file)" \
20+
&& echo "::notice::git commit $(file)" \
1921
|| true;
20-
touch "$(file)";
21-
@echo "::debug::[commit] end $(file)"
2222

2323
.PHONY: swift-openapi-generator
2424
swift-openapi-generator:
25-
@echo "::debug::[generator] setup swift-openapi-generator"
25+
@echo "::debug::make: $@"
2626
mise use spm:apple/swift-openapi-generator
2727

28-
## Create sources
28+
## Generate Sources
2929

30+
.INTERMEDIATE: %/openapi-generator-config.yml
3031
%/openapi-generator-config.yml:
31-
@echo "::debug::[config] start $(@D)"
32-
@mkdir -p "$(@D)"; \
33-
tag_name=$(shell basename $(shell dirname $@)); \
34-
@echo "::debug::[config] tag=$$tag_name"; \
32+
@echo ;
33+
@echo "::debug::make: $(@D)"
34+
mkdir -p "$(@D)"
35+
@echo "::debug::make: $@"
36+
tag_name=$(shell basename $(shell dirname $@)); \
3537
swift Scripts/GeneratorConfigBuilder.swift $$tag_name
36-
@echo "::debug::[config] end $(@D)"
3738

3839
.NOTPARALLEL: Submodule # Prevent submodule update from running in parallel with other jobs
3940
Submodule:
40-
@echo "::debug::[submodule] start"
41-
ifdef GITHUB_ACTIONS
42-
@echo "::debug::[submodule] CI mode skip update"
43-
else
44-
@echo "::debug::[submodule] updating"
41+
ifndef GITHUB_ACTIONS
42+
@echo "::debug::make: $@"
4543
@git submodule update --remote
4644
@$(MAKE) commit file="$@"
4745
endif
48-
@echo "::debug::[submodule] end"
46+
@echo ;
4947

5048
$(OPENAPI_PATH): Submodule
5149
@touch "$@"
5250

53-
%/Client.swift %/Types.swift: $(OPENAPI_PATH)
54-
@echo "::debug::[generate] start $(@D)"
55-
@echo "Folder $(@D) running"
56-
@$(MAKE) "$(@D)/openapi-generator-config.yml"
57-
@echo "::debug::[generate] running openapi-generator"
51+
%/Client.swift %/Types.swift: $(OPENAPI_PATH) %/openapi-generator-config.yml
52+
@echo "::debug::make: $@"
5853
swift-openapi-generator generate \
5954
"$(OPENAPI_PATH)" \
6055
--config "$(@D)/openapi-generator-config.yml" \
6156
--output-directory "$(@D)";
62-
@echo "::debug::[generate] finished openapi-generator"
63-
@touch $(@D)/*.swift
64-
@rm "$(@D)/openapi-generator-config.yml";
65-
@echo ;
66-
@echo "::debug::[generate] end $(@D)"
6757

6858
Sources/%: Sources/%/Client.swift Sources/%/Types.swift
69-
@echo "::debug::[target] build $@"
7059
@$(MAKE) commit file="$@"
7160

72-
.DELETE_ON_ERROR: Sources
73-
Sources: $(OPENAPI_PATH)
74-
@echo "::debug::[sources] start"
75-
@names=$$(swift Scripts/PackageTargetsParser.swift $(OPENAPI_PATH)); \
76-
$(MAKE) $$(printf "Sources/%s " $$names)
77-
@echo "::debug::[sources] end"
78-
79-
$(PACKAGE_PATHS): Sources
80-
@echo "::debug::[package] start Package.swift"
61+
$(PACKAGE_PATHS): $(SOURCE_DIRS)
62+
@echo "::debug::make: $@"
8163
swift Scripts/PackageBuilder.swift "$@"
8264
@$(MAKE) commit file="$@"
83-
@echo "::debug::[package] end Package.swift"
8465

8566
.spi.yml: $(PACKAGE_PATHS)
86-
@echo "::debug::[spi] start"
67+
@echo "::debug::make: $@"
8768
swift Scripts/SPIManifestBuilder.swift
8869
@$(MAKE) commit file="$@"
89-
@echo "::debug::[spi] end"
9070

91-
## Install
71+
## main
9272

9373
install: .spi.yml
74+
75+
update:
76+
$(MAKE) -B Submodule
77+
$(MAKE) install

mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tools]
22
swift = "6"
33
"spm:apple/swift-openapi-generator" = "latest"
4+
jq = "1.8.1"
45

56
[settings]
67
experimental = true

0 commit comments

Comments
 (0)