-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (71 loc) · 2.43 KB
/
Makefile
File metadata and controls
88 lines (71 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!make
## Variables
# [Special-Targets](https://www.gnu.org/software/make/manual/html_node/Special-Targets.html)
.DEFAULT_GOAL := install
OPENAPI_PATH := Submodule/github/rest-api-description/descriptions/api.github.com/api.github.com.json
FILTERED_NAMES = $(shell swift Scripts/PackageTargetsParser.swift $(OPENAPI_PATH))
SOURCE_DIRS = $(addprefix Sources/, $(FILTERED_NAMES))
PACKAGE_PATHS := Package.swift
## Helper
.SILENT: commit
.PHONY: commit
commit:
git add "$(file)"
git commit -m "Commit via running: make $(file)" >/dev/null \
&& touch "$(file)" \
&& echo "::notice::git commit $(file)" \
|| true;
.INTERMEDIATE: swift-openapi-generator/.build/release/swift-openapi-generator
swift-openapi-generator/.build/release/swift-openapi-generator:
@echo "::debug::make: $@"
git clone --branch 1.11.0 --single-branch \
https://github.com/apple/swift-openapi-generator
cd swift-openapi-generator; \
swift build -c release --product swift-openapi-generator
.NOTPARALLEL: .build/bin/swift-openapi-generator
.build/bin/swift-openapi-generator: swift-openapi-generator/.build/release/swift-openapi-generator
@echo "::debug::make: $@"
mkdir -p $(@D)
cp -f $^ $@
touch $@
rm -rf swift-openapi-generator
## Generate Sources
.INTERMEDIATE: %/openapi-generator-config.yml
%/openapi-generator-config.yml:
@echo ;
@echo "::debug::make: $(@D)"
mkdir -p "$(@D)"
@echo "::debug::make: $@"
tag_name=$(shell basename $(shell dirname $@)); \
swift Scripts/GeneratorConfigBuilder.swift $$tag_name
.NOTPARALLEL: Submodule # Prevent submodule update from running in parallel with other jobs
Submodule:
ifndef GITHUB_ACTIONS
@echo "::debug::make: $@"
@git submodule update --remote
@$(MAKE) commit file="$@"
endif
@echo ;
$(OPENAPI_PATH): Submodule
@touch "$@"
%/Client.swift %/Types.swift: $(OPENAPI_PATH) %/openapi-generator-config.yml .build/bin/swift-openapi-generator
@echo "::debug::make: $@"
.build/bin/swift-openapi-generator generate \
"$(OPENAPI_PATH)" \
--config "$(@D)/openapi-generator-config.yml" \
--output-directory "$(@D)";
Sources/%: Sources/%/Client.swift Sources/%/Types.swift
@$(MAKE) commit file="$@"
$(PACKAGE_PATHS): $(SOURCE_DIRS)
@echo "::debug::make: $@"
swift Scripts/PackageBuilder.swift "$@"
@$(MAKE) commit file="$@"
.spi.yml: $(PACKAGE_PATHS)
@echo "::debug::make: $@"
swift Scripts/SPIManifestBuilder.swift
@$(MAKE) commit file="$@"
## main
install: .spi.yml
update:
$(MAKE) -B Submodule
$(MAKE) install