This repository has been archived by the owner on Jul 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
executable file
·172 lines (146 loc) · 4.66 KB
/
Makefile
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#--------------#
# s3d Makefile #
#--------------#
MODE := debug
ifeq ($(RELEASE),1)
MODE = release
CARGO_BUILD_FLAGS += --release
endif
ifdef VERBOSE
CARGO_BUILD_FLAGS += -v
endif
LOG = @echo "\nMakefile: 🥷 "
LOG_START = @echo "\nMakefile: 🥷 $@ start ...\n"
LOG_DONE = @echo "\nMakefile: ✅ $@ done\n"
TIMER := time
IMAGE := s3d:dev
IMAGE_BUILDER := docker
CODEGEN_CRATES_DIR := smithy-rs/s3d/build/crates
CODEGEN_SERVER_S3 := $(CODEGEN_CRATES_DIR)/s3d-smithy-codegen-server-s3
CODEGEN_SDK_DIR := smithy-rs/aws/sdk/build/aws-sdk/sdk
CARGO_BUILD_CMD := $(TIMER) cargo build $(CARGO_BUILD_FLAGS)
CARGO_TEST_CMD := $(TIMER) cargo test $(CARGO_BUILD_FLAGS) # using same flags as build for now
#--------------------------------------------#
# build - binaries only, the default for dev #
#--------------------------------------------#
build: codegen_init_once
$(LOG_START)
$(CARGO_BUILD_CMD)
$(LOG) "Built binary: target/$(MODE)/s3"
$(LOG) "Built binary: target/$(MODE)/s3d"
$(LOG_DONE)
.PHONY: build
#------#
# help #
#------#
help:
@echo ""
@echo "Makefile targets:"
@echo ""
@echo " build - (default) binaries only, the default for dev"
@echo " all - codegen + build + test"
@echo " codegen - generate code from smithy-rs"
@echo " test - cargo test"
@echo " image - build container image"
@echo " clean - start fresh"
@echo " env - prints shell commands for dev"
@echo ""
.PHONY: help
#------------------------------#
# all - codegen + build + test #
#------------------------------#
all: codegen build test
$(LOG_DONE)
.PHONY: all
#-----------------------------------#
# codegen - generate from smithy-rs #
#-----------------------------------#
codegen: submodules_init_once
$(LOG_START)
cd smithy-rs && $(TIMER) ./gradlew -i \
:rust-runtime:assemble \
:aws:sdk:assemble \
:s3d:assemble \
-Paws.services=+sts,+sso,+s3 \
-Ps3d.release=false
@#####################################
@## moving all crates to crates dir ##
@#####################################
rm -rf $(CODEGEN_CRATES_DIR)
mkdir -p $(CODEGEN_CRATES_DIR)
mv smithy-rs/rust-runtime/build/smithy-rs/rust-runtime/* $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/aws-config $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/aws-endpoint $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/aws-http $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/aws-sig-auth $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/aws-sigv4 $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/aws-types $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/s3 $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/sso $(CODEGEN_CRATES_DIR)/
mv $(CODEGEN_SDK_DIR)/sts $(CODEGEN_CRATES_DIR)/
mv smithy-rs/s3d/build/smithyprojections/s3d/s3/rust-server-codegen $(CODEGEN_SERVER_S3)
$(LOG_DONE)
.PHONY: codegen
# CAUTION:
# submodules target should NOT be used if you are making changes directly
# on the smithy-rs submodule (which is useful for dual development),
# because it will effectively `git reset --hard` on the submodule HEAD
# and discard local commits and worktree changes. however, for most users
# this is desired as they would not change the submodule directly.
submodules:
$(LOG_START)
cd smithy-rs && git remote -v
cd smithy-rs && git branch -avv
git submodule status
git submodule update --init
git submodule status
$(LOG_DONE)
.PHONY: submodules
# the "init_once" targets avoid rebuilding more than once when used as dep,
# but we can still run the main targets unconditionally as needed.
codegen_init_once: | $(CODEGEN_SERVER_S3)
.PHONY: codegen_init_once
submodules_init_once: | smithy-rs/README.md
.PHONY: submodules_init_once
$(CODEGEN_SERVER_S3):
$(call LOG,call make codegen)
$(TIMER) $(MAKE) codegen
smithy-rs/README.md:
$(call LOG,call make submodules)
$(TIMER) $(MAKE) submodules
#-------------------#
# test - cargo test #
#-------------------#
test:
$(LOG_START)
@#### TODO - no tests yet !!! ####
@# $(CARGO_TEST_CMD)
@# cd $(CODEGEN_SERVER_S3) && $(CARGO_TEST_CMD)
$(LOG_DONE)
.PHONY: test
#-------------------------------------#
# image - containerization buildation #
#-------------------------------------#
image:
$(LOG_START)
$(TIMER) $(IMAGE_BUILDER) build . -t $(IMAGE)
$(LOG_DONE)
.PHONY: image
#---------------------#
# clean - start fresh #
#---------------------#
clean:
$(LOG_START)
cd smithy-rs && $(TIMER) ./gradlew clean
$(TIMER) cargo clean
$(LOG_DONE)
.PHONY: clean
#------------------------------------#
# env - print shell commands for dev #
#------------------------------------#
env:
@echo "alias s3=\"\$$PWD/target/$(MODE)/s3\";"
@echo "alias s3d=\"\$$PWD/target/$(MODE)/s3d\";"
@echo "alias aws3d='aws --endpoint http://localhost:33333';"
@echo "# usage: eval \$$(make env)"
.PHONY: env