forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
117 lines (97 loc) · 3.59 KB
/
GNUmakefile
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
115
116
117
# See https://googlecloudplatform.github.io/magic-modules/docs/getting-started/generate-providers/
# for a guide on provider generation.
default: build
# mm setup
ifeq ($(ENGINE),tpgtools)
# we specify the product to one that doesn't
# exist so exclusively build base tpgtools implementation
mmv1_compile=-p does-not-exist
else ifneq ($(PRODUCT),)
mmv1_compile=-p products/$(PRODUCT)
else
mmv1_compile=-a
endif
# tpgtools setup
ifeq ($(ENGINE),mmv1)
# we specify the product to one that doesn't
# exist so exclusively build base mmv1 implementation
tpgtools_compile = --service does-not-exist
else ifneq ($(PRODUCT),)
tpgtools_compile = --service $(PRODUCT)
else
tpgtools_compile =
endif
ifneq ($(RESOURCE),)
mmv1_compile += -t $(RESOURCE)
tpgtools_compile += --resource $(RESOURCE)
endif
ifneq ($(OVERRIDES),)
mmv1_compile += -r $(OVERRIDES)
tpgtools_compile += --overrides $(OVERRIDES)/tpgtools/overrides --path $(OVERRIDES)/tpgtools/api
serialize_compile = --overrides $(OVERRIDES)/tpgtools/overrides --path $(OVERRIDES)/tpgtools/api
else
tpgtools_compile += --path "api" --overrides "overrides"
serialize_compile = --path "api" --overrides "overrides"
endif
ifneq ($(VERBOSE),)
tpgtools_compile += --logtostderr=1 --stderrthreshold=2
endif
UNAME := $(shell uname)
# The inplace editing semantics are different between linux and osx.
ifeq ($(UNAME), Linux)
SED_I := -i
else
SED_I := -i '' -E
endif
ifeq ($(FORCE_DCL),)
FORCE_DCL=latest
endif
terraform build provider:
@make validate_environment;
make mmv1
make tpgtools
make teamcity-servicemap-generate
mmv1:
cd mmv1;\
bundle; \
bundle exec compiler.rb -e terraform -o $(OUTPUT_PATH) -v $(VERSION) $(mmv1_compile);
tpgtools:
make serialize
cd tpgtools;\
go run . --output $(OUTPUT_PATH) --version $(VERSION) $(tpgtools_compile)
# This should be removed when all DCL resources are migrated to MMv1; service map generation should be
# controlled inside MMv1, like originally implemented in this PR: https://github.com/GoogleCloudPlatform/magic-modules/pull/8254
teamcity-servicemap-generate:
cd tools/teamcity-generator;\
go run . --output $(OUTPUT_PATH) --version $(VERSION)
tgc:
cd mmv1;\
bundle;\
bundle exec compiler -e terraform -f tgc -v beta -o $(OUTPUT_PATH) $(mmv1_compile);\
test:
cd mmv1; \
bundle; \
bundle exec rake test
serialize:
cd tpgtools;\
cp -f serialization.go.base serialization.go &&\
go run . $(serialize_compile) --mode "serialization" > temp.serial &&\
mv -f temp.serial serialization.go
upgrade-dcl:
make serialize
cd tpgtools && \
go mod edit -dropreplace=github.com/GoogleCloudPlatform/declarative-resource-client-library &&\
go mod edit -require=github.com/GoogleCloudPlatform/declarative-resource-client-library@$(FORCE_DCL) &&\
go mod tidy;\
MOD_LINE=$$(grep declarative-resource-client-library go.mod);\
SUM_LINE=$$(grep declarative-resource-client-library go.sum);\
cd ../mmv1/third_party/terraform && \
sed ${SED_I} "s!.*declarative-resource-client-library.*!$$MOD_LINE!" go.mod.erb; echo "$$SUM_LINE" >> go.sum
validate_environment:
# only print doctor script to console if there was a dependency failure detected.
@./scripts/doctor 2>&1 > /dev/null || ./scripts/doctor
@[ -d "$(OUTPUT_PATH)" ] || (printf " \e[1;31mdirectory '$(OUTPUT_PATH)' does not exist - ENV variable \033[0mOUTPUT_PATH\e[1;31m should be set to a provider directory. \033[0m \n" && exit 1);
@[ -n "$(VERSION)" ] || (printf " \e[1;31mversion '$(VERSION)' does not exist - ENV variable \033[0mVERSION\e[1;31m should be set to ga or beta \033[0m \n" && exit 1);
doctor:
./scripts/doctor
.PHONY: mmv1 tpgtools test