-
Notifications
You must be signed in to change notification settings - Fork 3
/
generate.mk
executable file
·114 lines (85 loc) · 3.15 KB
/
generate.mk
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/make -f
###############################################################################
# NAME: generate.mk
#
# AUTHOR: Ethan D. Twardy <[email protected]>
#
# DESCRIPTION: Generate the sources from an OpenAPI document.
#
# CREATED: 01/29/2023
#
# LAST EDITED: 06/25/2023
#
####
RELEASE_LINK=https://www.dmtf.org/sites/default/files/standards/documents
REDFISH_VERSION=2024.2
SCHEMA_FILE=DSP8010_$(REDFISH_VERSION).zip
REGISTRY_VERSION=2024.1
REGISTRY_FILE=DSP8011_$(REGISTRY_VERSION).zip
B=DSP8010_$(REDFISH_VERSION)
# Check for GNU mv
GNUMV=$(shell which gmv || echo mv)
SWORDFISH_VERSION=v1.2.6
SWORDFISH_SCHEMA_FILE=Swordfish_$(SWORDFISH_VERSION)_Schema.zip
SWORDFISH_LINK=https://www.snia.org/sites/default/files/technical-work/swordfish/release/$(SWORDFISH_VERSION)/zip/$(SWORDFISH_SCHEMA_FILE)
OPENAPI_DOCUMENT=$(B)/openapi/openapi.yaml
JAR_FILE=redfish-generator/target/redfish-codegen-0.3.1-SNAPSHOT.jar
JVM_ARGS=-DmaxYamlCodePoints=6291456 -Dfile.encoding=UTF-8
ifdef CARGO_FEATURE_CLIENT
JAR_ARGS += -clientMode
endif
define redfish_models
(cd $1 && java $(JVM_ARGS) -jar ../$(JAR_FILE) \
-specDirectory ../$(B) \
-specVersion $(REDFISH_VERSION) \
-registryDirectory ../registry \
-component $2 $(JAR_ARGS))
endef
CODEGEN_DEPENDENCIES += $(B)/openapi/openapi.yaml
CODEGEN_DEPENDENCIES += registry/DSP8011_$(REGISTRY_VERSION).pdf
CODEGEN_DEPENDENCIES += $(JAR_FILE)
models: redfish-models/src/lib.rs
routing: redfish-axum/src/lib.rs
redfish-models/src/lib.rs: $(CODEGEN_DEPENDENCIES)
$(call redfish_models,redfish-models,models)
redfish-axum/src/lib.rs: $(CODEGEN_DEPENDENCIES)
$(call redfish_models,redfish-axum,routing)
# Schema
$(SCHEMA_FILE):
curl -LO $(RELEASE_LINK)/$(SCHEMA_FILE)
$(SWORDFISH_SCHEMA_FILE):
curl -LO $(SWORDFISH_LINK)
SCHEMA_FILES += $(SCHEMA_FILE)
SCHEMA_FILES += $(SWORDFISH_SCHEMA_FILE)
SCHEMA_FILES += $(REGISTRY_FILE)
get-schema: $(SCHEMA_FILES)
$(B)/.unzip.lock: $(SCHEMA_FILES)
unzip -o -DD $(SCHEMA_FILE)
: # Unzip from the swordfish distribution only those files which are
: # not included in the Redfish distribution.
unzip -n -DD -d swordfish $(SWORDFISH_SCHEMA_FILE)
$(GNUMV) --update=none swordfish/yaml/* $(B)/openapi/
unzip -o -DD -d registry $(REGISTRY_FILE)
touch $@
unzip: DSP8010_$(REDFISH_VERSION)/.unzip.lock
$(B)/openapi/openapi.yaml: $(B)/.unzip.lock
-if [ -f schema-patches/series ]; then \
QUILT_PC=$(B)/.pc QUILT_PATCHES=schema-patches quilt push -a --leave-rejects; \
fi
sed -i -e 's#http://redfish.dmtf.org/schemas/v1#.#' $(B)/openapi/*.yaml
sed -i -e 's#http://redfish.dmtf.org/schemas/swordfish/v1#.#' \
$(B)/openapi/*.yaml
clean:
rm -rf $(B) registry swordfish
# Registry
$(REGISTRY_FILE):
curl -L -O $(RELEASE_LINK)/$(REGISTRY_FILE)
registry/DSP8011_$(REGISTRY_VERSION).pdf: $(B)/.unzip.lock
-QUILT_PC=registry/.pc QUILT_PATCHES=registry-patches quilt push -a
touch $@
prepare: registry/DSP8011_$(REGISTRY_VERSION).pdf $(B)/openapi/openapi.yaml
# Jar
$(JAR_FILE): redfish-generator/pom.xml
(cd redfish-generator && mvn clean package)
.PHONY: get-schema unzip clean prepare
###############################################################################