forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
81 lines (64 loc) · 1.98 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
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
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:
make serialize
make mmv1
make tpgtools
mmv1:
cd mmv1;\
bundle; \
bundle exec compiler -e terraform -o $(OUTPUT_PATH) -v $(VERSION) $(mmv1_compile);
tpgtools:
cd tpgtools;\
go run . --path "api" --overrides "overrides" --output $(OUTPUT_PATH) --version $(VERSION) $(tpgtools_compile)
validator:
cd mmv1;\
bundle; \
bundle exec compiler -e terraform -f validator -o $(OUTPUT_PATH) $(mmv1_compile);
serialize:
cd tpgtools;\
go run . --path "api" --overrides "overrides" --mode "serialization" > temp.serial &&\
mv -f temp.serial serialization.go;\
upgrade-dcl:
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
.PHONY: mmv1 tpgtools