forked from brendanhay/amazonka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (61 loc) · 1.93 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
SHELL := /usr/bin/env bash
TOP_DIR := ..
MODEL_DIR := model
OUT_DIR := ..
BIN_DIR := ../bin
GENERATE := $(BIN_DIR)/amazonka-gen
BRITTANY := $(BIN_DIR)/brittany
STYLISH := $(BIN_DIR)/stylish-haskell
define version =
$(shell sed -n 's/^version: *\([0-9]*\.[0-9]*\.[0-9]\).*$$/\1/p' $(1))
endef
VERSION = $(shell sed -n 's/^version: *\(.*\)$$/\1/p' amazonka-gen.cabal)
CORE_VERSION = $(call version,$(TOP_DIR)/core/amazonka-core.cabal)
CLIENT_VERSION = $(call version,$(TOP_DIR)/gen/amazonka-gen.cabal)
MODELS ?= $(sort $(dir $(wildcard $(MODEL_DIR)/*/*)))
.PHONY: gen format $(GENERATE)
all: gen format
debug:
@echo $(MODELS)
gen: $(MODEL_DIR) $(GENERATE)
$(GENERATE) \
--out=$(OUT_DIR) \
--library-version=$(VERSION) \
--client-version=$(CLIENT_VERSION) \
--core-version=$(CORE_VERSION) \
--annexes=annex \
--configs=config \
--templates=template \
--static=static \
--retry=$(MODEL_DIR)/_retry.json \
$(addprefix --model=,$(MODELS))
format: $(STYLISH)
@echo -e '\nFormatting...'
@find \
$(wildcard $(OUT_DIR)/amazonka-*/gen) \
$(wildcard $(OUT_DIR)/amazonka-*/test/Test/AWS/Gen) \
-type f \
-name '*.hs' \
-exec sh -c "printf ' -> %s\n' $1 {}; $(BRITTANY) --write-mode=inplace {}; $(STYLISH) -i {}" \;
$(GENERATE): $(BIN_DIR)
stack install --nix amazonka-gen
$(BRITTANY): $(BIN_DIR)
stack install --nix brittany
$(STYLISH): $(BIN_DIR)
stack install --nix stylish-haskell
$(BIN_DIR):
mkdir $@
clean:
stack clean --nix
rm -rf $(MODEL_DIR) $(OUT_DIR)/amazonka-*/gen
full-clean: clean
rm -rf vendor $(GENERATE) $(STYLISH)
$(MODEL_DIR): vendor/botocore
cp -rf vendor/botocore/botocore/data/ $@
vendor/botocore:
git clone https://github.com/boto/botocore.git $@
.PHONY: audit
ACTUAL = $(sort $(addsuffix \\n,$(notdir $(wildcard config/*.json))))
EXPECT = $(sort $(addsuffix .json\\n,$(notdir $(patsubst %/,%,$(wildcard model/*/)))))
audit: $(MODEL_DIR)
@diff -B -y <(echo -e $(ACTUAL)) <(echo -e $(EXPECT))