-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
107 lines (78 loc) · 2.69 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
config ?= release
PACKAGE := eohippus
PONYC ?= ponyc
GET_DEPENDENCIES_WITH := corral fetch
CLEAN_DEPENDENCIES_WITH := corral clean
COMPILE_WITH := corral run -- $(PONYC)
BUILD_DIR ?= build/$(config)
SRC_DIR := $(PACKAGE)
TESTS_DIR := $(PACKAGE)/test
CLI_DIR := eohippus-cli
LSP_DIR := eohippus-lsp
FMT_DIR := eohippus-fmt
EXAMPLES_DIR := examples
binary := $(BUILD_DIR)/$(PACKAGE)
tests_binary := $(BUILD_DIR)/test
cli_binary := $(BUILD_DIR)/$(CLI_DIR)
lsp_binary := $(BUILD_DIR)/$(LSP_DIR)
fmt_binary := $(BUILD_DIR)/$(FMT_DIR)
docs_dir := build/$(PACKAGE)-docs
ifdef config
ifeq (,$(filter $(config),debug release))
$(error Unknown configuration "$(config)")
endif
endif
ifeq ($(config),release)
PONYC = $(COMPILE_WITH)
else
PONYC = $(COMPILE_WITH) --debug
endif
ifneq ($(wildcard .git),)
tag := $(shell cat VERSION)-$(shell git rev-parse --short HEAD)
else
tag := $(shell cat VERSION)
endif
SOURCE_FILES := $(shell find $(SRC_DIR) -name *.pony)
CLI_FILES := $(shell find $(CLI_DIR) -name *.pony)
LSP_FILES := $(shell find $(LSP_DIR) -name *.pony)
FMT_FILES := $(shell find $(FMT_DIR) -name *.pony)
VERSION := "$(tag) [$(config)]"
GEN_FILES_IN := $(shell find $(SRC_DIR) -name \*.pony.in)
GEN_FILES = $(patsubst %.pony.in, %.pony, $(GEN_FILES_IN))
#EXAMPLES := $(notdir $(shell find $(EXAMPLES_DIR)/* -maxdepth 0 -type d))
#EXAMPLES_SOURCE_FILES := $(shell find $(EXAMPLES_DIR) -name *.pony)
#EXAMPLES_BINARIES := $(addprefix $(BUILD_DIR)/,$(EXAMPLES))
build: $(tests_binary)
test: unit-tests # build-examples
unit-tests: $(tests_binary)
$^ --exclude=integration --sequential
cli: $(cli_binary)
lsp: $(lsp_binary)
fmt: $(fmt_binary)
$(binary): $(GEN_FILES) $(SOURCE_FILES) | $(BUILD_DIR)
$(PONYC) -o $(BUILD_DIR) $(SRC_DIR)
$(tests_binary): $(GEN_FILES) $(SOURCE_FILES) | $(BUILD_DIR)
$(PONYC) -o $(BUILD_DIR) $(TESTS_DIR)
$(cli_binary): $(GEN_FILES) $(SOURCE_FILES) $(CLI_FILES) | $(BUILD_DIR)
$(PONYC) -o $(BUILD_DIR) $(CLI_DIR)
$(lsp_binary): $(GEN_FILES) $(SOURCE_FILES) $(LSP_FILES) | $(BUILD_DIR)
$(PONYC) -o $(BUILD_DIR) $(LSP_DIR)
$(fmt_binary): $(GEN_FILES) $(SOURCE_FILES) $(FMT_FILES) | $(BUILD_DIR)
$(PONYC) -o $(BUILD_DIR) $(FMT_DIR)
%.pony: %.pony.in
sed s/%%VERSION%%/$(VERSION)/ $< > $@
build-examples: $(EXAMPLES_BINARIES)
$(EXAMPLES_BINARIES): $(BUILD_DIR)/%: $(SOURCE_FILES) $(EXAMPLES_SOURCE_FILES) | $(BUILD_DIR)
$(PONYC) -o $(BUILD_DIR) $(EXAMPLES_DIR)/$*
clean:
$(CLEAN_DEPENDENCIES_WITH)
rm -rf $(BUILD_DIR)
$(docs_dir): $(GEN_FILES) $(SOURCE_FILES)
$(PONYC) --docs-public --pass=expr --output build $(SRC_DIR)
docs: $(docs_dir)
TAGS:
ctags --recurse=yes $(SRC_DIR)
all: test
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
.PHONY: all build-examples clean docs TAGS test cli lsp fmt