forked from brendanhay/gogol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (49 loc) · 1.5 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
SHELL := /usr/bin/env bash
TOP := ..
BIN := bin
MODEL_DIR := model
OUT_DIR := ..
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' gogol-gen.cabal)
CORE_VERSION = $(call version,$(TOP)/core/gogol-core.cabal)
CLIENT_VERSION = $(call version,$(TOP)/gen/gogol-gen.cabal)
MODELS ?= $(shell find $(MODEL_DIR) -type f -name '*.json' | sort)
.PHONY: gen format $(BIN)/gogol-gen
release: gen format
gen: $(BIN)/gogol-gen $(MODEL_DIR)
$(BIN)/gogol-gen \
--out=$(OUT_DIR) \
--library-version=$(VERSION) \
--client-version=$(CLIENT_VERSION) \
--core-version=$(CORE_VERSION) \
--annexes=annex \
--templates=template \
--static=static \
$(addprefix --model=,$(MODELS))
format:
@echo -e '\nFormatting...'
@find $(wildcard $(OUT_DIR)/gogol-*/gen) \
-type f \
-name '*.hs' \
-printf ' -> %p\n' \
-exec stylish-haskell -i {} \;
$(BIN)/gogol-gen: $(BIN)
stack build gogol-gen --copy-bins --local-bin-path $(BIN)
$(BIN):
mkdir $@
clean:
stack clean
rm -rf $(MODEL_DIR)
full-clean: clean
rm -rf vendor model
$(MODEL_DIR): vendor/google-api-go-client
@./script/copy-models $< $@
vendor/google-api-go-client:
git clone [email protected]:google/google-api-go-client $@
.PHONY: audit
ACTUAL = $(addsuffix \\n,$(sort $(notdir $(MODELS))))
EXPECT = $(addsuffix -api.json\\n,$(sort $(notdir $(basename $(wildcard annex/*.json)))))
audit: $(MODEL_DIR)
@diff -B -y <(echo -e $(ACTUAL)) <(echo -e $(EXPECT))