|
5 | 5 | # [Special-Targets](https://www.gnu.org/software/make/manual/html_node/Special-Targets.html) |
6 | 6 | .DEFAULT_GOAL := install |
7 | 7 | 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)) |
8 | 10 | PACKAGE_PATHS := Package.swift |
9 | 11 |
|
10 | 12 | ## Helper |
11 | 13 |
|
12 | 14 | .SILENT: commit |
13 | 15 | .PHONY: commit |
14 | 16 | commit: |
15 | | - @echo "::debug::[commit] start $(file)" |
16 | 17 | git add "$(file)" |
17 | 18 | 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)" \ |
19 | 21 | || true; |
20 | | - touch "$(file)"; |
21 | | - @echo "::debug::[commit] end $(file)" |
22 | 22 |
|
23 | 23 | .PHONY: swift-openapi-generator |
24 | 24 | swift-openapi-generator: |
25 | | - @echo "::debug::[generator] setup swift-openapi-generator" |
| 25 | + @echo "::debug::make: $@" |
26 | 26 | mise use spm:apple/swift-openapi-generator |
27 | 27 |
|
28 | | -## Create sources |
| 28 | +## Generate Sources |
29 | 29 |
|
| 30 | +.INTERMEDIATE: %/openapi-generator-config.yml |
30 | 31 | %/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 $@)); \ |
35 | 37 | swift Scripts/GeneratorConfigBuilder.swift $$tag_name |
36 | | - @echo "::debug::[config] end $(@D)" |
37 | 38 |
|
38 | 39 | .NOTPARALLEL: Submodule # Prevent submodule update from running in parallel with other jobs |
39 | 40 | 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: $@" |
45 | 43 | @git submodule update --remote |
46 | 44 | @$(MAKE) commit file="$@" |
47 | 45 | endif |
48 | | - @echo "::debug::[submodule] end" |
| 46 | + @echo ; |
49 | 47 |
|
50 | 48 | $(OPENAPI_PATH): Submodule |
51 | 49 | @touch "$@" |
52 | 50 |
|
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: $@" |
58 | 53 | swift-openapi-generator generate \ |
59 | 54 | "$(OPENAPI_PATH)" \ |
60 | 55 | --config "$(@D)/openapi-generator-config.yml" \ |
61 | 56 | --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)" |
67 | 57 |
|
68 | 58 | Sources/%: Sources/%/Client.swift Sources/%/Types.swift |
69 | | - @echo "::debug::[target] build $@" |
70 | 59 | @$(MAKE) commit file="$@" |
71 | 60 |
|
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: $@" |
81 | 63 | swift Scripts/PackageBuilder.swift "$@" |
82 | 64 | @$(MAKE) commit file="$@" |
83 | | - @echo "::debug::[package] end Package.swift" |
84 | 65 |
|
85 | 66 | .spi.yml: $(PACKAGE_PATHS) |
86 | | - @echo "::debug::[spi] start" |
| 67 | + @echo "::debug::make: $@" |
87 | 68 | swift Scripts/SPIManifestBuilder.swift |
88 | 69 | @$(MAKE) commit file="$@" |
89 | | - @echo "::debug::[spi] end" |
90 | 70 |
|
91 | | -## Install |
| 71 | +## main |
92 | 72 |
|
93 | 73 | install: .spi.yml |
| 74 | + |
| 75 | +update: |
| 76 | + $(MAKE) -B Submodule |
| 77 | + $(MAKE) install |
0 commit comments