|
1 | 1 | #!make |
2 | | -# Special-Targets |
3 | | -# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html |
4 | 2 |
|
5 | | -# Variables |
| 3 | +## Variables |
| 4 | + |
| 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 swift Scripts/PackageTargetsParser.swift $(OPENAPI_PATH)) |
9 | | -SOURCE_DIRS := $(addprefix Sources/, $(FILTERED_NAMES)) |
10 | 8 | PACKAGE_PATHS := Package.swift |
11 | 9 |
|
12 | | -# Helper |
| 10 | +## Helper |
| 11 | + |
13 | 12 | .SILENT: commit |
14 | 13 | .PHONY: commit |
15 | 14 | commit: |
| 15 | + echo "::debug::[commit] start $(file)" |
16 | 16 | git add "$(file)" |
17 | 17 | git commit -m "Commit via running: make $(file)" >/dev/null \ |
18 | 18 | && echo "::notice:: git commit $(file)\n" \ |
19 | 19 | || true; |
20 | 20 | touch "$(file)"; |
| 21 | + echo "::debug::[commit] end $(file)" |
21 | 22 |
|
| 23 | +.PHONY: swift-openapi-generator |
22 | 24 | swift-openapi-generator: |
| 25 | + echo "::debug::[generator] setup swift-openapi-generator" |
23 | 26 | mise use spm:apple/swift-openapi-generator |
24 | 27 |
|
25 | | -# Create sources |
| 28 | +## Create sources |
| 29 | + |
26 | 30 | %/openapi-generator-config.yml: |
| 31 | + echo "::debug::[config] start $(@D)" |
27 | 32 | @mkdir -p "$(@D)"; \ |
28 | 33 | tag_name=$(shell basename $(shell dirname $@)); \ |
| 34 | + echo "::debug::[config] tag=$$tag_name"; \ |
29 | 35 | swift Scripts/GeneratorConfigBuilder.swift $$tag_name |
| 36 | + echo "::debug::[config] end $(@D)" |
30 | 37 |
|
31 | 38 | %/Client.swift %/Types.swift: $(OPENAPI_PATH) |
| 39 | + echo "::debug::[generate] start $(@D)" |
32 | 40 | @echo "\n\nFolder $(@D) running" |
33 | 41 | @$(MAKE) "$(@D)/openapi-generator-config.yml" |
| 42 | + echo "::debug::[generate] running openapi-generator" |
34 | 43 | swift-openapi-generator generate \ |
35 | 44 | "$(OPENAPI_PATH)" \ |
36 | 45 | --config "$(@D)/openapi-generator-config.yml" \ |
37 | 46 | --output-directory "$(@D)"; |
| 47 | + echo "::debug::[generate] finished openapi-generator" |
38 | 48 | @touch $(@D)/*.swift |
39 | 49 | @rm "$(@D)/openapi-generator-config.yml"; |
40 | 50 | @echo ; |
| 51 | + echo "::debug::[generate] end $(@D)" |
41 | 52 |
|
42 | 53 | Sources/%: Sources/%/Client.swift Sources/%/Types.swift |
| 54 | + echo "::debug::[target] build $@" |
43 | 55 | @$(MAKE) commit file="$@" |
44 | 56 |
|
45 | | -# Prevent submodule update from running in parallel with other jobs |
46 | | -.NOTPARALLEL: Submodule |
47 | | - |
48 | | -# Update openapi specification if needed |
49 | | -.PHONY: Submodule |
50 | | -Submodule: |
51 | | -ifdef GITHUB_ACTIONS ## https://docs.github.com/en/actions/learn-github-actions/variables |
52 | | - @touch "$(OPENAPI_PATH)" |
53 | | -else |
54 | | - @git submodule update --remote |
55 | | - @$(MAKE) commit file="$@" |
56 | | - # @touch "$(OPENAPI_PATH)" # Uncomment to force-install |
57 | | -endif |
| 57 | +FILTERED_NAMES = $(shell \ |
| 58 | + echo "::debug::[parse] start PackageTargetsParser"; \ |
| 59 | + swift Scripts/PackageTargetsParser.swift $(OPENAPI_PATH); \ |
| 60 | + echo "::debug::[parse] end PackageTargetsParser"; \ |
| 61 | +) |
| 62 | +SOURCE_DIRS := $(addprefix Sources/, $(FILTERED_NAMES)) |
58 | 63 |
|
59 | | -# Update Package.swift |
60 | 64 | .DELETE_ON_ERROR: $(SOURCE_DIRS) |
61 | 65 | $(PACKAGE_PATHS): $(SOURCE_DIRS) |
| 66 | + echo "::debug::[package] start Package.swift" |
62 | 67 | swift Scripts/PackageBuilder.swift "$@" |
63 | 68 | @$(MAKE) commit file="$@" |
| 69 | + echo "::debug::[package] end Package.swift" |
64 | 70 |
|
65 | 71 | .spi.yml: $(PACKAGE_PATHS) |
| 72 | + echo "::debug::[spi] start" |
66 | 73 | swift Scripts/SPIManifestBuilder.swift |
67 | 74 | @$(MAKE) commit file="$@" |
| 75 | + echo "::debug::[spi] end" |
| 76 | + |
| 77 | +.PHONY: Submodule # Update openapi specification if needed |
| 78 | +.NOTPARALLEL: Submodule # Prevent submodule update from running in parallel with other jobs |
| 79 | +Submodule: |
| 80 | + echo "::debug::[submodule] start" |
| 81 | +ifdef GITHUB_ACTIONS |
| 82 | + echo "::debug::[submodule] CI mode skip update" |
| 83 | + @touch "$(OPENAPI_PATH)" |
| 84 | +else |
| 85 | + echo "::debug::[submodule] updating" |
| 86 | + @git submodule update --remote |
| 87 | + @$(MAKE) commit file="$@" |
| 88 | +endif |
| 89 | + echo "::debug::[submodule] end" |
| 90 | + |
| 91 | +## Install |
68 | 92 |
|
69 | | -# Install |
70 | 93 | install: Submodule .spi.yml |
0 commit comments